[Bug]: OAS 3.1 list-style "type" raises in SchemaCaster and StyleDeserializersFactory

Đang mở
#1,180 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
api

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ả

kind/bug kind/bug/confirmed
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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python-openapi/openapi-core

Tất cả issue của python-openapi/openapi-core

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.