Skip to content
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

Swagger UI OpenAPI nullable model properties not nullable in latest stable 5.16.0 #477

Closed
Seramis opened this issue Sep 2, 2023 · 3 comments
Labels
bug Something isn't working fixed the bug has been squashed

Comments

@Seramis
Copy link

Seramis commented Sep 2, 2023

I just recently upgraded from earlier version of FastEndpoints to the latest version of 5.16.0 and noticed that all request model properties have some default values in my swagger-ui. I then dug into it a bit and found that this bug has been introduced in 5.16.0 as it is working as expected in 5.15.0.

The swagger.json seems to be correct in both versions as the property is marked with "nullable": true. So i suspect the bug to reside in the swagger-ui part.

To reproduce:

  • Have FastEndpoint with model containing QueryParam property that is nullable. I recommend something, that defaults to some human-visible value, like int (0) or datetime (current time or 0000-... date)
  • Generated OpenAPI definition and Swagger UI.
    • 5.15.0 -> the input box for query parameter is empty
    • 5.16.0 -> the input box is prefilled with default value of datatype
@dj-nitehawk
Copy link
Member

changelog mentions how to turn it off:

This behavior can be turned off like so:
```cs
builder.Services.SwaggerDocument(o =>
{
o.DocumentSettings = s =>
{
s.GenerateExamples = false;
};
});
```

let me know if that sorts it out. if not i'll look in to it further.

thanks!

@Seramis
Copy link
Author

Seramis commented Sep 2, 2023

@dj-nitehawk Thanks! It did, thank you!
Maybe having it turned on by default causes too much confusion, as the engineer puts the questionmark on a property deliberately to make it nullable and then confusingly sees some values in SwaggerUI?

Thanks again! I can now continue to use the latest version. It's a great library!

@dj-nitehawk dj-nitehawk added bug Something isn't working fixed the bug has been squashed labels Sep 2, 2023
@dj-nitehawk
Copy link
Member

this is now fixed in 5.16.0.3-beta

you can get rid of:

     o.DocumentSettings = s => 
     { 
         s.GenerateExamples = false; 
     };

see changelog.

thanks for reporting the issue 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed the bug has been squashed
Development

No branches or pull requests

2 participants