[Bug]: OAS 3.1 list-style "type" raises in SchemaCaster and StyleDeserializersFactory
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
Research direction
Start with the reproduced call to oas31_schema_casters_factory.create and inspect SchemaCaster and StyleDeserializersFactory, especially where SchemaPath values are read. Check how SchemaPath.read_str_or_list can support both string and list-form type values, then rerun the provided casting example and verify style deserialization also handles the OpenAPI 3.1 form.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 368
- Forks
- 140
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-openapi/openapi-core
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
python-openapi/openapi-core#1188 · 2 comments ·
-
kind/bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-openapi/openapi-core#1225 · 2 comments ·
-
kind/bug
Difficulty 3/5 1-2 days Newbie friendliness 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Openkind/bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-openapi/openapi-core#1210 ·
-
kind/enhancement
Difficulty 5/5 Over a week Newbie friendliness 32/100
python-openapi/openapi-core#1142 ·
All issues in python-openapi/openapi-core
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100