swagger-api/swagger-codegen

[java] incorrect generation of java Object

Open

#2,619 opened on Apr 15, 2016

View on GitHub
 (6 comments) (0 reactions) (0 assignees)HTML (12,701 stars) (5,474 forks)batch import
Client: JavaIssue: Bughelp wanted

Description

version: 2.1.6

swagger specs:

"Attributes" : {
  "type" : "object"
},

instead of mapping it to java object, it create new class

package com.macomp;
import java.util.Objects;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-14T08:31:30.310-07:00")
public class Attributes   {

  @Override
  public boolean equals(Object o) {
      if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    Attributes attributes = (Attributes) o;
    return true;
  }

  @Override
  public int hashCode() {
    return Objects.hash();
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
   sb.append("class Attributes {\n");

   sb.append("}");
   return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }
}

Contributor guide