简体   繁体   中英

How to exclude lib in Swagger API documentation

I have used keycloak-admin-client in a jaxrs application, and use swagger to generate API documentation. Swagger generates documents for all methods in keycloak-admin-client. How can I exclude this library from documentation in swagger ?

Dependency:

        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-admin-client</artifactId>
            <version>7.0.0</version>
        </dependency>

        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-jaxrs2</artifactId>
            <version>2.1.0</version>
        </dependency>

        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-jaxrs2-servlet-initializer</artifactId>
            <version>2.1.0</version>
        </dependency>

by this solution assign only my package for scan

@ApplicationPath("/api")

public class ApplicationInitializer extends Application {

public ApplicationInitializer(@Context ServletConfig servletConfig) {
    super();
    OpenAPI oas = new OpenAPI();
    try {
        Set<String> resource = new HashSet<>();
        resource.add("my.company.api.path");
        SwaggerConfiguration oasConfig = new SwaggerConfiguration()
                .openAPI(oas)
                .prettyPrint(true)
                .resourcePackages(resource);

        OpenApiContext oac = new JaxrsOpenApiContextBuilder()
                .servletConfig(servletConfig)
                .application(this)
                .openApiConfiguration(oasConfig)
                .buildContext(true);
        oac.read();
    } catch (OpenApiConfigurationException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM