Open ehsanonline opened 5 years ago
The integer validation part works well individually (gives error when passing float or string in baz
key as expected) :
'baz': {
'oneOf': [
{ 'type': 'integer' },
# { 'type': 'number', 'format': 'float' }
]
}
But when using the float validation (should not accept integer) :
'baz': {
'oneOf': [
# { 'type': 'integer' },
{ 'type': 'number', 'format': 'float' }
]
}
but accepts integer! (tested with 123
value)
So the problem should be in { 'type': 'number', 'format': 'float' }
and oneOf
functionality.
@ehsanonline: Despite the fact that you find a workaround for yourself, I would like to explain why you got the validation error.
The reason is not in Quart-OpenAPI itself, but at jsonschema. JSONSchema (which is used for validtion) has 2 keywords for describing several supported cases:
123
is a valid over both your schemas (it can be a string and an integer), so validation with oneOf fails...
I was testing this example code:
Then send this request:
I got this respond:
But I was expecting
{'message':'OK'}
respond. It works with float value forbaz
key.Funny note: at respond in
msg
it says 'is valid' !