[dart][dart-dio] Enum improvements#8149
Conversation
|
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
Can you please elaborate on that? Sounds like a bug if it's always true independent of whether it's an enum or not. |
|
Could you also elaborate more on |
|
I have not found a model that get's passed into any of the {{#models}}
{{#model}}
{{#isEnum}}
{{>enum}}
{{/isEnum}}
{{^isEnum}}
{{>class}}
{{/isEnum}}
{{/model}}
{{/models}}Inside the enum template the value will always be a /// The underlying value of this enum member.
{{#isEnum}}
final String value;
{{/isEnum}}
{{^isEnum}}
final {{{dataType}}} value;
{{/isEnum}}After removing this check, the correct enum value type is generated: https://github.com/OpenAPITools/openapi-generator/pull/8149/files#diff-4671c37577153f83b40b0ad23a216cc1c6e1bbd2bbe7c074733af003c266f8b3L18 |
* use raw strings for enum string values
`@BuiltValueEnumConst` does some wierd string handling in the generated code `r'\$'` becomes `'$'`. This is different compared to the wireName in `@BuiltValueField`
8b9528c to
0e2588c
Compare
| static const InlineObject2EnumFormStringArray greaterThan = _$inlineObject2EnumFormStringArray_greaterThan; | ||
| /// Form parameter enum test (string array) | ||
| @BuiltValueEnumConst(wireName: '$') | ||
| @BuiltValueEnumConst(wireName: r'\$') |
There was a problem hiding this comment.
Found a mismatch between dart-dio and dart. a few files below you will find:
static const dollar = EnumArraysJustSymbolEnum._(r'$');
You can see the $ isn't escaped with \ but it is here, both are raw strings. I suspect this is breaking compatibility between them?
There was a problem hiding this comment.
See the comment here, this is specific to built_values Dart generator: https://github.com/OpenAPITools/openapi-generator/pull/8149/files#diff-f325b1ca8b03ba6f1ee25144eec1079de2cc2d853d6237eac40f157663bda2acR120
There was a problem hiding this comment.
ah thanks for that, missed comment. Well, it's fine then I expressed my opinion on use of built_value in another PR.
| bool operator ==(Object other) => identical(this, other) || | ||
| other is InlineObject2EnumFormStringArrayEnum && other.value == value || | ||
| other is String && other == value; | ||
| other is InlineObject2EnumFormStringArrayEnum && other.value == value; |
There was a problem hiding this comment.
other.value == value
this is comparing references not contents of lists, so it's not what I would expect from == on enum. What are your expectations?
There was a problem hiding this comment.
Not a request for change , just asking.
There was a problem hiding this comment.
Yes this is a list but is actually completely wrong. This needs to be fixed in some other PR. An enum with a list as value is not valid. And the inline objects are gonna be removed soon.
I know what causes this but it will get too big.
|
Please change title to include dart-dio |
PR checklist
./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.masterCC @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12)
FYI @agilob
@noordawod I reverted some of your changes to the enum templates. As far as I can tell
isEnumis always true in enum templates.