Actual Behavior
When a schema uses OpenAPI 3.1's list form for type (e.g. type: ["string", "integer"]), parameter casting and style deserialization fail.
It works okay in version 0.19.5, but does not work in version 0.23.1 (I did not test the versions in between).
Expected Behavior
Per the OpenAPI 3.1 specification, type may be either a string or a non-empty array of strings.
Steps to Reproduce
from openapi_core.casting.schemas import oas31_schema_casters_factory
from jsonschema_path import SchemaPath
spec = {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": ["string", "number", "boolean"]
}
schema = SchemaPath.from_dict(spec)
oas31_schema_casters_factory.create(spec, schema).cast("42")
This snippet raises TypeError: Expected a string value, got <class 'list'>.
OpenAPI Core Version
0.23.1
OpenAPI Core Integration
flask
Affected Area(s)
casting, deserializing.
References
No response
Anything else we need to know?
jsonschema_path.SchemaPath already exposes read_str_or_list. So we should use it.
Would you like to implement a fix?
Yes
Actual Behavior
When a schema uses OpenAPI 3.1's list form for type (e.g. type: ["string", "integer"]), parameter casting and style deserialization fail.
It works okay in version 0.19.5, but does not work in version 0.23.1 (I did not test the versions in between).
Expected Behavior
Per the OpenAPI 3.1 specification, type may be either a string or a non-empty array of strings.
Steps to Reproduce
This snippet raises TypeError: Expected a string value, got <class 'list'>.
OpenAPI Core Version
0.23.1
OpenAPI Core Integration
flask
Affected Area(s)
casting, deserializing.
References
No response
Anything else we need to know?
jsonschema_path.SchemaPathalready exposesread_str_or_list. So we should use it.Would you like to implement a fix?
Yes