Skip to content

Commit

Permalink
typescript-angular: Fix Cannot read property 'apiKey' of undefined (#…
Browse files Browse the repository at this point in the history
…9260)

* fix #9259

* avoid optional chaining operator
  • Loading branch information
EmmanuelRoux authored Apr 16, 2021
1 parent b5dac42 commit 0329119
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export class {{configurationClassName}} {
{{#isApiKey}}
this.credentials['{{name}}'] = () => {
{{! Fallback behaviour may be removed for 5.0 release. See #5062 }}
return this.apiKeys['{{name}}'] || this.apiKeys['{{keyParamName}}'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['{{name}}'] || this.apiKeys['{{keyParamName}}'];
}
};
{{/isApiKey}}
{{#isBasic}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class PetStoreConfiguration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export class Configuration {
// init default api_key credential
if (!this.credentials['api_key']) {
this.credentials['api_key'] = () => {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['api_key'] || this.apiKeys['api_key'];
}
};
}

Expand Down

0 comments on commit 0329119

Please sign in to comment.