microsoft / microsoft/OpenAPI.NET.OData
When EnableDiscriminatorValue is set to true all types end up with a required property of odata.type
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 240
- 派生
- 70
- 平均合并
- 7 小时 59 分钟
- 30 天内合并 PR
- 13
描述
My understanding is odata.type is only required in the case the type cannot be determined such as it being a type derived from the specified type.
When using EnableDiscriminatorValue = true I get correctly odata.type used as a discriminator when a type has a derived type.
I also get however for seemingly all types, odata.type included as a required property.
Assemblies affected
v1.1.0
Steps to reproduce
- Create an odata model with no derived types.
- Generate an Open API specification from the model with EnableDiscriminatorValue = true.
Expected result
I would only expect odata.type to be required in the case a type is a derived type.
Actual result
odata.type is set as required for all types.
If I use Open API connected services in Visual Studio with the specification to generate a client, the client will fail to deserialize responses missing the required property by default.
Additional detail
This can be worked around in most case.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用一个没有派生类型且 EnableDiscriminatorValue 设置为 true 的 OData 模型重现该问题,然后检查生成的 OpenAPI 规范。跟踪 discriminator 元数据如何变成必需属性;完成的标准是,只有在派生类型使其成为必要时,odata.type 才是必需的,同时不破坏有效的客户端反序列化。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, openapi
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100