You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When validating a request, I get a different validation error depending on the structure of the schema.
If I have the following schema:
Pet:
type: object # <-- this causes the differenceproperties:
id:
type: integerPet2:
allOf:
- properties:
id:
type: integer
and send a request with body {"id": "hello"},
with the first schema I get:
openapi_core.casting.schemas.exceptions.CastError: Failed to cast value to integer type: hello
whereas in the second one I get:
openapi_core.validation.schemas.exceptions.InvalidSchemaValue: Value {'id': 'hello'} not valid for schema of type any: (<ValidationError: "'hello' is not of type 'integer'">,)
Expected Behavior
These schemas are equivalent, and as such I expected to get the same error. Specifically, I expected the validation error in both cases rather than the casting error as I asked for request validation.
Also, removing the type: object in the first schema seems to bypass casting entirely and leads to the same validation error as the second schema.
Actual Behavior
When validating a request, I get a different validation error depending on the structure of the schema.
If I have the following schema:
and send a request with body
{"id": "hello"}
,with the first schema I get:
whereas in the second one I get:
Expected Behavior
These schemas are equivalent, and as such I expected to get the same error. Specifically, I expected the validation error in both cases rather than the casting error as I asked for request validation.
Also, removing the
type: object
in the first schema seems to bypass casting entirely and leads to the same validation error as the second schema.Steps to Reproduce
schema.yaml
OpenAPI Core Version
0.19.0
OpenAPI Core Integration
starlette
Affected Area(s)
casting, validation
References
No response
Anything else we need to know?
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: