phiz71 / vertx-swagger

Swagger integration in Eclipse Vert.X world. A dynamic Vert.X router, configured with a swagger file and a swagger-codegen plugin to generate a server stub.
Apache License 2.0
86 stars 35 forks source link

Duplicate default constructors generated for top level definition of array type #106

Closed cspok82 closed 2 years ago

cspok82 commented 5 years ago

Problem: Swagger JSON:

...
                "responses": {
                    "default": {
                        "description" : "OK",
                        "schema" : {
                            "$ref" : "#/definitions/StringArray"
                        }
                    }
                }
...
    "definitions": {
        "StringArray" : {
            "type" : "array",
            "items" : {
                "type" : "string"
            }
        }
    }

Generated Class:

public class StringArray extends ArrayList<String>  {

  public StringArray () {

  }

  public StringArray () {
  }

Propose to fix pojo.mustache: Instead of (current):

  public {{classname}} ({{#vars}}{{{datatypeWithEnum}}} {{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}) {
    {{#vars}}
    this.{{name}} = {{name}};
    {{/vars}}
  }

Enclose with #hasVars (the fix):

  {{#hasVars}}

  public {{classname}} ({{#vars}}{{{datatypeWithEnum}}} {{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}) {
    {{#vars}}
    this.{{name}} = {{name}};
    {{/vars}}
  }

  {{/hasVars}}