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
Allow reusable enumerations in parameters/models #1250
Comments
This is really a swagger-code-gen issue I believe. AFAIK this is not supported in swagger 2.0 |
This should be possible with Swagger 2.0 using a reference to a List of type string with the enum values listed, pls see the example at Codegen only picks up the Enums as defined, if the Enum is referenced it should generate the Enum as a separate enum class. |
This is a duplicate of #1738, but neither of these issues are an issue with swagger-codegen. Springfox should be writing top-level enums to the definitions section of the generated spec and referencing them using |
Hi is there any updates (after 3 years?) This is very useful! |
Version: 2.4.0
For enumerations:
the API-docs are currently rendered as a enum to the parameter/attribute:
When generating client code using Swagger-codegen (Java), the Enumeration is generated as inner class:
If you have multiple variables of type MyEnum in different classes, this leads to the fact, that the enumeration is contained as inner classes in every class where it is used (and who don't know each other/have no common parent or reference).
It would be much better to have a reference to the enumeration, so the client code can generate a separate class for the Enumeration (same as done in the API model classes).
According to the OpenAPI-spec, this should be possible using a reference to a Set/List of type String and the enumeration of the possible values:
OAI/OpenAPI-Specification#300
I think this would be the more clean way of rendering the enumerations.
The text was updated successfully, but these errors were encountered: