You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using angular-typescript generator leads to invalid code throwing following error at runtime : ERROR TypeError: Cannot read property 'apiKey' of undefined
Looking at generated source code, see Configuration class in configuration.ts does not correctly handle undefined config parameters :
constructor(configurationParameters: ConfigurationParameters={}){this.apiKeys=configurationParameters.apiKeys;// <-- THIS MAY BE UNDEFINED// [...] if(configurationParameters.credentials){this.credentials=configurationParameters.credentials;}else{this.credentials={};}// init default apiKey credentialif(!this.credentials['apiKey']){this.credentials['apiKey']=()=>{returnthis.apiKeys['apiKey']||this.apiKeys['apiKey'];// <-- THIS IS THROWING THE ERROR};}}
openapi-generator version
Version 5.1.0
(npm package @openapitools/openapi-generator-cli version 2.2.5)
Description
Using angular-typescript generator leads to invalid code throwing following error at runtime :
ERROR TypeError: Cannot read property 'apiKey' of undefined
Looking at generated source code, see
Configuration
class inconfiguration.ts
does not correctly handleundefined
config parameters :openapi-generator version
Version 5.1.0
(npm package
@openapitools/openapi-generator-cli
version2.2.5
)OpenAPI declaration file content or url
Generation Details
openapi-generator-cli generate -g typescript-angular -i api.yml
Related issues/PRs
This problem also lead to compilation errors when using strict type checking, as described in #8980 and #8983.
Suggest a fix
The fix suggested in #8980 may work
The text was updated successfully, but these errors were encountered: