OpenAPI V3 CompositionExtendedModel example incorrect and behaviour incorrect.
Referring to the following documentation, a model extending another model should place its own properties within an entry of the "allOf" field. https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/
In the above documentation, the field "rootCause" is within allOf > properties.
Comparing this with the v3.json file used for testing, it is evident that the tool expects properties to live outside of "allOf".
"CompositionExtendedModel": {
"description": "This is a model that extends the base model",
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/CompositionBaseModel"
}
],
"properties": {
"age": {
"type": "number"
}
},
"required": [
"firstName",
"lastname",
"age"
]
}
If I try running OpenAPI V3 json or yml through the tool it will not include the properties in the extended model if the properties for the sub model are included within an entry of the allOf field.
I'm having the same problem. Did you find a workaround ?
This got it working for me but some of the unit tests fail as a result which means you should probably be very careful if you decide to try and use this patch:
--- a/src/openApi/v3/parser/getModelComposition.ts
+++ b/src/openApi/v3/parser/getModelComposition.ts
@@ -55,6 +55,16 @@ export const getModelComposition = (
properties.push(...requiredProperties);
}
+ if (definition.allOf?.length) {
+ definition.allOf.forEach((entry) => {
+ if (entry?.properties) {
+ definition.properties = {...definition.properties, ...entry.properties};
+ }
+ })
+ }