Skip to content

Commit f30606c

Browse files
authored
fix: don't export aliases if name is ApiClient (#319)
we don't need the aliased exports (retained for backwards compatibility) if the main exports have the same name.
1 parent 20b2454 commit f30606c

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

packages/openapi-code-generator/src/typescript/client/abstract-client-builder.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ export abstract class AbstractClientBuilder implements ICompilable {
5151
this.operations.push(result)
5252
}
5353

54+
protected legacyExports(clientName: string, isConfigAClass = false) {
55+
if (clientName === "ApiClient") {
56+
return ""
57+
}
58+
59+
return `
60+
export { ${clientName} as ApiClient }
61+
export ${isConfigAClass ? "" : "type"} { ${clientName}Config as ApiClientConfig }
62+
`
63+
}
64+
5465
protected abstract buildImports(imports: ImportBuilder): void
5566

5667
protected abstract buildOperation(builder: ClientOperationBuilder): string

packages/openapi-code-generator/src/typescript/client/typescript-angular/angular-service-builder.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ export class ${clientName} {
166166
${clientMethods.join("\n")}
167167
}
168168
169-
export { ${clientName} as ApiClient }
170-
export { ${clientName}Config as ApiClientConfig }
169+
${this.legacyExports(clientName, true)}
171170
`
172171
}
173172
}

packages/openapi-code-generator/src/typescript/client/typescript-axios/typescript-axios-client-builder.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ export class ${clientName} extends AbstractAxiosClient {
131131
${clientMethods.join("\n")}
132132
}
133133
134-
export { ${clientName} as ApiClient }
135-
export type { ${clientName}Config as ApiClientConfig }
134+
${this.legacyExports(clientName)}
136135
`
137136
}
138137
}

packages/openapi-code-generator/src/typescript/client/typescript-fetch/typescript-fetch-client-builder.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ export class ${clientName} extends AbstractFetchClient {
135135
${clientMethods.join("\n")}
136136
}
137137
138-
export { ${clientName} as ApiClient }
139-
export type { ${clientName}Config as ApiClientConfig }
138+
${this.legacyExports(clientName)}
140139
`
141140
}
142141
}

0 commit comments

Comments
 (0)