microsoft / microsoft/OpenAPI.NET.OData

Post/Patch/Delete Paths not generated for type casts

未关闭
#529 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
240
派生
70
平均合并
7 小时 59 分钟
30 天内合并 PR
13

描述

When generating an OpenAPI specification of the OData model, it does not generate the post/patch/delete paths for the type cast entities. In my example (see below) CreateJiraIssue is derived from Widget. But it does not generate the paths for post/patch/delete

image

OData supports post/patch/delete for the cast types! It works when you do an patch request to the correct url. It is also described here:
https://learn.microsoft.com/en-us/odata/webapi-8/fundamentals/entity-routing?tabs=net60%2Cvisual-studio

Assemblies affected

Microsoft.OpenApi.OData (1.6.3)

Steps to reproduce

Create a class A and a derived class B. Add class A as entity set to the odata model.
In the converter settings you need to set RequireDerivedTypesConstraintForODataTypeCastSegments to false.

Expected result

The post/patch/delete paths would be generated for all derived (cast) types.

Actual result

Only the get paths are generated for derived (class) types.

Additional detail

I looked into the code and I have an idea where this is coming from.
The ODataTypeCastPathItemHandler will be used for the path (because of the type cast kind). And there only the Get operation will be set:

https://github.com/microsoft/OpenAPI.NET.OData/blob/92c98108c74121d8eb0eec334762bbcaf6c16007/src/Microsoft.OpenApi.OData.Reader/PathItem/ODataTypeCastPathItemHandler.cs#L16

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 src/Microsoft.OpenApi.OData.Reader/PathItem/ODataTypeCastPathItemHandler.cs 开始,重点关注 issue 中引用的类型转换路径处理。使用基类 A、派生类 B,并将 RequireDerivedTypesConstraintForODataTypeCastSegments 设置为 false,重现该情况。完成的标准是,为转换类型生成的路径除了 GET 外,还包含 POST、PATCH 和 DELETE。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp
领域
api
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
54/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。