Skip to content

Commit

Permalink
fix: fixed duplicated enum names (wosherco/trpc-client-dart#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
polvallverdu committed Jan 10, 2025
1 parent c43b85d commit 677fe5e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/quicktype-core/src/language/Dart/DartRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ export class DartRenderer extends ConvenienceRenderer {
nestedTypeName = `List<${this.getNestedTypeName(this.resolveTypeName(prop.type.items))}>`;
} else if (prop.type instanceof MapType && prop.type.values instanceof ObjectType) {
nestedTypeName = `Map<String, ${this.getNestedTypeName(this.resolveTypeName(prop.type.values))}>`;
} else if (prop.type instanceof EnumType) {
nestedTypeName = this.getNestedTypeName(this.nameForNamedType(prop.type));
} else {
nestedTypeName = this.dartType(prop.type);
}
Expand All @@ -748,7 +750,7 @@ export class DartRenderer extends ConvenienceRenderer {

protected emitEnumDefinition(e: EnumType, enumName: Name): void {
this.emitDescription(this.descriptionForType(e));
this.emitLine("enum ", enumName, " {");
this.emitLine("enum ", this.getNestedTypeName(enumName), " {");
this.indent(() => {
this.forEachEnumCase(e, "none", (name, jsonName, pos) => {
const comma = pos === "first" || pos === "middle" ? "," : [];
Expand Down

0 comments on commit 677fe5e

Please sign in to comment.