Closed aj-scram closed 4 months ago
i believe it's being done as a workaround for #699
if we revert the workaround, then a nullable enum property is going to look like this in swagger ui:
any ideas what exact swagger spec is needed for swagger ui to render a dropdown as well as honor default values for a nullable enum property?
I believe the correction here is to add to allOf instead
I already have an operation processor to do so for MVC controller enums (middle of refactoring towards FE) based on this comment/issue:
https://github.com/RicoSuter/NSwag/issues/3645#issuecomment-1457994616
That was to fix enums not generating as dropdowns as well, but I find using allOf continues to allow defaults to work as expected
There’s also an open issue where someone is asking for it to be configurable between the two
https://github.com/RicoSuter/NJsonSchema/issues/1509#issue-1181080784
NOTE: this won’t fix defaults for array enum parameters, but I’m also not sure how to fix that currently
thanks! that helped...
check out v5.26.0.26-beta
which should be available on nuget soon.
i believe it's working as expected now.
Much appreciated; if figure out how to get the array defaults (with/ multi selection) working as expected, I’ll report back
Is there any interest in the configurable feature request? Could see about opening a PR for it in the future, if/when I find time
so in the operation processor, you're assigning the ref directly to the param object via Schema; this causes invalid swagger which makes the default value not populate
https://github.com/FastEndpoints/FastEndpoints/blob/60efcbdbf7268af398c407b9d638e885807feffa/Src/Swagger/OperationProcessor.cs#L652
see generated swagger from NSwag below
Fix is that the $ref needs to be moved to oneOf or allOf collection for the param