Skip to content
Boniara edited this page Oct 12, 2016 · 6 revisions

Introduction

Swagger is a simple yet powerful representation of RESTful API.
Springfox is an implementation of Swagger and Spring MVC integration.
Springfox home page here

swagger-ui.html location

Swagger ui located by zafira/swagger-ui.html path.

Maven dependencies

  • springfox-swagger2:
<dependency>
	<groupId>io.springfox</groupId>
	<artifactId>springfox-swagger2</artifactId>
	<version>2.6.0</version>
</dependency>
  • spring-swagger-ui
<dependency>
	<groupId>io.springfox</groupId>
	<artifactId>springfox-swagger-ui</artifactId>
	<version>2.6.0</version>
</dependency>

For connect swagger core and swagger ui respectively. Also need to change com.google.guava 13.0.1 to latter version (19.0 e.g.) for compatibility of dependencies.

Swagger configuration

In class SwaggerConfiguration.java a swagger documentation configuration is located. Docket is an object of configuration. Docket stands for a summary or other brief statement of the contents of a document an abstract. It helps configure a subset of the services to be documented and groups them by name.

Configuration with Spring integration

Created file swagger-configuration.xml and imported him to dispatcher-servlet.xml.

Exclude boilerplate annotations

The package annotations with @interface XxxxResponse annotations was created for minimaze amount of code. These annotations extend fill with data properties of support swagger annotations to document. They contain user transcripts of server response codes by default.

Apis annotation

  • @ApiIgnore is used for mark that class or method don`t need for documentation as group of apis or api respectively.
  • @ApiOperation:
    value - how value will be have method name at swigger-ui.html
    httpMethod - api method of the request
    notes - description (summary) of the api method
    responseType - type of the response of api method