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

Then, we could start to create http_request:

Postman_2

we could change the request type in the left selector:

Postman_4

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

Postman_6

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

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

Postman_10

Finally, here you have a DELETE request:

Postman_11

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.