Skip to content

[Bug]: Regression: AnnotatedType equality change drops polymorphic subtype allOf entries #5003

@benjaminknauer

Description

@benjaminknauer

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

  1. clone the example project
  2. mvn clean test
  3. Inspect the failure of BuggySchemaIntegrationTest (compares /api-docs response 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions