Failure to validate exclusiveMinimum for OpenAPI 3.0
plondino opened this issue · 1 comments
plondino commented
The following code throws an error when validating:
from openapi_schema_validator import oas30_format_checker
from openapi_schema_validator import validate
# A sample schema
schema = {
"type": "object",
"required": [
"duration"
],
"properties": {
"duration": {
"type": "number",
"exclusiveMinimum": True,
"minimum": 0
}
},
"additionalProperties": False,
}
validate({"duration": 10}, schema, format_checker=oas30_format_checker)
Failed validating 'type' in metaschema['allOf'][1]['properties']['properties']['additionalProperties']['$dynamicRef']['allOf'][3]['properties']['exclusiveMinimum']:
{'type': 'number'}
On schema['properties']['duration']['exclusiveMinimum']:
True
This is valid OpenAPI 3.0 syntax since it follows the Draft 5 JSON schema synatx:
https://swagger.io/specification/#schema-object
https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.5
This would be an error in 3.0 if it was a number.
plondino commented
Disregard, I misread the use of format_checker and it works when using this syntax:
from openapi_schema_validator import OAS30Validator
validate(payload, schema, cls=OAS30Validator)