Skip to content

Support for @JsonBackReference #3682

Open
@ccarv

Description

@ccarv

I have a field annotated with @JsonBackReference, which is the proper way to handle circular references in your Java objects using Jackson. Traditionally, you would normally annotate with @JsonIgnore but this is not recommended by Jackson. In springdoc, it is recommended to use @Schema(hidden = true) to suppress specific fields but this is ignored when a Jackson annotation is present. See this issue for more details.

Steps To Reproduce
Declare the following annotations at the field level:

  • @JsonBackReference
  • @Schema(hidden = true)

Expected behavior
The field should not be present when viewing models in the swagger UI.

Additional context
It might be worth noting that Jackson recommends using @JsonManagedReference and @JsonBackReference to handle circular references, and thus should be supported by swagger.

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