JanithOCoder
JanithOCoder

Reputation: 301

Change Swagger generated class names

i'm generating java classes from a swagger file and following is the part of the swagger files.

"jobCardStepList": {
          "type": "object",
          "properties": {
            "jobCardStep": {
              "type": "array", 

for the above part Swagger is generating a java class

UpdateJobCardRequestJobCardStepListJobCardStep.java

I want to rename this class with a proper name. is there any way to change the class names from the Swagger generator.

Upvotes: 2

Views: 9165

Answers (1)

William Cheng
William Cheng

Reputation: 10817

Currently, you're defining the model inline.

I would recommend defining the model in a different section and reference it in your spec. Here is an example:

Model definition: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml#L654

Reference: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml#L49

That way, the name of the Java class name will be based on the model name defined in the specification.

Upvotes: 3

Related Questions