Skip to content
williamlixu edited this page Apr 9, 2020 · 8 revisions

Swagger UI

  • Swagger is a way for developers to test their api endpoints, and also acts as a documentation center for API's created.

  • It allows software engineers to save time on documentation as much of it is auto generated

  • It's comprehensible for developers and non-developers. Anyone can have input into the design of the API, because it is clearly mapped in a user-friendly UI.

  • It's easily adjustable. This makes it great for testing and debugging API problems.

Using Swagger

Upon starting up the WebApiBackend, the swagger interface will open up in the browser automatically, and you will be presented with a similar looking page.

image

Since every api endpoint is authorised (besides user), in order to test the endpoints in swagger you will first have to obtain a JWT token otherwise all requests will result in a 401 unauthorised error. This can be done by logging in through the log in endpoint and entering a correct username/password in the body.

image

You will receive a response body which contains the JWT token which can be used to authenticate

image

Once the JWT token is obtained, click the authorise button

image

And then enter "Bearer " (e.g. Bearer eyJhbGciOiJIUzI1NiI...)

image

Now all endpoints should be accessible

Clone this wiki locally