Carapacik / swagger_parser

Dart package that takes an OpenApi definition file and generates REST clients based on retrofit and data classes for your project.
https://pub.dev/packages/swagger_parser
MIT License
90 stars 38 forks source link

Support String values with spaces for enums #127

Closed RyanRamchandar closed 10 months ago

RyanRamchandar commented 10 months ago

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.

RyanRamchandar commented 10 months ago

Thanks!