openapi-generators / openapi-generators/openapi-python-client

Skip setting 'Content-Type' on file upload, when multiple bodies are supported

未關閉 適合新手
#947 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
2k
分支
293
平均合併
34 分鐘
30 天內合併 PR
1

描述

Describe the bug
Form-style submissions to endpoints that support multiple different content types are missing the necessary "boundary" attribute on the Content-Type header.

POST https://.../items HTTP/1.1
Host: ...
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
User-Agent: python-httpx/0.25.2
Authorization: Bearer ...
Content-Type: multipart/form-data
Transfer-Encoding: chunked

Cause
https://github.com/openapi-generators/openapi-python-client/blob/660941dfe23a39ea9a22dd724e1db54afb130d08/openapi_python_client/templates/endpoint_module.py.jinja#L48-L63

In the template above, lines 60-62 have an "if content-type is not multipart/form-data" condition since httpx sets content type and multipart form boundary properly when files are provided. The same condition needs to be applied around line 54, which occurs when multiple body types are supported.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 openapi_python_client/templates/endpoint_module.py.jinja 開始,尤其檢查第 48-63 行附近的 Content-Type 處理以及現有的 multipart 條件。驗證支援多種 body 類型的 endpoint 所產生的 requests,並在 multipart 上傳取得 Content-Type boundary 且不覆寫 httpx 的 header 處理時,視為工作完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
api
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
65/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。