Repository navigation
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
allOf can have sibling json properties like deprecated, readOnly, nuallable etc.
allOf with single$ref is treated differently: #16096
allOf with single $ref doesn't respect sibling property behaviour.
Whereas allOf with more than one $ref respects sibling properties.
OpenAPI spec with allOf & single $ref:
"components":{
"schemas": {
"AssetFrame": {
"type": "object",
"properties": {
"test": {
"type": "string",
"deprecated": true
},
"machineDetails": {
"deprecated": true,
"allOf": [
{
"$ref": "#/components/schemas/MachineDetails"
}
]
}
}
}
}
}
Generates below java code:
Snippet of AssetFrame.java
@SerializedName(SERIALIZED_NAME_MACHINE_DETAILS)
private AssetFrameMachineDetails machineDetails;
OpenAPI spec with allOf & more man one $ref
"components":{
"schemas": {
"AssetFrame": {
"type": "object",
"properties": {
"test": {
"type": "string",
"deprecated": true
},
"machineDetails": {
"deprecated": true,
"allOf": [
{
"$ref": "#/components/schemas/MachineDetails"
},
{
"$ref": "#/components/schemas/Shelf"
}
]
}
}
}
}
}
Snippet of AssetFrame.java
@Deprecated
@SerializedName(SERIALIZED_NAME_MACHINE_DETAILS)
private AssetFrameMachineDetails machineDetails;
openapi-generator version
3.0.0
Expectation
allOf with single $ref should respect deprecated property and should have @Deprecated annotation.
Steps to reproduce
java -jar ./modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ./library_openapi.json -g java -o ~/Documents/library/
Related issues/PRs
None found
Suggest a fix
Probably fix will be in [modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java#L235](
Line 235 in c9f7af7
| // single allOf and it's a ref |
Need to set properties before/after execution.
need go through the code to find the code fix location.
Activity
wing328 commentedon Nov 13, 2023
thanks for reporting the issue. I've filed #17056 to fix it.