Skip to content

6. Test. Postman and Swagger

Appendix: Postman.

This is free software and, through Postman we can make requests:

  • GET, to a route, indicating the parameters in all their possibilities, in the Query of the route, as identifiers in the route.
  • POST and PUT, allowing in a very comfortable way to edit the JSON objects in the body (Body) of the request
  • DELETE, to carry out deletions.

Let's see how we can work with the queries to our newly created API. The first step to take is to create a workspace or Workspace, where we will add our requests

![Postman_1](./img/Postman_1.png){width=95%}

Then, we could start to create http_request:

![Postman_2](./img/Postman_2.png){width=95%}

we could change the request type in the left selector:

![Postman_4](./img/Postman_4.png){width=95%}

we could set parameters adding ?name=value in the request

![Postman_6](./img/Postman_6.png){width=95%}

And we can set values of variables in the path simply adding to the request (as a text in the path). Remember that this correspond with PathVariable.

![Postman_7](./img/Postman_7.png){width=95%}

If we want to send data, in form of JSON object, as forms do, we must set up inside body as raw data as json in a POST or PUT request:

![Postman_8](./img/Postman_8.png){width=95%}
![Postman_10](./img/Postman_10.png){width=95%}

Finally, here you have a DELETE request:

![Postman_11](./img/Postman_11.png){width=95%}

Apèndix 2: Swagger

In this webpage https://www.baeldung.com/spring-rest-openapi-documentation you can find how to add en emmbedded API test pages to work with the API you are generating easily.