Skip to content

Commit

Permalink
Use toJson() instead of .name if @Path enums have toJson() (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
sooxt98 authored Nov 10, 2023
1 parent 5877f30 commit 333dff8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion generator/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class RetrofitGenerator extends GeneratorForAnnotation<retrofit.RestApi> {
final value = v.peek(_valueVar)?.stringValue ?? k.displayName;
definePath = definePath?.replaceFirst(
'{$value}',
"\${${k.displayName}${k.type.element?.kind == ElementKind.ENUM ? '.name' : ''}}",
"\${${k.displayName}${k.type.element?.kind == ElementKind.ENUM ? _hasToJson(k.type) ? '.toJson()' : '.name' : ''}}",
);
});
return literal(definePath);
Expand Down

0 comments on commit 333dff8

Please sign in to comment.