[typescript-angular] Use security scheme name for API key lookup (#5220)

* [typescript-angular] Use security scheme name when looking up API keys.

* [typescript-angular] Updated samples.
This commit is contained in:
Dheeraj Nalluri
2020-02-06 03:20:30 -06:00
committed by GitHub
parent 4fa096f604
commit 7799ddebe1
33 changed files with 168 additions and 71 deletions

View File

@@ -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}}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -402,8 +402,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;

View File

@@ -157,8 +157,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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;