openapi-generators / openapi-generators/openapi-python-client
TypeError when model default value is a list
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 2k
- フォーク
- 293
- 平均マージ
- 34分
- マージ済み PR(30日)
- 1
説明
Describe the bug
When generating models for an API where a default argument is a list of enums, a TypeError is raised on this line:
return f"{prop.class_info.name}.{inverse_values[default]}"
A possible fix could be to explicitly check for this case. Below is a proposed fix, but I'm not familiar enough with the codebase to know whether this is a correct fix. However, I was able to parse the API docs correctly with this fix in place:
if type(default) is list:
return [f"prop.class_info.name.inverse_values[d]" for d in default]
else:
return f"{prop.class_info.name}.{inverse_values[default]}"
To Reproduce
Steps to reproduce the behavior:
- Run
openapi-python-client generate --url https://sand-docs.ilevelsolutions.eu/openapi.yaml - See error
Expected behavior
The API docs should be able to be parsed
OpenAPI Spec File
https://sand-docs.ilevelsolutions.eu/openapi.yaml
Desktop (please complete the following information):
- OS: macOS 13.1
- Python Version: 3.10
- openapi-python-client version: 0.13.1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
openapi_python_client/parser/properties/init.py の463行目付近から始め、openapi-python-client generate --url https://sand-docs.ilevelsolutions.eu/openapi.yaml で失敗を再現してください。リスト値を持つ enum のデフォルト値がどのように表現されているかを追跡し、関連する parser テストを確認してください。TypeError なしで仕様が正常に生成され、既存の動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- openapi, python
- 領域
- api, tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 65/100