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
88 stars 33 forks source link

`index` in Enum is invalid #164

Closed dickermoshe closed 5 months ago

dickermoshe commented 5 months ago

This should be documented or auto renamed I would propose that replacement_rules should affect Enum names too

Class 'O' can't define static member 'index' and have instance member 'O.index' with the same name.
Try renaming the member to a name that doesn't conflict.dart(conflicting_static_and_instance)
@JsonEnum()
enum O {
  @JsonValue('-index')
  index('-index'),

  @JsonValue('-name')
  name('-name'),

  /// Default value for all unparsed values, allows backward compatibility when adding new values on the backend.
  $unknown(null);

  const O(this.json);

  factory O.fromJson(String json) => values.firstWhere(
        (e) => e.json == json,
        orElse: () => $unknown,
      );

  final String? json;
}