Search code examples
javaspringdocspringdoc-openapi-ui

Omit super class fields in spring doc open api docs


I'm on java 8, spring-boot 1.5.1 release and I've got the dependency

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    <version>1.8.0</version>
</dependency>

My controller requests all extend a common super class with some fields in it. Now I want to omit these fields in the documentation. So that only the fields of the base class are shown... How can I do that?

I've tried Schema(all = {}) on top of my base request class. I've tried creating a Bean OpenApiCustomizer but it requires springdoc-openapi-starter-webmvc-ui and java 17. I've tried adding this in the yml springdoc.packages-to-exclude=packageWithOnlyTheSuperRequestClass

nothing works

@RestController
public class FakeController{

    @RequestMapping(value = {"/fake-method"}, method = RequestMethod.GET)
    public String fakeMethod(BaseClassRequest request){
        return "Hello, world!";
    }

}
public class BaseClassRequest extends SuperClassRequest{

    private String username;

    // getter and setter
}
public class SuperClassRequest{
    private String password;

    // getter and setter
}

enter image description here


Solution

  • Try using @Schema(hidden = true) in the class and check