From 849309bbd80e037df9616345b15d84aa933f613e Mon Sep 17 00:00:00 2001 From: bonukai <17750886+bonukai@users.noreply.github.com> Date: Thu, 25 Nov 2021 20:34:18 +0000 Subject: [PATCH 1/5] Update api.eta --- templates/default/api.eta | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/default/api.eta b/templates/default/api.eta index 430e6a262..3f33d5d29 100644 --- a/templates/default/api.eta +++ b/templates/default/api.eta @@ -36,7 +36,7 @@ const descriptionLines = _.compact([ <% }) %> */ <% } %> -export class Api<% if (!config.singleHttpClient) { %> extends HttpClient <% } %> { +export class <%~ config.apiClassName %><% if (!config.singleHttpClient) { %> extends HttpClient <% } %> { <% if(config.singleHttpClient) { %> http: HttpClient; From fde3883097ac54d26874754c6b5d4cabbddc10ec Mon Sep 17 00:00:00 2001 From: bonukai <17750886+bonukai@users.noreply.github.com> Date: Thu, 25 Nov 2021 20:35:01 +0000 Subject: [PATCH 2/5] Update index.d.ts --- index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/index.d.ts b/index.d.ts index 4673b93c8..5ee4121b1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -323,6 +323,7 @@ export interface GenerateApiConfiguration { routeName: string; }; routeNameDuplicatesMap: Map; + apiClassName: string }; modelTypes: ModelType[]; rawModelTypes: SchemaComponent[]; From 806a5d8d7e53ec1df22a87b41696000c2bca807b Mon Sep 17 00:00:00 2001 From: bonukai <17750886+bonukai@users.noreply.github.com> Date: Thu, 25 Nov 2021 20:36:45 +0000 Subject: [PATCH 3/5] Update index.js --- src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index 6ccbdd3ab..78a574d54 100644 --- a/src/index.js +++ b/src/index.js @@ -56,6 +56,7 @@ module.exports = { silent = config.silent, typePrefix = config.typePrefix, typeSuffix = config.typeSuffix, + apiClassName = config.apiClassName, }) => new Promise((resolve, reject) => { addToConfig({ @@ -85,6 +86,7 @@ module.exports = { toJS: translateToJavaScript, typePrefix, typeSuffix, + apiClassName, }); (spec ? convertSwaggerObject(spec) From 837f5511e446216fe1d132bee3a2b15b713cf080 Mon Sep 17 00:00:00 2001 From: bonukai <17750886+bonukai@users.noreply.github.com> Date: Thu, 25 Nov 2021 20:39:06 +0000 Subject: [PATCH 4/5] Update index.js --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index a42b61a50..9797209e7 100755 --- a/index.js +++ b/index.js @@ -72,6 +72,7 @@ program .option("--default-response ", "default type for empty response schema", TS_KEYWORDS.VOID) .option("--type-prefix ", "data contract name prefix", "") .option("--type-suffix ", "data contract name suffix", "") + .option("--api-class-name ", "name of the main exported class", "Api") .option( "--clean-output", "clean output folder before generate api. WARNING: May cause data loss", @@ -107,6 +108,7 @@ const { silent, typePrefix, typeSuffix, + apiClassName, } = program; generateApi({ @@ -137,4 +139,5 @@ generateApi({ silent: !!silent, typePrefix, typeSuffix, + apiClassName, }); From 26bc93200a6ef1df18e32f047203f89bec597011 Mon Sep 17 00:00:00 2001 From: bonukai <17750886+bonukai@users.noreply.github.com> Date: Thu, 25 Nov 2021 20:39:24 +0000 Subject: [PATCH 5/5] Update config.js --- src/config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/config.js b/src/config.js index b9f3d63a5..f258188b5 100644 --- a/src/config.js +++ b/src/config.js @@ -84,6 +84,8 @@ const config = { typePrefix: "", typeSuffix: "", componentTypeNameResolver: new NameResolver([]), + /** name of the main exported class */ + apiClassName: "Api", }; /** needs to use data everywhere in project */