Extremely simple SpringBoot Integrate Swagger
reference
Learn from open source projects com.spring4all.swagger-spring-boot-starter.
rely on
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
<version>1.9.0.RELEASE</version>
</dependency>
Use steps
Add in startup class @EnableSwagger2Doc
annotation
@EnableSwagger2Doc
@SpringBootApplication
public class Bootstrap {
public static void main(String[] args) {
SpringApplication.run(Bootstrap.class, args);
}
}
By default, all current Spring MVC Loaded request mapping document .
To write Controller
@RestController("hello")
public class HelloController {
@ApiOperation(value = "Hello World", authorizations = {
@Authorization(value = "Authorization")})
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String hello(){
}
}
visit swagger-ui Interface
http://localhost:8080/swagger-ui.html/
Reference material
- https://github.com/SpringForAll/spring-boot-starter-swagger