How to use Postman to write interface documents, team collaboration development

Recently, in order to reduce the intrusiveness of the code, I abandoned the Swagger that I had been using before, but showdoc is more troublesome to write documents, and it is not convenient to test the interface, so I read many articles on the Internet about postman writing interface documents, and personally experimented Finally, combine the experience to make a summary here.

First understand what is postman

Postman is an interface testing tool. When doing interface testing, Postman is equivalent to a client. It can simulate various HTTP requests initiated by users, send the request data to the server, and obtain the corresponding response results to verify the response. Whether the result data matches the expected value; and ensure that developers can deal with bugs in the interface in a timely manner, thereby ensuring the stability and security of the product after it goes online.

Postman provides a separate installation package: https://www.postman.com/downloads/

So how can the backend use postman to write interface documents, and let the frontend or other developers also collaborate synchronously?

The 4 steps are as follows:

1. Register and log in postman

If you don't have a postman account yet, you need to register one: email address, user name, password;
if you already have an account, just log in directly.

2. Create a project workspace

After successfully logging in, select the workspace. There will be two workspaces by default, and there will be some differences between the team workspace and the personal workspace. But we can create a new workspace for a project to serve the interaction of a project alone:
insert image description here

3. Write interface documentation

2.1 After creating the project workspace, you can create one or more collections in this workspace and name them respectively. The collections here are actually equivalent to each end of the corresponding project: such as the api end, admin end (or can be directly used as a functional module)
insert image description here
2.2 Then right-click on the corresponding collections end and select "add folder" to add a folder (the folder here is equivalent to A functional module can be regarded as a controller, such as "product management", but it is not a necessary step. It mainly depends on personal coding habits. If there are no functional modules, there is no need to create folders. There are many functional modules in the project and need to be subdivided , then a folder can be regarded as a module)
insert image description here
2.3 Next, under the function folder, you can select new Request to add a request, and describe the interface url:
insert image description here
this is an interface request document, so how to describe the return value document Woolen cloth? Look at the picture:
insert image description here
you need to click " Save Response " and select " Save as example ", and an eg will be generated at this time. Then click to enter eg, add **//comment** to the corresponding return value, remember to click save. insert image description here
This is a complete and clear interface document.

4. Add collaborators (this step can also be done at the beginning of creating a workspace)

This step is mainly to allow front-end or developers to share and view the interface documents of the project.
insert image description here
Here are some things to pay attention to:

  1. First, the invitation must be made in the correct project workspace, otherwise, even if the addition is successful, the other party will not be able to see the shared content.
  2. The object to be added must be a postman registered account, otherwise the addition will fail.

In postman, you can also remove collaborators or modify permissions for collaborators according to development needs. This can be explored by individuals.

Xiaobai Xiaoji, if there are mistakes, I hope you guys can correct me!

Guess you like

Origin blog.csdn.net/Ivy_Xinxxx/article/details/121490270
Recommended