openapi-generators / openapi-generators/openapi-python-client
body type mismatch
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 2k
- フォーク
- 293
- 平均マージ
- 34分
- マージ済み PR(30日)
- 1
説明
Describe the bug
In the _get_kwargs generated method, the body is determined as File type (because the format in my swagger definition is binary), but it tries to access its .to_dict attribute (because body_type is considered as data due to the content type application/x-www-form-urlencoded), which does not exist because it is a file
OpenAPI Spec File
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"description": "do stuff",
"type": "string",
"format": "binary"
}
}
}
Desktop (please complete the following information):
- OS: macOS 13.3.1
- Python Version: 3.9.8
- openapi-python-client version: 0.17.2
Additional context
In the macro, the arguments macro determine the argument type of body based on endpoint.bodies[0].prop.get_type_string(), whereas in the body_to_kwarg macro it determines it based on body.body_type, which is determined by the following:
if simplified_content_type == "application/x-www-form-urlencoded":
body_type = BodyType.DATA
elif simplified_content_type == "multipart/form-data":
body_type = BodyType.FILES
elif simplified_content_type == "application/octet-stream":
body_type = BodyType.CONTENT
elif simplified_content_type == "application/json" or simplified_content_type.endswith("+json"):
body_type = BodyType.JSON
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Start with the generated _get_kwargs method and trace the arguments and body_to_kwarg macros, especially how endpoint.bodies[0].prop.get_type_string() differs from body.body_type. Review the application/x-www-form-urlencoded BodyType mapping and verify that a binary body no longer attempts to access .to_dict.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api, tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100