diff --git a/index.d.ts b/index.d.ts index ace3de117..d8a4a4757 100644 --- a/index.d.ts +++ b/index.d.ts @@ -343,6 +343,7 @@ export interface GenerateApiConfiguration { routeName: string; }; routeNameDuplicatesMap: Map; + apiClassName: string }; modelTypes: ModelType[]; rawModelTypes: SchemaComponent[]; diff --git a/index.js b/index.js index 3b5412341..9ff650a0f 100755 --- a/index.js +++ b/index.js @@ -106,6 +106,7 @@ generateApi({ typePrefix: program.typePrefix, typeSuffix: program.typeSuffix, patch: !!program.patch, + apiClassName, }).catch((err) => { // NOTE collect all errors on top level and shows to users in any case console.error(err); diff --git a/src/config.js b/src/config.js index 26d92a5f8..005b7ea79 100644 --- a/src/config.js +++ b/src/config.js @@ -91,6 +91,8 @@ const config = { typeSuffix: "", patch: false, componentTypeNameResolver: new NameResolver([]), + /** name of the main exported class */ + apiClassName: "Api", }; /** needs to use data everywhere in project */ diff --git a/src/index.js b/src/index.js index 99c75a3ff..dc946e546 100644 --- a/src/index.js +++ b/src/index.js @@ -64,6 +64,7 @@ module.exports = { typeSuffix = config.typeSuffix, patch = config.patch, authorizationToken, + apiClassName = config.apiClassName, }) => new Promise((resolve, reject) => { addToConfig({ @@ -99,6 +100,7 @@ module.exports = { typePrefix, typeSuffix, patch, + apiClassName, }); (spec ? convertSwaggerObject(spec, { patch }) 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;