Swagger UI

Swagger UI (http://localhost:8080/swagger-ui.html) can also be used to look at the documentation. Swagger UI is enabled by the dependency (io.springfox:springfox-swagger-ui) that was added in our pom.xml, in the previous step.

Swagger UI (http://petstore.swagger.io) is also available online. We can visualise any Swagger documentation (swagger JSON) using Swagger UI.

The following screenshot shows the list of controller-exposing services. When we click on any controller, it expands to show the list of request methods and URIs each controller supports:

The following screenshot shows the details for the POST service to create a todo for the user in Swagger UI:

Some important things to note are as follows:

  • Parameters show all the important parameters including the request body
  • The Parameter Type body (for the ;todo parameter) shows the expected structure for the ;body of the request
  • The Response Messages sections show ;different HTTP status codes returned by the service

The Swagger UI provides an excellent way to expose service definitions for your API without a lot of additional effort.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset