Skip to content

How to use Swagger

Jordan Jordanov edited this page Jan 9, 2019 · 2 revisions

What Is Swagger?

Swagger allows you to describe the structure of our APIs so that machines can read them. By reading API’s structure, we can automatically build beautiful and interactive API documentation. We can also automatically generate client libraries for our API and explore other possibilities like automated testing. Swagger does this by asking our APIs to return a JSON that contains a detailed description of our entire API.

We can explore information like:

  • What are all the operations that the API supports?
  • What are API’s parameters and what does it return?
  • Does our API need some authorization?
  • And even fun things like terms, contact information and license to use the API.

Use Swagger for JjOnlineStore.Api

  1. Start the project. By default, you will see Swagger UI.

  2. Authorization:

    Go to Token endpoint: Click Try it out :

    image.png - Credentials look like:

    {
        "password": "{your password}",
        "email": "{your email}"
    }
    

    then click Execute. You will receive a response like this:

    image.png

    Copy "tokenString" value. (example : eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdW.....) .

    Go to Authorize button on the top of the page:

    image.png

    Click on it and in the Value: textbox write

    Bearer {your token string}
    

    Example:

    image.png

Well done! Now you are ready to request API endpoints!

You can read more about it here. Have fun.