openapi-generators / openapi-generators/openapi-python-client
Incorrect parsing of null as nullable enum value serialized as strings
未关闭
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 2k
- 派生
- 293
- 平均合并
- 34 分钟
- 30 天内合并 PR
- 1
描述
Consider the following schema definition (which passes validation with the openapitools/openapi-generator-cli container image):
// [...]
"deviceEncryptionKeyScheme": {
"$ref": "#/components/schemas/DeviceEncryptionKeyScheme",
"nullable": true // <-- nullability declared
},
// [...]
"DeviceEncryptionKeyScheme": {
"enum": ["Default8"],
"type": "string"
},
It looks as if openapi-python-client version 0.23.1 supports deserialization with the deviceEncryptionKeyScheme property being unset, but not it being null:
_device_encryption_key_scheme = d.pop("deviceEncryptionKeyScheme", UNSET)
device_encryption_key_scheme: Union[Unset, DeviceEncryptionKeyScheme]
if isinstance(_device_encryption_key_scheme, Unset):
device_encryption_key_scheme = UNSET
else:
device_encryption_key_scheme = DeviceEncryptionKeyScheme(_device_encryption_key_scheme)
This looks like a bug to me.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 openapi-python-client 0.23.1 的行为和所示的生成反序列化代码,复现 issue 中的 nullable enum 情况。从 d.pop 之后对 deviceEncryptionKeyScheme 的处理开始;比较 UNSET 路径和 null 路径。当显式为 null 的值能够成功反序列化,同时未设置的属性仍表示为 UNSET 时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- openapi, python
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100