Open blakharaz opened 11 months ago
Having one reference and one inline schema in the allOf also doesn't generate code I would expect. The generated type for the property (which is of type string so I wouldn't even expect an additional type here) contains a property of type object instead of string.
Specification for this:
{
"openapi": "3.0.3",
"info": {
"title": "allOf used to add constraints bug",
"description": "allOf used to add constraints for string properties results in faulty generated DTO class",
"version": "1b2917d69f13ea0545f755a6e2963923ff2fb367"
},
"paths": {
"/actual": {
"get": {
"responses": {
"200": {
"description": "reproduces the bug",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Actual"
}
}
}
}
}
}
},
"/expected": {
"get": {
"responses": {
"200": {
"description": "returns expected type",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Expected"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Actual": {
"properties": {
"myString": {
"allOf": [
{"type": "string", "pattern": "[a-z]*"},
{"$ref": "#/components/schemas/BaseClass"}
]
}
}
},
"BaseClass": {
"properties": {
"myString": {
"pattern": "[a-z]*"
}
}
},
"Expected": {
"properties": {
"myString": {
"type": "string",
"pattern": "[a-z]*"
}
}
}
}
}
}
Bug Report Checklist
Description
schemas with allOf definitions setting the same property multiple times result in a generated type with no property at all
openapi-generator version
I used commit hash 1b2917d69f13ea0545f755a6e2963923ff2fb367 and the "csharp" generator as well as a new generator for a different target language I'm developing right now.
OpenAPI declaration file content or url
Generation Details
My settings for generator as code:
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/10010
Suggest a fix
In case of allOf properties of the same property should be merged (taking the first or the last if set multiple times, the spec doesn't state anything for that case), that way there would be no need to generate a new type, especially for basic type properties.