Reputation: 738
I would like to generate a swagger-json containing an enum. My problem is the way the enum gets rendered:
"MyEnumType": {
"typeName": "MyEnumType",
"type": "string",
"enum": [
"first",
"second",
"third"
]
}
What I really want is the name of the possible values (first, second, third) as well as the value behind that enum-values (0, 1, 2). Is it even possible to generate such a json (which is "swagger-valid") and if so, how?
Upvotes: 9
Views: 11561
Reputation: 738
I use NSwag and in the meantime Rico Suter from NSwag made the feature available. Big props to him!
Upvotes: 3
Reputation: 5331
The current version of the OpenAPI (fka. Swagger) do not propose this. It will probably be added in next version (cf. https://github.com/OAI/OpenAPI-Specification/issues/348)
In the meanwhile having the same issue I ended giving these informations in the property's description.
Upvotes: 2