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
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:
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.
Screenshots/Code Snippets
Resulting specification:
By the way, SwashBuckle is used for specification generation.
Additional context
This is more a question than bug report. For myself, the solution was to not use the copy constructor and to modify the source object directly.
The text was updated successfully, but these errors were encountered: