Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

vcloud openapi v37.2 Java generation #14

@tvs61

Description

@tvs61

I'm attempting to use the 37.2.json spec to generate java objects via openapi-generator-cli-6.6.0 running under JDK11 and the resulting maven project won't build due to errors related to the "type" variable derived from the spec. I was seeing this same issue when using the 37.0 spec as well.

In short, it appears that "type" and "_type" in the generated VcloudQueryResultRecordType class conflict. Specifically:

  public static final String SERIALIZED_NAME_TYPE = "type";
  @SerializedName(SERIALIZED_NAME_TYPE) private String type;

  public static final String SERIALIZED_NAME_TYPE = "_type";
  @SerializedName(SERIALIZED_NAME_TYPE) protected String type;

Which results in these 3 methods being duplicated in VcloudQueryResultRecordType (once for "type" and once for "_type"):

  public VcloudQueryResultRecordType type(String type) {

    this.type = type;
    return this;
  }

  /**
   * Contains the type of the resource.
   * @return type
   **/
  @javax.annotation.Nullable
  public String getType() {
    return type;
  }

  public void setType(String type) { this.type = type; }

  public VcloudQueryResultRecordType link(List<VcloudLinkType> link) {

    this.link = link;
    return this;

This in-turn throws off any other generated VcloudQueryResult* classes which descend from VcloudQueryResultRecordType.

From what I can tell, the "_type" discriminator is the root of my problems (from the spec):

      "vcloud_QueryResultRecordType": {
        "title": "vcloud_QueryResultRecordType",
        "description": "Base type for a single record from query result in records format. Subtypes define more specific elements.",
        "discriminator": {
          "propertyName": "_type",

Is there a particular option I need to provide to openapi-generator-cli-6.6.0 to generate better/compiling Java? I've attempted with various combinations of discriminatorCaseSensitive, legacyDiscriminatorBehavior, x-discriminator-value, etc - but none of those appear to make any difference in the generated output. Perhaps I'm looking in the wrong place WRT the discriminator value?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions