Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript-angular2] Generated model attributes always start with lowercase char #4558

Closed
pspeter opened this issue Jan 15, 2017 · 4 comments

Comments

@pspeter
Copy link

pspeter commented Jan 15, 2017

Description

The models generated by the cli always have attributes whose first character is lowercase. My properties all start with an uppercase character though, and they are also written like that in the API and the swagger doc.

Swagger-codegen version

2.2.1

Swagger declaration file content or url
{ ...
"definitions":{ ... 
    "Rating":{"type":"object","properties":{
        "RatingId":{"format":"int32","type":"integer"},
        "Player":{"$ref":"#/definitions/Player"},
        "Datetime":{"format":"date-time","type":"string"},
        "Value":{"format":"int32","type":"integer"}
    }}
}}

generates:

export interface Rating {
    ratingId?: number;
    player?: models.Player;
    datetime?: Date;
    value?: number;
}
Command line used for generation

CMD:

java -jar swagger-codegen-cli-2.2.1.jar generate -o [...]\src\app \
-i http:\\localhost:4649/swagger/docs/v1 -l typescript-angular2
@wing328
Copy link
Contributor

wing328 commented Jan 15, 2017

@bloody-orange there's an option change the variable naming:

	modelPropertyNaming
	    Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name (Default: camelCase)

Ref: java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l typescript-angular2

@wing328
Copy link
Contributor

wing328 commented Jan 15, 2017

@bloody-orange there's also another PR to use an ObjectSerializer to handle mapping of the JSON key name: #4264

Please kindly it test out by runnning:

git checkout -b TiFu-typescriptPropertyNamingFix 2.3.0
git pull https://github.com/TiFu/swagger-codegen.git typescriptPropertyNamingFix

@pspeter
Copy link
Author

pspeter commented Jan 15, 2017

@wing328 thanks for the quick response
The config works perfectly, thanks again.

@wing328
Copy link
Contributor

wing328 commented Jan 15, 2017

@bloody-orange no problem. Let us know if you've further feedback.

(we've just added Swagger Codegen to ProductHunt: https://www.producthunt.com/posts/swagger-codegen, pleae upvote found Swagger Codegen useful)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants