Search code examples
spring-bootswaggerswagger-codegenopenapi

Swagger codegen option to don't generate hashCode() and equals()


The following refers to the generation of the Spring boot server stubs with swagger codegen (-l spring).

Is there any option for Swagger codegen binary (current: v2.3.1) to generate the dto models without the hashCode() and equals() methods?

I did not found any options in the config-help. I want the generated dto models to extend an abstract class where the hashCode() and equals() methods are already declared and therefore shouldn't be overwritten in the generated model classes.


Solution

  • One way is to customize the mustache templates (by removing those lines related to hashCode(), equals()) and use the -t option when generating the spring boot server stubs.