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

Breaking change introduced by #1259 #1290

Open
pbelousov opened this issue May 27, 2024 · 0 comments
Open

Breaking change introduced by #1259 #1290

pbelousov opened this issue May 27, 2024 · 0 comments

Comments

@pbelousov
Copy link

It seems like the PR #1259 introduced a breaking change.

Here is an example schema that we have:

{
  "components": {
    "schemas": {
      "SimpleDTO": {
        "properties": {
          "extraInfo": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ExtraInfoADto"
              },
              {
                "$ref": "#/components/schemas/ExtraInfoBDTO"
              }
            ]
          }
        },
        "type": "object"
      },
      "ExtraInfoADto": {
        "type": "object"
      },
      "ExtraInfoBDTO": {
        "type": "object"
      }
    }
  },
...
}

Swagger Codegen Generators v1.0.47 generates the following OneOfSimpleDTOExtraInfo interface:

@JsonTypeInfo(
  use = JsonTypeInfo.Id.NAME,
  include = JsonTypeInfo.As.PROPERTY,
  property = "type")
@JsonSubTypes({
  @JsonSubTypes.Type(value = ExtraInfoADto.class, name = "ExtraInfoADto"),
  @JsonSubTypes.Type(value = ExtraInfoBDTO.class, name = "ExtraInfoBDTO")
})
public interface OneOfSimpleDTOExtraInfo {

}

However, Swagger Codegen Generators v1.0.48 starts generating the following file:

@JsonTypeInfo(
  use = JsonTypeInfo.Id.NAME,
  include = JsonTypeInfo.As.PROPERTY,
  property = "")
@JsonSubTypes({
  @JsonSubTypes.Type(value = ExtraInfoADto.class, name = "ExtraInfoADto"),
  @JsonSubTypes.Type(value = ExtraInfoBDTO.class, name = "ExtraInfoBDTO")
})
public interface OneOfSimpleDTOExtraInfo {

}

As you can see, for now, the property argument is empty instead of having the type value which causes issues for consumers of the generated library. The template was changed in the scope of the #1259 (the src/main/resources/handlebars/Java/interface.mustache file) that looks like a breaking change.

Can you please help us understand how to deal with this change since the OpenAPI schema is auto-generated and we cannot change it?

/cc @HugoMario @OsztosA

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

No branches or pull requests

1 participant