I'm using NSwag 14.0.2.0, and have noticed that when I use NSwag to generate a controller from my OpenAPI 3.1 specification, if the API consumer sends an invalid payroll (i.e. doesn't deserialise cleanly to the expected type) then .NET deserialises it to null instead, rather than returning a 400 Bad Request as would be expected. Further investigation indicates that the reason for this is that the controllers generated by NSwag to not have the ApiController attribute (see https://learn.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-2.1#annotate-class-with-apicontrollerattribute).
I appreciate that we can always create a custom Liquid template for the controller as a workaround, but would it be possible to add a configuration option to tell NSwag to add the attribute, or even do it automatically for supported versions of .NET Core? Otherwise it seems to be giving up a lot of built-in good stuff.
I'm using NSwag 14.0.2.0, and have noticed that when I use NSwag to generate a controller from my OpenAPI 3.1 specification, if the API consumer sends an invalid payroll (i.e. doesn't deserialise cleanly to the expected type) then .NET deserialises it to null instead, rather than returning a
400 Bad Request
as would be expected. Further investigation indicates that the reason for this is that the controllers generated by NSwag to not have theApiController
attribute (see https://learn.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-2.1#annotate-class-with-apicontrollerattribute).I appreciate that we can always create a custom Liquid template for the controller as a workaround, but would it be possible to add a configuration option to tell NSwag to add the attribute, or even do it automatically for supported versions of .NET Core? Otherwise it seems to be giving up a lot of built-in good stuff.