[Bug]: OAS 3.1 list-style "type" raises in SchemaCaster and StyleDeserializersFactory
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 368
- Fork
- 140
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python-openapi/openapi-core
-
kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
python-openapi/openapi-core#1188 · 2 bình luận ·
-
kind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
python-openapi/openapi-core#1225 · 2 bình luận ·
-
kind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Đang mởkind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
python-openapi/openapi-core#1210 ·
-
kind/enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 32/100
python-openapi/openapi-core#1142 ·
Tất cả issue của python-openapi/openapi-core
Issue tương tự
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
simonw/sqlite-utils#872 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100