Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rmharris157 opened this issue Mar 30, 2017 · 2 comments · Fixed by #8245

Comments

@rmharris157
Copy link

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    ");
  }
}
@ePaul
Copy link
Contributor

ePaul commented Mar 30, 2017

Is this different if you have just the properties + additionalProperties?

    DynamicAccountModel:
        properties:
          accountId:
            type: string
            description: Account ID
        additionalProperties:
          type: string

@ePaul
Copy link
Contributor

ePaul commented Mar 30, 2017

Possibly related issues: #5187, #5132, #4970, #4839, #4907, #4688, ... looks like we have a general problem with additionalProperties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants