openapi-generators / openapi-generators/openapi-python-client
TypeError when model default value is a list
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 2k
- 分支
- 293
- 平均合併
- 34 分鐘
- 30 天內合併 PR
- 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 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 openapi_python_client/parser/properties/init.py 第 463 行附近開始,使用 openapi-python-client generate --url https://sand-docs.ilevelsolutions.eu/openapi.yaml 重現此失敗。追蹤具有列表值的 enum 預設值如何表示,並檢查相關的 parser 測試。當 specification 能夠成功產生且不出現 TypeError,同時維持現有行為時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- openapi, python
- 領域
- api, tooling
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 65/100