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] int enum generates "anonymous" labels #307

Closed
fncap opened this issue Jan 12, 2022 · 2 comments · Fixed by #338
Closed

[BUG] int enum generates "anonymous" labels #307

fncap opened this issue Jan 12, 2022 · 2 comments · Fixed by #338
Assignees
Labels
bug Something isn't working

Comments

@fncap
Copy link

fncap commented Jan 12, 2022

Take a look on the following spec

"TenantAvailabilityState": {
  "enum": [
    1,
    2,
    3
  ],
  "type": "integer",
  "format": "int32",
  "x-enumNames": [
    "Available",
    "InActive",
    "NotFound"
  ]
},

this produce following Dart

enum TenantAvailabilityState {
  @JsonValue('swaggerGeneratedUnknown')
  swaggerGeneratedUnknown,
  @JsonValue(1)
  value_1,
  @JsonValue(2)
  value_2,
  @JsonValue(3)
  value_3
}

const $TenantAvailabilityStateMap = {
  TenantAvailabilityState.value_1: '1',
  TenantAvailabilityState.value_2: '2',
  TenantAvailabilityState.value_3: '3'
};

What I'm expecting is an enum generated with same labels that are listed in x-enumNames spec's field, instead of value_1, value_2 and value_3!

Isn't it?

@fncap fncap added bug Something isn't working Triage needed labels Jan 12, 2022
@Vovanella95
Copy link
Collaborator

Hi @fncap , thanks for raising issue. Actually, it's not a bug and looks like cool feature. I will try to take a look on it

@fryette
Copy link
Contributor

fryette commented Jan 13, 2022

Link with all possibilities of annotation enums:
https://stackoverflow.com/questions/66465888/how-to-define-enum-mapping-in-openapi

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