1

With Swagger as i understand one cannot pass/specify things like Jackson annotations for fields when specifying the models in the swagger definition yaml.

Therefore, is there a way to manually make these changes in the generated model files & request swagger (swagger-codegen) to try & preserve those when regenerating the models?

I tried doing this & see that by default it just overwrites the files completely, i couldn't find any setting for this in the codegen configuration.

Can someone suggest any idea on how to go about this?

Thanks

lmk
  • 654
  • 5
  • 21

1 Answers1

2

You can use custom templates with the -t option, e.g.

java -jar swagger-codegen-cli.jar generate -i https://raw.githubusercontent.com/swagger-api/swagger-codegen/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l csharp -o C:\test\csharp-client -t C:\workspace\csharp-custom-templates

where C:\workspace\csharp-custom-templates stores the templates with your changes.

NickSim
  • 156
  • 6
  • Thanks @NickSim i did come across custom templates but was not sure how i could use it to preserve manual changes like annotations that i add to specific model fields, let me read up on it & see how i can do that...if u know of a good tutorial or blog post please do share..again thanks for the time & the response. – lmk Nov 14 '20 at 09:49