Search code examples
spring-bootspring-restspring-restdocsspringdocspringdoc-openapi-ui

Springdoc OpenAPI displays class relationships under schemas and examples


I am using springdoc-openapi for REST API documentation. I have two classes which has One to One relationship between them. After I create the API, When I use the API. It returns exactly the way it stored in the database, but the example values or schema shown in the docs display the complete relationship between them. I don't want to display the relationship between them instead display only the way it would get the response. The following image, the first highlighted one is the actual result and second one is the example value shown. The second one displays the relationship between Room and Check-in. How can I avoid this displaying??

enter image description here


Solution

  • You need to add @JsonIgnore on checkin_id in your parent entity.

    @JsonIgnore Will not add the checkin_id in your sample and actual response.