Spring Boot Actuator / Swagger

Arggos picture Arggos · Nov 12, 2015 · Viewed 12.8k times · Source

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.

Answer

jny picture jny · Nov 12, 2015

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.