-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Description of the problem/issue
After upgrading to swagger-core 2.2.39, polymorphic schemas that rely on subtype resolution produce incomplete allOf definitions.
Expected Schema
"ConcretionResponseA": {
"type": "object",
"allOf": [
{ "$ref": "#/components/schemas/BaseResponse" },
{
"type": "object",
"properties": {
"concretionAField": { "type": "string" }
}
}
]
}Actual Schema (Buggy)
"ConcretionResponseA": {
"allOf": [
{ "$ref": "#/components/schemas/BaseResponse" }
]
}Possible cause
The regression stems from commit dd5ce54, which normalizes context annotations inside AnnotatedType.equals()/hashCode() but still ignores flags such as schemaProperty and propertyName. As a result, property and subtype resolutions now collapse into the same cache entry and the subtype-specific fragment is skipped.
In the attached example Spring Boot project the type ConcretionResponseA is first resolved as a property and later as a subtype; the second pass now reuses the cached property schema, so the subtype-specific properties never reach the generated OpenAPI document.
Affected Version
>= 2.2.39
Earliest version the bug appears in: 2.2.39 (regression introduced by commit dd5ce54)
Steps to Reproduce
Example Project: https://github.com/benjaminknauer/swagger-2-2-39-polymorphism-bug-example
- clone the example project
mvn clean test- Inspect the failure of
BuggySchemaIntegrationTest(compares/api-docsresponse with expected schema).
The serialized schema will show ConcretionResponseA with only a single allOf entry.
Expected Behavior
ConcretionResponseA should contain two allOf entries: the $ref to BaseResponse and a second object with the subtype’s own property (concretionAField).
Actual Behavior
ConcretionResponseA only contains the $ref to BaseResponse; the object with concretionAField is missing because subtype resolution returns the cached result from the earlier property resolution.