Default values for enum are not written #3855
Closed
WolfgangHG
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
|
It doesn't say which version of OpenAPI you're using in your application, but this is a constraint of OpenAPI 3.0 documents. When a From me double-checking this locally, the The default version generated by Swashbuckle.AspNetCore is 3.0. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have this snippet in a model class (I tried both
DefaultValuewith enum and with string - of course I would prefer the first version):The OpenAPI file generated by Swashbuckle does not define the default value:
I would like to see a default value for the enum values. But default values for "$ref" properties seem to be difficult to handle, as no further properties are allowed when "$ref" is used.
According to the sample at https://www.github.com/OpenAPITools/openapi-generator/issues/14689, the schema could look like this:
I found this stackoverflow post which suggests an easier syntax. But I did not find any hint that this is allowed in the 3.1.1 spec
The sample model class can be found in https://github.com/WolfgangHG/Swashbuckle_Discussion3709/ (used for a previous discussion) - start the project using the launch profile "WebApiSwaggerVersion".
Beta Was this translation helpful? Give feedback.
All reactions