[typescript-angular2] API Call Returns Model with "undefined" Member Value
Description
When calling API by using TypeScript-Angular2 codegen, it returns data with "undefined" member value. When I inspect the returned data, the issue relies on different letter case (the return data has Pascal-case property name, but the model declaration has Camel-case property name).

Swagger-codegen version
2.2.1
Steps to reproduce
- Create an API service with return model which has Pascal-case property name (e.g. AuthenticationToken).
- Generate code with typescript-angular2 language.
- Write a dummy TypeScript code to call the API and compare the return data with the model declaration. Both has different capitalization style.
Suggest a Fix
Please add mapping for the returned data from any-case to camel-case, or change the property name to follow the letter case of the returned data.
@darius-iko I think the issue you reported is similar to this one: https://github.com/swagger-api/swagger-codegen/issues/2766
Have you tried the modelPropertyNaming option to see if that addresses the issue for you?
swagger-codegen|master⚡ ⇒ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l typescript-angular2
CONFIG OPTIONS
sortParamsByRequiredFlag
Sort method arguments to place required parameters before optional parameters. (Default: true)
ensureUniqueParams
Whether to ensure parameter names are unique in an operation (rename parameters that are not). (Default: true)
modelPropertyNaming
Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name (Default: camelCase)
supportsES6
Generate code that conforms to ES6. (Default: false)
npmName
The name under which you want to publish generated npm package
npmVersion
The version of your npm package
npmRepository
Use this property to set an url your private npmRepo in the package.json
snapshot
When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm (Default: false)
cc @Vrolijkx
Thank you. It works.
Hi, how to inject parameter in HTTP Headers by using generated code? Can I set it by using the Api.defaultHeaders before calling the API? e.g: this.api.defaultHeaders.set('Content-Type', 'application/json');
Btw, there is another issue that the Api calls set Content-Type to text/plain by default. Meanwhile, it suppose to be application/json because it sends JSON data type. It causes the server to respond error message, unless I set it manually by using above approach.
@darius-iko could you please try and see if #3603 fixes your issues?
@darius-iko #3603 has been merged into master. Please pull the latest to give it a try.
If the issue still occurs, we'll reopen this issue.
Thank you.