microsoft / OpenAPI.NET.OData

Generates OpenAPI document from OData CSDL
MIT License
207 stars 62 forks source link

Post/Patch/Delete Paths not generated for type casts #529

Open lorenyaSICKAG opened 6 months ago

lorenyaSICKAG commented 6 months ago

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