swagger-api/swagger-codegen

[Spring] Codegen 2.2.2 does not render objects comprised by allOf and containing additionalProperties:

Open

#5.259 aberto em 30 de mar. de 2017

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)HTML (5.474 forks)batch import
Issue: BugServer: Springhelp wanted

Métricas do repositório

Stars
 (12.701 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Description

When running Codegen 2.2.2 to render Spring objects, when the object has a definition using the allOf schema attribute and also the additionalProperties attribute, the rendered Java object contains no members at all.

Swagger-codegen version

swagger-codegen-cli-2.2.2.jar

Swagger declaration file content or url
  DynamicAccountModel:
    allOf:
      - properties:
          accountId:
            type: string
            description: Account ID
      - additionalProperties:
          type: string
Command line used for generation
java -jar ../tools/swagger-codegen-cli-2.2.2.jar generate -i allof-no-render.yaml -l spring -o target
Steps to Reproduce

Execute above command.

Note that the class contains neither derives from HashMap (due to having the additionalParameters attribute) nor contains an accountId member.

package com.foo.bar;

import java.util.Objects;
import java.io.Serializable;
import javax.validation.constraints.*;
/**
 * DynamicAccountModel
 */
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-03-30T07:57:06.421-04:00")

public class DynamicAccountModel  implements Serializable {

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

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

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class DynamicAccountModel {\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(java.lang.Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }
}

Guia do colaborador