Repro
$ npx oav generate-examples widgets.json; npx oav validate-example widgets.json
If you remove description from PagedWidgetSuite, somehow validate-example doesn't throw an error.
Expected
No errors
Actual
Fails to match empty response in example, with empty model in 200 response in spec
$ npx oav validate-example widgets.json
{
message: 'Validating "examples" and "x-ms-examples" in widgets.json:\n',
level: '\x1B[32minfo\x1B[39m'
}
Error reported:
{
code: 'INVALID_TYPE',
message: 'Expected type but found type object',
schemaUrl: 'widgets.json',
exampleUrl: 'example.json',
schemaPosition: { line: 22, column: 22 },
schemaJsonPath: undefined,
examplePosition: { line: 10, column: 16 },
exampleJsonPath: '$response.200/body',
severity: 0,
source: 'response',
operationId: 'Widgets_ListWidgets',
level: '\x1B[31merror\x1B[39m'
}
Files
widgets.json
{
"swagger": "2.0",
"paths": {
"/widgets": {
"get": {
"operationId": "Widgets_ListWidgets",
"description": "List Widget resources",
"parameters": [],
"responses": {
"200": {
"description": "The request has succeeded.",
"schema": {
"$ref": "#/definitions/PagedWidgetSuite"
}
}
}
}
},
"/widgets2": {
"get": {
"operationId": "Widgets_ListWidgets2",
"description": "List Widget resources",
"parameters": [],
"responses": {
"200": {
"description": "The request has succeeded.",
"schema": {
"$ref": "#/definitions/PagedWidgetSuite2"
}
}
}
}
}
},
"definitions": {
"PagedWidgetSuite": {
"type": "object",
"description": "Paged collection of WidgetSuite items"
},
"PagedWidgetSuite2": {
"type": "object",
"description": "Paged collection of WidgetSuite items",
"properties": {
"nextLink": {
"type": "string",
"format": "uri",
"description": "The link to the next page of items"
}
},
"required": [
"nextLink"
]
}
}
}
Repro
If you remove
descriptionfromPagedWidgetSuite, somehow validate-example doesn't throw an error.Expected
No errors
Actual
Fails to match empty response in example, with empty model in 200 response in spec
Files
widgets.json
{ "swagger": "2.0", "paths": { "/widgets": { "get": { "operationId": "Widgets_ListWidgets", "description": "List Widget resources", "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedWidgetSuite" } } } } }, "/widgets2": { "get": { "operationId": "Widgets_ListWidgets2", "description": "List Widget resources", "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedWidgetSuite2" } } } } } }, "definitions": { "PagedWidgetSuite": { "type": "object", "description": "Paged collection of WidgetSuite items" }, "PagedWidgetSuite2": { "type": "object", "description": "Paged collection of WidgetSuite items", "properties": { "nextLink": { "type": "string", "format": "uri", "description": "The link to the next page of items" } }, "required": [ "nextLink" ] } } }