Search code examples
spring-bootswaggerspring-boot-actuator

Spring Boot Actuator / Swagger


I'm working on Spring Boot application and i use Swagger for the documentation.

I have adding Spring Boot Actuator on my application, but now i want to add the new services creating by actuator (/health /metrics ..) on my swagger documentation.

I don't find how configure Actuator and Swagger.


Solution

  • You can configure in Swagger which paths you want to be added to the documentation :

    @Bean
    public Docket appApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                ...
    }
    

    will display all available endpoints.

    .paths(PathSelectors.any("/mypath/**")) will limit only to endpoints exposed in mypath.