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);