Skip to content

Support for @JsonBackReference #3682

@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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @ccarv

      Issue actions

        Support for @JsonBackReference · Issue #3682 · swagger-api/swagger-core