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 String values with spaces for enums #127

Closed
RyanRamchandar opened this issue Oct 25, 2023 · 1 comment · Fixed by #126
Closed

Support String values with spaces for enums #127

RyanRamchandar opened this issue Oct 25, 2023 · 1 comment · Fixed by #126
Labels
bug Something isn't working

Comments

@RyanRamchandar
Copy link

RyanRamchandar commented Oct 25, 2023

Given the swagger:

"SessionTypes": {
  "type": "string",
  "enum": [
    "Crystal Calibration",
  ]
},

The following is generated:

import 'package:freezed_annotation/freezed_annotation.dart';

@JsonEnum()
enum SessionTypes {
  /// Incorrect name has been replaced. Original name: `Crystal Calibration`.
  @JsonValue('Crystal Calibration')
  undefined0,
}

I would expect:

import 'package:freezed_annotation/freezed_annotation.dart';

@JsonEnum()
enum SessionTypes {
  @JsonValue('Crystal Calibration')
  crystalCalibration,
}

In Dart, I would suggest converting strings to camelCase variable names and strip away any spaces.

@Carapacik Carapacik added the bug Something isn't working label Oct 25, 2023
StarProxima added a commit to StarProxima/swagger_parser that referenced this issue Oct 25, 2023
@Carapacik Carapacik linked a pull request Oct 26, 2023 that will close this issue
@RyanRamchandar
Copy link
Author

Thanks!

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.

2 participants