Closed tsinis closed 1 year ago
Hey @Carapacik and thanks for a great package!
In this super small patch PR, I'm trying to fix duplicate field names in integer-based enums (provided by Open-API definition JSON). For example, if we have a model defined like this:
"Foo": { "enum": [ -1, 0, 1, 2 ], "type": "number" },
The package will code generate a model like this:
@JsonEnum() enum Foo { @JsonValue(-1) value1, // <--- Error, duplicated field. @JsonValue(0) value0, @JsonValue(1) value1, // <--- Error, duplicated field. @JsonValue(2) value2; num toJson() => _$FooEnumMap[this]!; }
And in this PR package will generate a proper model like this:
@JsonEnum() enum Foo { @JsonValue(-1) valueMinus1, // <--- Yey! No errors here. @JsonValue(0) value0, @JsonValue(1) value1, // <--- And no errors here. @JsonValue(2) value2; num toJson() => _$FooEnumMap[this]!; }
Because of modifications in the code generation part on the Dart side that will remove "-" from the value name. Thanks one more time!
LGTM
Hey @Carapacik and thanks for a great package!
In this super small patch PR, I'm trying to fix duplicate field names in integer-based enums (provided by Open-API definition JSON). For example, if we have a model defined like this:
The package will code generate a model like this:
And in this PR package will generate a proper model like this:
Because of modifications in the code generation part on the Dart side that will remove "-" from the value name. Thanks one more time!