swagger-api/swagger-codegen-generators

Breaking change introduced by #1259

pbelousov opened this issue · 0 comments

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