swagger-codegen
swagger-codegen copied to clipboard
[Java] setters for readonly fields are missed
Description
Json parsers like gson need setters for all non transient fields by default. But setters for readonly
fields are missed in codegen. So json parser can to use only slow reflection to set value into private read only
methods.
Swagger-codegen version
2.2.2-SNAPSHOT
Command line used for generation
java -jar /home/punksta/apps/swagger-codegen-cli.jar generate \
-i ../api-v1.yml \
-l java \
Steps to reproduce
read_only for any fields
Related to
https://github.com/swagger-api/swagger-codegen/issues/2189
Suggest a Fix
Easy way: Generate setters, but annotate fields as "read only".
Hard way: Let read_only
fields final
and generate custom constructors for it. Also need to generate deserialization for every library what invoke custom constructors while json parsing.
Ping..? Is there any plan to fix/support it?
@punksta do you have some interesting WA for this?