swagger-api/swagger-codegen

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

Open

#5,259 建立於 2017年3月30日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)HTML (12,701 star) (5,474 fork)batch import
Issue: BugServer: Springhelp wanted

描述

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    ");
  }
}

貢獻者指南

[Spring] Codegen 2.2.2 does not render objects comprised by allOf and containing additionalProperties: · swagger-api/swagger-codegen#5259 | Good First Issue