Swagger2 dependencies
Add these dependencies to your pom.xml file
<dependency> | |
<groupId>io.springfox</groupId> | |
<artifactId>springfox-swagger2</artifactId> | |
<version>2.4.0</version> | |
</dependency> | |
<dependency> | |
<groupId>io.springfox</groupId> | |
<artifactId>springfox-swagger-ui</artifactId> | |
<version>2.4.0</version> | |
</dependency> |
Swagger configuration file
Now you can create the Swagger configuration file
package com.learning.app.config; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import springfox.documentation.spi.DocumentationType; | |
import springfox.documentation.spring.web.plugins.Docket; | |
import springfox.documentation.swagger2.annotations.EnableSwagger2; | |
@Configuration | |
@EnableSwagger2 | |
public class SwaggerConfig { | |
@Bean | |
public Docket api() { | |
return new Docket(DocumentationType.SWAGGER_2); | |
} | |
} |
Now you are ready. Your REST controllers are now available on Swagger 2. You can access the Swagger documentation via http://localhost:8090/swagger-ui.html You may change the port with the port your application is running.
You can find the complete code from my GitHub
Top comments (0)