-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suppress null check in response object in latest version of NSwagStudio 13.7.0.0 #3011
Comments
Duplicate of #2995 |
It's in fact a duplicate of #3015 . The explanation and workaround is given here : #2995 (comment) We did that to allow the implementation of proper NullableReferenceTypes and for that, we need to be able to trust the spec. If the spec doesn't declare the result as nullable, then we consider it to be not null. I don't know how you could do that with Swashbuckle, but you need to add |
Thanks for reply. @jeremyVignelles and @RicoSuter I tried couple of workarounds mentioned in linked issue and also the XML document of setting We don't even have reference to this extension at the moment. Also
What are the options available to us and how do i do this: but you need to add nullable: true in your OpenApi spec file where relevant Any help to workaround this would be great. We only have to decorate few POST endpoints to make them return nullable. Our workflow is: Opening nswag.json in NSwagStudio and then generate files (with service successfully launching swagger endpoint in background) |
You need to tell swashbuckle that the result can be null. The first thing you tried is NSwag-specific. |
So I cannot override generator telling that all responses can be nullable during client generation? |
We have POST endpoints in ASP.NetCore project that return no response (null) when 200 status code.
Recently when we regenerated clients using latest version of NSwagStudio, we see that it has added additional null checks on response object because of which our tests now fail.
Question is:
Is there a way to configure to not generate this new null checks for specific (or all) endpoints in latest version of NSwagStudio?
Dependency versions:
<Swashbuckle_AspNetCore_Version>5.5.1</Swashbuckle_AspNetCore_Version>
Microsoft.AspNetCore.Mvc.Core, Version=3.1.0.0
Generated client
(before)
(after)
We also tried to change our POST endpoint to return void instead of IActionResult but both ways seem to be producing above null check in clients in latest version of NSwagStudio.
Controller
(before)
[HttpPost]
[ODataRoute]
[Produces("application/json")]
[ProducesResponseType(typeof(IActionResult), Status200OK)]
public Task PostXXX() => ...;
(after)
[HttpPost]
[ODataRoute]
[Produces("application/json")]
[ProducesResponseType(Status200OK)]
public Task PostXXX() => ...;
The text was updated successfully, but these errors were encountered: