From 91f470e41f5cbad7bdc10f8c83c4d89521330a5f Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 27 Jun 2017 09:23:40 -0700 Subject: [PATCH] Add a function for injecting your own Authentication into the Typescript-node client (#5865) --- .../src/main/resources/typescript-node/api.mustache | 4 ++++ .../petstore-security-test/typescript-node/api.ts | 4 ++++ .../client/petstore/typescript-node/default/api.ts | 12 ++++++++++++ samples/client/petstore/typescript-node/npm/api.ts | 12 ++++++++++++ 4 files changed, 32 insertions(+) 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 adfdfd035a..735b35f432 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache @@ -171,6 +171,10 @@ export class {{classname}} { return this._basePath; } + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + public setApiKey(key: {{classname}}ApiKeys, value: string) { this.authentications[{{classname}}ApiKeys[key]].apiKey = value; } diff --git a/samples/client/petstore-security-test/typescript-node/api.ts b/samples/client/petstore-security-test/typescript-node/api.ts index f946919ecd..cf25c9dd06 100644 --- a/samples/client/petstore-security-test/typescript-node/api.ts +++ b/samples/client/petstore-security-test/typescript-node/api.ts @@ -123,6 +123,10 @@ export class FakeApi { return this._basePath; } + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + public setApiKey(key: FakeApiApiKeys, value: string) { this.authentications[FakeApiApiKeys[key]].apiKey = value; } diff --git a/samples/client/petstore/typescript-node/default/api.ts b/samples/client/petstore/typescript-node/default/api.ts index 274b84d927..11e3a970e4 100644 --- a/samples/client/petstore/typescript-node/default/api.ts +++ b/samples/client/petstore/typescript-node/default/api.ts @@ -175,6 +175,10 @@ export class PetApi { return this._basePath; } + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + public setApiKey(key: PetApiApiKeys, value: string) { this.authentications[PetApiApiKeys[key]].apiKey = value; } @@ -667,6 +671,10 @@ export class StoreApi { return this._basePath; } + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + public setApiKey(key: StoreApiApiKeys, value: string) { this.authentications[StoreApiApiKeys[key]].apiKey = value; } @@ -913,6 +921,10 @@ export class UserApi { return this._basePath; } + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + 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 274b84d927..11e3a970e4 100644 --- a/samples/client/petstore/typescript-node/npm/api.ts +++ b/samples/client/petstore/typescript-node/npm/api.ts @@ -175,6 +175,10 @@ export class PetApi { return this._basePath; } + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + public setApiKey(key: PetApiApiKeys, value: string) { this.authentications[PetApiApiKeys[key]].apiKey = value; } @@ -667,6 +671,10 @@ export class StoreApi { return this._basePath; } + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + public setApiKey(key: StoreApiApiKeys, value: string) { this.authentications[StoreApiApiKeys[key]].apiKey = value; } @@ -913,6 +921,10 @@ export class UserApi { return this._basePath; } + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + public setApiKey(key: UserApiApiKeys, value: string) { this.authentications[UserApiApiKeys[key]].apiKey = value; }