From 64c7e23a04d68db9ad27f11295141d8df4b413b9 Mon Sep 17 00:00:00 2001 From: Granjow Date: Sat, 1 Apr 2017 10:33:29 +0200 Subject: [PATCH] TypeScript client API: Add public getter/setter for base path (#5270) --- .../resources/typescript-node/api.mustache | 10 +++++- .../petstore/typescript-node/default/api.ts | 34 ++++++++++++++++--- .../petstore/typescript-node/npm/api.ts | 34 ++++++++++++++++--- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache index 0a9d023c31a..adfdfd035a3 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache @@ -116,7 +116,7 @@ export enum {{classname}}ApiKeys { } export class {{classname}} { - protected basePath = defaultBasePath; + protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; @@ -163,6 +163,14 @@ export class {{classname}} { this._useQuerystring = value; } + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + public setApiKey(key: {{classname}}ApiKeys, value: string) { this.authentications[{{classname}}ApiKeys[key]].apiKey = value; } diff --git a/samples/client/petstore/typescript-node/default/api.ts b/samples/client/petstore/typescript-node/default/api.ts index edfe1a4fef3..274b84d927d 100644 --- a/samples/client/petstore/typescript-node/default/api.ts +++ b/samples/client/petstore/typescript-node/default/api.ts @@ -140,7 +140,7 @@ export enum PetApiApiKeys { } export class PetApi { - protected basePath = defaultBasePath; + protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; @@ -167,6 +167,14 @@ export class PetApi { this._useQuerystring = value; } + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + public setApiKey(key: PetApiApiKeys, value: string) { this.authentications[PetApiApiKeys[key]].apiKey = value; } @@ -413,10 +421,10 @@ export class PetApi { json: true, }; - this.authentications.petstore_auth.applyToRequest(requestOptions); - this.authentications.api_key.applyToRequest(requestOptions); + this.authentications.petstore_auth.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); if (Object.keys(formParams).length) { @@ -624,7 +632,7 @@ export enum StoreApiApiKeys { } export class StoreApi { - protected basePath = defaultBasePath; + protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; @@ -651,6 +659,14 @@ export class StoreApi { this._useQuerystring = value; } + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + public setApiKey(key: StoreApiApiKeys, value: string) { this.authentications[StoreApiApiKeys[key]].apiKey = value; } @@ -862,7 +878,7 @@ export enum UserApiApiKeys { } export class UserApi { - protected basePath = defaultBasePath; + protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; @@ -889,6 +905,14 @@ export class UserApi { this._useQuerystring = value; } + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + public setApiKey(key: UserApiApiKeys, value: string) { this.authentications[UserApiApiKeys[key]].apiKey = value; } diff --git a/samples/client/petstore/typescript-node/npm/api.ts b/samples/client/petstore/typescript-node/npm/api.ts index edfe1a4fef3..274b84d927d 100644 --- a/samples/client/petstore/typescript-node/npm/api.ts +++ b/samples/client/petstore/typescript-node/npm/api.ts @@ -140,7 +140,7 @@ export enum PetApiApiKeys { } export class PetApi { - protected basePath = defaultBasePath; + protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; @@ -167,6 +167,14 @@ export class PetApi { this._useQuerystring = value; } + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + public setApiKey(key: PetApiApiKeys, value: string) { this.authentications[PetApiApiKeys[key]].apiKey = value; } @@ -413,10 +421,10 @@ export class PetApi { json: true, }; - this.authentications.petstore_auth.applyToRequest(requestOptions); - this.authentications.api_key.applyToRequest(requestOptions); + this.authentications.petstore_auth.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); if (Object.keys(formParams).length) { @@ -624,7 +632,7 @@ export enum StoreApiApiKeys { } export class StoreApi { - protected basePath = defaultBasePath; + protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; @@ -651,6 +659,14 @@ export class StoreApi { this._useQuerystring = value; } + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + public setApiKey(key: StoreApiApiKeys, value: string) { this.authentications[StoreApiApiKeys[key]].apiKey = value; } @@ -862,7 +878,7 @@ export enum UserApiApiKeys { } export class UserApi { - protected basePath = defaultBasePath; + protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; @@ -889,6 +905,14 @@ export class UserApi { this._useQuerystring = value; } + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + public setApiKey(key: UserApiApiKeys, value: string) { this.authentications[UserApiApiKeys[key]].apiKey = value; }