Configuring Swagger

The dependencies are added, now we can configure the infrastructure for Swagger. The configuration is pretty simple. We will create a class with @Configuration to produce the Swagger configuration for the Spring container. Let's do it.

Take a look at the following Swagger configuration:

package springfive.cms.infra.swagger;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.web.bind.annotation.RestController;import springfox.documentation.builders.ParameterBuilder;import springfox.documentation.builders.PathSelectors;import springfox.documentation.builders.RequestHandlerSelectors;import springfox.documentation.spi.DocumentationType;

Get Spring 5.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.