openapi-generators / openapi-generators/openapi-python-client
Support array of format: binary items in multipart/form-data request bodies
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 an OpenAPI 3.0 schema defines a property as an array of binaries inside a multipart/form-data requestBody, the generator currently treats it as a JSON body and emits a single body parameter. As a result:
- The generated
sync_detailed(...)signature has only:
def sync_detailed(
*,
client: Client,
body: UploadFilesPostBody,
hash_: str,
) -> Response[Any]:
…
- Internally
body.files(a list ofFileobjects withpayload: BinaryIO) is passed tojson=…, causing serialization errors.
OpenAPI Spec File
paths:
/upload_files:
post:
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
hash_:
type: string
files:
type: array
items:
type: string
format: binary
responses:
'200':
description: OK
What actually happens
- The generator emits a single body: UploadFilesPostBody parameter.
- When calling sync_detailed(..., body=…), httpx is invoked with json=… and fails on BinaryIO because it isn’t valid JSON.
Desktop:
- OS: Windows 10
- Python Version: cPython 3.12.8
- openapi-python-client version 0.24.3
Additional context
None - if anything is needed, please let me know
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 bằng cách lần theo đường dẫn generator xử lý các request body multipart/form-data và so sánh nó với phương thức sync_detailed(...) được tạo ra mô tả trong issue. Xác minh rằng client được tạo gửi trường files dưới dạng dữ liệu multipart thay vì thông qua httpx json=, và thêm coverage cho OpenAPI schema được cung cấp nếu repository có vị trí kiểm thử generator phù hợp.
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100