From 333dff82ff84c5cfeed8de79f248d7ee442e8ada Mon Sep 17 00:00:00 2001 From: sooxt98 Date: Fri, 10 Nov 2023 15:55:58 +0800 Subject: [PATCH] Use `toJson()` instead of .name if `@Path` enums have `toJson()` (#637) --- generator/lib/src/generator.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/lib/src/generator.dart b/generator/lib/src/generator.dart index e4c2ba94e..2f1183e47 100644 --- a/generator/lib/src/generator.dart +++ b/generator/lib/src/generator.dart @@ -406,7 +406,7 @@ class RetrofitGenerator extends GeneratorForAnnotation { 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);