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