swagger usage tutorial

writing purpose

1. Review + prevent forgetting
2. The new background likes to use the formdata in the post method to submit data, but we prefer the default json method, and its interface is compatible with it later

1. get submit

a. Only one id is required (the most common)

image.png
The front end defines the interface:
image.png
use:
image.png

b.id is spliced ​​after the request address (common)

The back-end swagger is not up, and there is no picture. It is probably like this. The
image.png
front-end definition interface
image.png
is used
image.png

c. Need to splicing id, but also need to pass parameters (common)

The picture is probably like this
image.png
image.png
image.png

2. post submission

a. Just submit normal json data (the most common)

image.png
The front end defines the interface:
image.png
use:
image.png

b. Submitting a post needs to be submitted in formdata form format, which is not very common (mainly here, the front end needs to use formdata to submit when posting, which is very uncomfortable. I don’t want to write new Formdata when there is no file to upload, so it can be like this)

image.png
The front end defines the interface:
image.png
use:
image.png

3. put submit

a.id splicing, you also need to pass parameters (common):

image.png
The front end defines the interface:
image.png
use:
image.png
image.png

Guess you like

Origin blog.csdn.net/weixin_43239880/article/details/132148269