swagger-api / swagger-api/swagger-codegen-generators
Breaking change introduced by #1259
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/main/resources/handlebars/Java/interface.mustache and compare the change made for PR #1259 against the v1.0.47 and v1.0.48 generated interfaces. Reproduce the example schema and trace how the discriminator property becomes empty. Done means the generated OneOfSimpleDTOExtraInfo interface retains property = "type" without requiring a schema change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100