Add Swagger 2 to Rest API

Introduction

Swagger 2 provides the API documentation which are informative, readable, and easy to follow. It uses Springfox implementation of the Swagger 2 specification.

Set up

Add the swagger dependencies to your pom.xml. Check the latest version. N.B some version may have problems when displaying the documentation soln:

  • build your application
  • change swagger dependency versions
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
apis(RequestHandlerSelectors.basePackage("com.tables.Tables"))

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mercy Jemosop

Mercy Jemosop

Software Developer connect with me on twitter @kipyegon_mercy