openapi-generators / openapi-generators/openapi-python-client
`anyOf` in responses generates invalid body parser
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 2k
- Fork
- 293
- Merge trung bình
- 34 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
Describe the bug
When a response media type has an anyOf schema, the generated code does not parse it properly/is not valid. (see add'l context)
OpenAPI Spec File
https://gist.github.com/nkrishnaswami/8c4a2068d8ac59cab153136a6069b44d
Desktop (please complete the following information):
- OS: macOS 15.6
- Python Version: 3.12.8
- openapi-python-client version: git revision
13bf2e8
Additional context
def _parse_response_200(data: object) -> Union["Response200", Literal["Why have a fixed response? I dunno"]]:
response_200_type_0 = cast(Literal["Why have a fixed response? I dunno"], data)
if response_200_type_0 != "Why have a fixed response? I dunno":
raise ValueError(
f"response_200_type_0 must match const 'Why have a fixed response? I dunno', got '{response_200_type_0}'"
)
return response_200_type_0
if not isinstance(data, dict):
raise TypeError()
response_200_type_1 = Response200.from_dict(data)
return response_200_type_1
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.
Hướng nghiên cứu
Bắt đầu với OpenAPI Spec File được liên kết trong issue và tái hiện ví dụ parse_response_200 được sinh ra cho một response schema sử dụng anyOf. So sánh các nhánh parser được sinh ra và xác minh rằng đầu ra hợp lệ và có thể parse cả hai lựa chọn fixed-value và Response200.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- openapi, python
- Lĩnh vực
- api, tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 38/100