Why not to use Swagger in correlation with coding? The documentation is always in the current version, you don't need to maintain it, you can test it - a lot of benefits in this kind of approach. It is simple to integrate Swagger with Spring MVC. Start with the API (you don't need to implement anything)- so in Spring MVC it would be controllers layer and use it as a skeleton for your app. Here you have a config for Swagger using Docker - wrapper for swagger api.
@Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage( "com.example.controllers")) .paths(PathSelectors.any()) .build() .apiInfo(apiInfo()); } private ApiInfo apiInfo() { ApiInfo apiInfo = new ApiInfo( "Info ...", "Info ...", "Version ...", "", new Contact("John Smith", "", "[email protected]"), "Copyright 2017 John Smith", ""); return apiInfo; } }
And two dependencies, assuming you use Maven
<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>
After building and deploying your app Swagger docs would be available
YOUR_SERVER:PORT/swagger-ui.html#/
And example usage in the controller
@ApiOperation(value = "Register user") @RequestMapping(value = "/users", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseStatus(HttpStatus.CREATED) public void registerUser(@RequestBody @Valid NewUserRequest newUserRequest) { // you don't need to implement it now }