You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenApiOperation copy constructor is creating RequestBody even if in source object it was null #1515
Describe the bug
The problem is, when using extension method .WithOpenApi() to customize OpenAPI specification for some endpoint and when using copy constructor (#832) in the handler, as suggested, the result is that object created using copy constructor will have RequestBody even if in source object it was null. The drawback of that is that OpenAPI specification for that endpoint will have requestBody and if using that specification we try to generate client, generated client will require body for requests even if body is not required (this happens mostly for GET endpoints).
OpenApi File To Reproduce
/
Expected behavior
Expected is next: If in source object RequestBody is null, then in newly created object, which should be copy of source object, RequestBody should also be null.
We only new up a RequestBody object in the OpenApiOperation copy constructor if it exists in the source object as defined below, otherwise it results to a null object:
Activity
MaggieKimani1 commentedon Jan 15, 2024
We only new up a
RequestBodyobject in theOpenApiOperationcopy constructor if it exists in the source object as defined below, otherwise it results to a null object:OpenAPI.NET/src/Microsoft.OpenApi/Models/OpenApiOperation.cs
Line 124 in 4de9313
Can you share a file/example that can help us reproduce this issue on our end?
panky98 commentedon Jan 15, 2024
Hi Maggie Kimani (@MaggieKimani1). In my project, I am using v7.0.11, probably as soon as we migrate to dotnet 8 everything is going to be ok
then.
Thank you very much for the response :)
MaggieKimani1 commentedon Jan 16, 2024
Closing this issue as it was already fixed by #1195