Skip to content

Commit 6b27308

Browse files
committed
refs swagger-api/swagger-codegen#10090 - fix typescript-angular apiKey in template
1 parent 1130576 commit 6b27308

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/resources/handlebars/typescript-angular/api.service.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ export class {{classname}} {
200200
// authentication ({{name}}) required
201201
{{#isApiKey}}
202202
{{#isKeyInHeader}}
203-
if (this.configuration.apiKeys["{{keyParamName}}"]) {
203+
if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) {
204204
{{#useHttpClient}}headers = {{/useHttpClient}}headers.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
205205
}
206206

207207
{{/isKeyInHeader}}
208208
{{#isKeyInQuery}}
209-
if (this.configuration.apiKeys["{{keyParamName}}"]) {
209+
if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) {
210210
{{#useHttpClient}}queryParameters = {{/useHttpClient}}queryParameters.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
211211
}
212212

src/main/resources/mustache/typescript-angular/api.service.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ export class {{classname}} {
200200
// authentication ({{name}}) required
201201
{{#isApiKey}}
202202
{{#isKeyInHeader}}
203-
if (this.configuration.apiKeys["{{keyParamName}}"]) {
203+
if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) {
204204
{{#useHttpClient}}headers = {{/useHttpClient}}headers.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
205205
}
206206

207207
{{/isKeyInHeader}}
208208
{{#isKeyInQuery}}
209-
if (this.configuration.apiKeys["{{keyParamName}}"]) {
209+
if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) {
210210
{{#useHttpClient}}queryParameters = {{/useHttpClient}}queryParameters.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
211211
}
212212

0 commit comments

Comments
 (0)