openapi-spec-validator
openapi-spec-validator copied to clipboard
`Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['parameters']['items']:`
I get:
{'in': 'query', 'name': 'bar', 'example': '1', 'examples': {'1': {'summary': '1', 'value': '1'}, '2': {'summary': '2', 'value': '2'}}, 'schema': {'type': 'string'}} is not valid under any of the given schemas
Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['parameters']['items']:
{'oneOf': [{'$ref': '#/definitions/Parameter'},
{'$ref': '#/definitions/Reference'}]}
On instance['paths']['/']['get']['parameters'][0]:
{'$ref': '#/components/parameters/foo',
'x-scope': ['file:///usr/share/ucs-test/73_udm-rest/openapi2.json']}
for
{
"components": {
"parameters": {
"foo": {
"in": "query",
"name": "bar",
"example": "1",
"examples": {
"1": {
"summary": "1",
"value": "1"
},
"2": {
"summary": "2",
"value": "2"
}
},
"schema": {
"type": "string"
}
}
}
},
"info": {
"description": "",
"title": "",
"version": "1.0.0"
},
"openapi": "3.0.0",
"paths": {
"/": {
"get": {
"parameters": [
{
"$ref": "#/components/parameters/foo"
}
],
"responses": { "200": {"description": "", "content": {"text/plain": {"schema": {"type": "string"}}}} }
}
}
}
}
since openapi-spec-validator==0.3.0
. It succeeded to validate with openapi-spec-validator==0.2.10
.
If I remove one of example
or examples
from #/components/parameters/foo
the validation succeeds.
Does openapi define them as mutually exclusive?
https://swagger.io/docs/specification/adding-examples/ doesn't seem to contain a mix. The swagger UI just sucks in displaying examples
.
Hi @spaceone
yes you're right, example and examples are mutually exclusive
Example of the parameter’s potential value. The example SHOULD match the specified schema and encoding properties if present. The example field is mutually exclusive of the examples field. Furthermore, if referencing a schema that contains an example, the example value SHALL override the example provided by the schema. To represent examples of media types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where necessary.
See https://spec.openapis.org/oas/v3.0.3#fixed-fields-9
Also see #126 - the error is in components/schemas/foo but the problem is not being reported there