Closed
Description
Hi,
Not sure if I'm doing something wrong or if additionalProperties
is missing proper support.
Here is my test case:
from openapi_core import create_spec
from openapi_core.wrappers import MockRequest, MockResponse
from openapi_core.validators import ResponseValidator
schema = {
"components": {
"schemas": {
"Errors": {
"additionalProperties": {
"type": "string"
},
"type": "object"
}
}
},
"info": {
"title": "xxx",
"version": "1.0.0"
},
"openapi": "3.0.0",
"paths": {
"/simulate": {
"get": {
"responses": {
"422": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Errors"
}
}
},
"description": "Error in data"
}
}
}
}
}
}
spec = create_spec(schema)
validator = ResponseValidator(spec)
request = MockRequest('http://localhost', 'get', '/simulate')
response = MockResponse('{"error_key": "message"}', 422)
result = validator.validate(request, response)
result.raise_for_errors()
Which raises the error openapi_core.exceptions.UndefinedSchemaProperty: Undefined properties in schema: {'error_key'}
.
I'm expecting instead that any key is allowed in the Error
schema, given I'm using additionalProperties
(see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.6 and this discussion).
Thanks for your inputs on this! :)