[Typescript - Angular2] Add support for multiple API Keys (#5236)

# Conflicts:
#	modules/swagger-codegen/src/main/resources/typescript-angular2/configuration.mustache
#	samples/client/petstore/typescript-angular2/default/configuration.ts
#	samples/client/petstore/typescript-angular2/npm/configuration.ts
This commit is contained in:
Usman Iqbal
2017-03-30 15:27:39 +01:00
committed by wing328
parent e4ca7744df
commit 833db27101
10 changed files with 24 additions and 24 deletions

View File

@@ -184,14 +184,14 @@ export class {{classname}} {
// authentication ({{name}}) required
{{#isApiKey}}
{{#isKeyInHeader}}
if (this.configuration.apiKey) {
headers.set('{{keyParamName}}', this.configuration.apiKey);
if (this.configuration.apiKeys["{{keyParamName}}"]) {
headers.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
}
{{/isKeyInHeader}}
{{#isKeyInQuery}}
if (this.configuration.apiKey) {
queryParameters.set('{{keyParamName}}', this.configuration.apiKey);
if (this.configuration.apiKeys["{{keyParamName}}"]) {
queryParameters.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
}
{{/isKeyInQuery}}

View File

@@ -1,5 +1,5 @@
export interface ConfigurationParameters {
apiKey?: string;
apiKeys?: {[ key: string ]: string};
username?: string;
password?: string;
accessToken?: string;
@@ -7,7 +7,7 @@ export interface ConfigurationParameters {
}
export class Configuration {
apiKey: string;
apiKeys: {[ key: string ]: string};
username: string;
password: string;
accessToken: string | (() => string);
@@ -15,7 +15,7 @@ export class Configuration {
constructor(configurationParameters: ConfigurationParameters = {}) {
this.apiKey = configurationParameters.apiKey;
this.apiKeys = configurationParameters.apiKeys;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;

View File

@@ -429,8 +429,8 @@ export class PetService {
}
// authentication (api_key) required
if (this.configuration.apiKey) {
headers.set('api_key', this.configuration.apiKey);
if (this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
}

View File

@@ -191,8 +191,8 @@ export class StoreService {
];
// authentication (api_key) required
if (this.configuration.apiKey) {
headers.set('api_key', this.configuration.apiKey);
if (this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
}

View File

@@ -1,5 +1,5 @@
export interface ConfigurationParameters {
apiKey?: string;
apiKeys?: {[ key: string ]: string};
username?: string;
password?: string;
accessToken?: string;
@@ -7,7 +7,7 @@ export interface ConfigurationParameters {
}
export class Configuration {
apiKey: string;
apiKeys: {[ key: string ]: string};
username: string;
password: string;
accessToken: string | (() => string);
@@ -15,7 +15,7 @@ export class Configuration {
constructor(configurationParameters: ConfigurationParameters = {}) {
this.apiKey = configurationParameters.apiKey;
this.apiKeys = configurationParameters.apiKeys;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;

View File

@@ -1,4 +1,4 @@
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201703211709
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201703271250
### Building
@@ -19,7 +19,7 @@ navigate to the folder of your consuming project and run one of next commando's.
_published:_
```
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201703211709 --save
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201703271250 --save
```
_unPublished (not recommended):_

View File

@@ -429,8 +429,8 @@ export class PetService {
}
// authentication (api_key) required
if (this.configuration.apiKey) {
headers.set('api_key', this.configuration.apiKey);
if (this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
}

View File

@@ -191,8 +191,8 @@ export class StoreService {
];
// authentication (api_key) required
if (this.configuration.apiKey) {
headers.set('api_key', this.configuration.apiKey);
if (this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
}

View File

@@ -1,5 +1,5 @@
export interface ConfigurationParameters {
apiKey?: string;
apiKeys?: {[ key: string ]: string};
username?: string;
password?: string;
accessToken?: string;
@@ -7,7 +7,7 @@ export interface ConfigurationParameters {
}
export class Configuration {
apiKey: string;
apiKeys: {[ key: string ]: string};
username: string;
password: string;
accessToken: string | (() => string);
@@ -15,7 +15,7 @@ export class Configuration {
constructor(configurationParameters: ConfigurationParameters = {}) {
this.apiKey = configurationParameters.apiKey;
this.apiKeys = configurationParameters.apiKeys;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;

View File

@@ -1,6 +1,6 @@
{
"name": "@swagger/angular2-typescript-petstore",
"version": "0.0.1-SNAPSHOT.201703211709",
"version": "0.0.1-SNAPSHOT.201703271250",
"description": "swagger client for @swagger/angular2-typescript-petstore",
"author": "Swagger Codegen Contributors",
"keywords": [