Closed pferngren closed 1 year ago
Finally found the fix for this issue, you have to opt in to support for nullable reference types in the setup for swagger gen
services.AddSwaggerGen(options =>
{
options.SupportNonNullableReferenceTypes();
});
Finally found the fix for this issue, you have to opt in to support for nullable reference types in the setup for swagger gen
services.AddSwaggerGen(options => { options.SupportNonNullableReferenceTypes(); });
Thank you, it helped a lot.
I'm trying to correctly specify a string property in a record as being not nullable, but everything I try results in the property being taged as nullable in the generated swagger.
To reproduce the issue create a new .net7 web api with OpenAPI support .csproj
No need to change anything in the program.cs from the template Program.cs
Add a controller and a record model ExampleController.cs
The generated swagger:
Adding the required attribute works for classes but not for records