Skip to content

Commit

Permalink
[typescript-angular] Use security scheme name for API key lookup (#5220)
Browse files Browse the repository at this point in the history
* [typescript-angular] Use security scheme name when looking up API keys.

* [typescript-angular] Updated samples.
  • Loading branch information
djnalluri authored Feb 6, 2020
1 parent 4fa096f commit 7799dde
Show file tree
Hide file tree
Showing 33 changed files with 168 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,19 @@ export class {{classname}} {
{{#authMethods}}
// authentication ({{name}}) required
{{#isApiKey}}
if (this.configuration.apiKeys) {
{{! Fallback behaviour may be removed for 5.0 release. See #5062 }}
const key: string | undefined = this.configuration.apiKeys["{{name}}"] || this.configuration.apiKeys["{{keyParamName}}"];
if (key) {
{{#isKeyInHeader}}
if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) {
{{#useHttpClient}}headers = {{/useHttpClient}}headers.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
}

{{#useHttpClient}}headers = {{/useHttpClient}}headers.set('{{keyParamName}}', key);
{{/isKeyInHeader}}
{{#isKeyInQuery}}
if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) {
{{#useHttpClient}}queryParameters = {{/useHttpClient}}queryParameters.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
{{#useHttpClient}}queryParameters = {{/useHttpClient}}queryParameters.set('{{keyParamName}}', key);
{{/isKeyInQuery}}
}
}

{{/isKeyInQuery}}
{{/isApiKey}}
{{#isBasic}}
{{#isBasicBasic}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,11 @@ export class PetService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,11 @@ export class StoreService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,11 @@ export class PetService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,11 @@ export class StoreService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,11 @@ export class PetService implements PetServiceInterface {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,11 @@ export class StoreService implements StoreServiceInterface {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,11 @@ export class PetService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ export class StoreService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,11 @@ export class PetService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,11 @@ export class StoreService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,11 @@ export class PetService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ export class StoreService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,11 @@ export class PetService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ export class StoreService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,11 @@ export class PetService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ export class StoreService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,11 @@ export class PetService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ export class StoreService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,11 @@ export class PetService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ export class StoreService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,11 @@ export class PetService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ export class StoreService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,11 @@ export class PetService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ export class StoreService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,11 @@ export class PetService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ export class StoreService {
let headers = this.defaultHeaders;

// authentication (api_key) required
if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys) {
const key: string | undefined = this.configuration.apiKeys["api_key"] || this.configuration.apiKeys["api_key"];
if (key) {
headers = headers.set('api_key', key);
}
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
Expand Down
Loading

0 comments on commit 7799dde

Please sign in to comment.