Open SSCodeChamp opened 6 years ago
This isn't something we could do by default - the purpose of enum
is to express "only these values can be used".
I'd be open to a vendor extension for this though, maybe something like x-allow-custom-values
.
Thanks Shockey. That would be great if you could add that to the vendor extension.
A question about enum, the swagger-maven-plugin generates an empty enum
{
"openapi" : "3.0.1",
"info" : {
"title" : "My Rest API",
"description" : "My RESTful API implementation",
"version" : "1.0.0"
},
"servers" : [ {
"url" : "/{context-path}/{rest-api}",
"description" : "My REST API",
"variables" : {
"context-path" : {
"default" : "my-war"
"enum" : [ "" ]
},
"rest-api" : {
"default" : "api",
"enum" : [ "api", "rest", "batchapi" ]
}
}
} ],
...
}
The empty enum is rendered as an empty dropdown, is it correct? If I remove the empty enum I have an input field with the default value.
Here the full issue description I have open into swagger code.
Swagger core version 2.0.6 and I have tested against the deployed version of swagger-ui as well.
Thanks in advance 😉
@blackat, this is intentional - if you have an enum
you should include your default value in it. Swagger Core should generate enums accordingly, so this is a bug on their side.
Hi,
The enum parameter is a great feature. I have a requirement where user can select from enum or he can enter the value he want. This is useful when the value is not available in the enum set.