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

[BUG] Duplicate enum key when generating enum values with sign #264

Closed
jtzell opened this issue Oct 15, 2021 · 1 comment · Fixed by #281
Closed

[BUG] Duplicate enum key when generating enum values with sign #264

jtzell opened this issue Oct 15, 2021 · 1 comment · Fixed by #281
Assignees
Labels
bug Something isn't working

Comments

@jtzell
Copy link

jtzell commented Oct 15, 2021

Describe the bug
When the enum values different from each other by only sign characters (the "+" or "-"), the generator build code with duplicate enum definition.

To Reproduce
1./ Swagger file with following enum fields:

...
"tz": {"type": "string", "enum": [Etc/GMT", "Etc/GMT+0", "Etc/GMT+1", "Etc/GMT+10", "Etc/GMT+11", "Etc/GMT+12", "Etc/GMT+2", "Etc/GMT+3", "Etc/GMT+4", "Etc/GMT+5", "Etc/GMT+6", "Etc/GMT+7", "Etc/GMT+8", "Etc/GMT+9", "Etc/GMT-0", "Etc/GMT-1", "Etc/GMT-10", "Etc/GMT-11", "Etc/GMT-12", "Etc/GMT-13", "Etc/GMT-14", "Etc/GMT-2", "Etc/GMT-3", "Etc/GMT-4", "Etc/GMT-5", "Etc/GMT-6", "Etc/GMT-7", "Etc/GMT-8", "Etc/GMT-9", "Etc/GMT0"]}
...

2./ Running build will generated ".enums.swagger" with duplicate definition as follow:

...
@JsonValue('Etc/GMT-0')
etcGmt0,
@JsonValue('Etc/GMT-1')
etcGmt1,
@JsonValue('Etc/GMT-10')
etcGmt10,
@JsonValue('Etc/GMT-11')
etcGmt11,
@JsonValue('Etc/GMT-12')
etcGmt12,
...
@JsonValue('Etc/GMT-2')
etcGmt2,
@JsonValue('Etc/GMT-3')
etcGmt3,
@JsonValue('Etc/GMT-4')
etcGmt4,
@JsonValue('Etc/GMT-5')
etcGmt5,
@JsonValue('Etc/GMT-6')
etcGmt6,
@JsonValue('Etc/GMT-7')
etcGmt7,
@JsonValue('Etc/GMT-8')
etcGmt8,
@JsonValue('Etc/GMT-9')
etcGmt9,
@JsonValue('Etc/GMT0')
etcGmt0,
...
@JsonValue('Etc/GMT-0')
etcGmt0,
@JsonValue('Etc/GMT-1')
etcGmt1,
@JsonValue('Etc/GMT-10')
etcGmt10,
@JsonValue('Etc/GMT-11')
etcGmt11,
@JsonValue('Etc/GMT-12')
etcGmt12,
...
@JsonValue('Etc/GMT-2')
etcGmt2,
@JsonValue('Etc/GMT-3')
etcGmt3,
@JsonValue('Etc/GMT-4')
etcGmt4,
@JsonValue('Etc/GMT-5')
etcGmt5,
@JsonValue('Etc/GMT-6')
etcGmt6,
@JsonValue('Etc/GMT-7')
etcGmt7,
@JsonValue('Etc/GMT-8')
etcGmt8,
@JsonValue('Etc/GMT-9')
etcGmt9,
@JsonValue('Etc/GMT0')
etcGmt0,

Expected behavior
The generator should taking into account the sign characters when building enum definitions.
For example,

"tz": {"type": "string", "enum": [Etc/GMT0", "Etc/GMT+0","Etc/GMT-0"}
should output:
@JsonValue('Etc/GMT0')
etcGmt0,
@JsonValue('Etc/GMT-0')
etcGmtMinus0,
@JsonValue('Etc/GMT+0')
etcGmtPlus0,

Library version used:
2.2.1

Additional context
Add any other context about the problem here.

@jtzell jtzell added bug Something isn't working Triage needed labels Oct 15, 2021
@Vovanella95
Copy link
Collaborator

Hi @jtzell , I will take a look to this. Thanks for raising issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants