Skip to content
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

Support enum constants for numeric values, and support x-enumNames extension #235

Closed
EilevHagen opened this issue Mar 31, 2020 · 4 comments

Comments

@EilevHagen
Copy link

EilevHagen commented Mar 31, 2020

ng-swagger-gen version 2.2.0

I have set "enumModule": true

This is my enum definition:

"MetadataVersionStatusType": { "type": "integer", "description": "", "x-enumNames": [ "Draft", "Published" ], "enum": [ 0, 1 ] }

This only produces

/* tslint:disable */
export type MetadataVersionStatusType = 0 | 1;

How am I supposed to get the string constants generated ("Draft" and "Published")?

@EilevHagen EilevHagen changed the title Does not generate constants from Does not generate constants from enum Mar 31, 2020
@luisfpg
Copy link
Collaborator

luisfpg commented Mar 31, 2020

ng-swagger-gen only supports the enumModule for string enums, not numeric enums.
Also, the x-enumNames extension isn't supported.
All of these are supported in https://github.com/cyclosproject/ng-openapi-gen.
If you can switch the descriptor to OpenAPI 3 instead of Swagger 2, you can switch to the newer project.
Otherwise, this will only be implemented if a PR is submitted, because ng-swagger-gen no longer receives new features, except for community contributions.

@luisfpg luisfpg changed the title Does not generate constants from enum Support enum constants for numeric values, and support x-enumNames extension Mar 31, 2020
@EilevHagen
Copy link
Author

Thank you! :)

@luisfpg
Copy link
Collaborator

luisfpg commented Mar 31, 2020

I'll reopen this just in case someone wants to contribute a PR.

@luisfpg
Copy link
Collaborator

luisfpg commented Nov 18, 2020

See #254

@luisfpg luisfpg closed this as completed Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants