Skip to content

@JsonUnwrapped is ignored when PolymorphicConverter is enabled #2640

Closed
@ghost

Description

Describe the bug

After upgrading to version 2.6.0 of springdoc-openapi we have found that properties included via @JsonUnwrapped aren’t present in the generated model schema.

We assume that the PolymorphicModelConverter causes the problem, since if we disable the polymorphic converter, the generated model looks like expected.

To Reproduce

  • Spring-Boot: v3.3.1
  • Spring Doc OpenAPI Packages:
    • springdoc-openapi-starter-webmvc-ui v2.6.0
  • Create a model including properties annotated with @JsonUnwrapped
  • set springdoc.model-converters.polymorphic-converter.enabled=true

The model generated by the example project doesn't include the properties of the @JsonUnwrapped annotated property:

{
  "schemas": {
    "RootModel": {
      "type": "object",
      "properties": {
        "rootProperty": {
          "type": "integer",
          "format": "int32"
        }
      }
    }
  }
}

Example project: springdoc-json-unwrapped-ignored.zip

Expected behavior

The expected schema should include all properties including those of the unwrapped property:

{
  "schemas": {
    "RootModel": {
      "type": "object",
      "properties": {
        "rootProperty": {
          "type": "integer",
          "format": "int32"
        },
        "unwrappedProperty": {
          "type": "integer",
          "format": "int32"
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions