forked from loafle/openapi-generator-original
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user