openapi-generators / openapi-generators/openapi-python-client
Support array of format: binary items in multipart/form-data request bodies
オープン
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 2k
- フォーク
- 293
- 平均マージ
- 34分
- マージ済み PR(30日)
- 1
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、multipart/form-data リクエストボディを処理する generator path を追跡し、issue で説明されている生成された sync_detailed(...) メソッドと比較します。生成された client が files フィールドを httpx json= 経由ではなく multipart データとして送信することを確認し、リポジトリに関連する generator test の場所がある場合は、提供された OpenAPI schema のカバレッジを追加します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- openapi, python
- 領域
- api, tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100