0

I need to exclude endpoints from the documentation which are added to the project through the maven dependency.

My OpenApi configuration:

    @Configuration public class OpenApiConfiguration {
    
        @Value("${app.version:unknown}")
        private String version;
    
        @Bean
        public OpenAPI openAPI() {
            return new OpenAPI()
                    .info(new Info()
                            .description("Generated OpenAPI 3.0 API")
                            .version(version));
        } 
}

My springdoc dependency in pom.xml

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

I have tried to use this in my application.yml, bit it didn't work, endpoints and modeles from maven dependencies were always shown in Open Api docs.

springdoc:
  packages-to-exclude:

The only thing that works is adding paths-to-match or paths-to-exclude in the application.yml. But I want exclude the entire lib and avoid listing all the paths.

springdoc:
    paths-to-exclude:
    paths-to-match:

I use java 8. Is there a way to exclude the library from the Open Api documentation?

olga
  • 1
  • 2
  • How did you use packages to exclude exactly ? – Vova Bilyachat May 17 '21 at 12:00
  • You will need to use the fully qualified package name to exclude the resources properly. – Debargha Roy May 17 '21 at 13:28
  • I used `springdoc: packages-to-exclude: my.package` in my application.yml. It didn't work in java 8. The beanType of classes from maven dependency is com.sun.proxy.$Proxy176 and package is null in java 8. There is a code snippet in org.springdoc.api that calculate a package for classes: org.springdoc.api.AbstractOpenApiResource#isFilterCondition. And there is a code snipper that add packages with null value in swagger documentation: org.springdoc.api.AbstractOpenApiResource#isPackageToScan `protected boolean isPackageToScan(Package aPackage) { if (aPackage == null) return true;` – olga May 19 '21 at 08:13
  • Is there a different way to exclude a package from OpenApi documentation? – olga May 19 '21 at 08:15
  • olga You have workaround with paths. Could you provide a minimal sample, that shows packages-to-exclude not working in your case ? – brianbro May 23 '21 at 15:17

0 Answers0