Generate enum from api key auth methods. Use this to set api key of authentication. Update test client to set multiple keys.

This commit is contained in:
Alexander Fisher
2016-04-07 10:19:16 -04:00
parent 155458012e
commit b5dabee20a
3 changed files with 96 additions and 99 deletions

View File

@@ -96,12 +96,18 @@ class VoidAuth implements Authentication {
* {{&description}}
*/
{{/description}}
export enum {{classname}}ApiKeys {
{{#authMethods}}
{{#isApiKey}}
{{name}},
{{/isApiKey}}
{{/authMethods}}
}
export class {{classname}} {
protected basePath = '{{basePath}}';
protected defaultHeaders : any = {};
public authentications = {
'default': <Authentication>new VoidAuth(),
{{#authMethods}}
@@ -140,6 +146,10 @@ export class {{classname}} {
}
}
}
public setApiKey(key: {{classname}}ApiKeys, value: string) {
this.authentications[{{classname}}ApiKeys[key]].apiKey = value;
}
{{#authMethods}}
{{#isBasic}}
@@ -151,12 +161,6 @@ export class {{classname}} {
this.authentications.{{name}}.password = password;
}
{{/isBasic}}
{{#isApiKey}}
set apiKey(key: string) {
this.authentications.{{name}}.apiKey = key;
}
{{/isApiKey}}
{{#isOAuth}}
set accessToken(token: string) {