Search code examples
javaswagger-uispring-annotationsspringdoc-openapi-ui

springdoc swagger ui not showing entity component model schema


org.springdoc-openapi-ui version = 1.5.13 using Maven 4.0.0, java 11

model user.java

@Entity(name = "User")
@Table(name = "User")
public class User {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Integer id;

    @Column
    @NotBlank(message = "user last name cannot be blank")
    @NotEmpty(message = "user last name cannot be empty")
    @Pattern(regexp="^[a-zA-Z]",message="last name must contain only alpha characters")
    private String lastName;
}

application.properties

springdoc.api-docs.path=/api-docs
springdoc.swagger-ui.path=/api-docs.html

when going to :

localhost:8080/api-docs.html

my other models (same architecture as User) are not showing.

Same if I go to

localhost:8080/api-docs

other models are not in >components>schemas either

It used to work on my other projects (with same springdoc version)


Solution

  • Entities must have set and get methods of their properties that are nested entities in order for swagger ui to show the models of those other entities. In my case I added the methods for nested entities I had in the context of OneToMAny and ManyToOne relationships and models showed