添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
私奔的山楂  ·  Python ...·  2 年前    · 
S
S
Swagger Documentation(CHS)
Search
K

描述参数

在Swagger中,API操作参数在操作定义的 parameters 部分中定义。每个参数都有 name ,值 type (对于原始值参数)或 schema (对于请求体),和可选项 description 。这是一个例子:
paths :
/users/ { userId }:
get :
summary : Gets a user by ID.
parameters :
- in : path
name : userId
type : integer
required : true
description : Numeric ID of the user to get.
注意,这 parameters 是一个数组,所以在YAML中,每个参数定义必须在前面加上一个dash( - )。

参数类型

Swagger根据参数位置区分以下参数类型。位置由参数的 in 键确定,例如 in: query in: path

查询参数

查询参数是最常见的参数类型。它们出现在请求URL尾部的问号( ? )之后,不同的 name=value 对由&符号分隔。查询参数可 以是必需和可选的。
GET /pets/findByStatus ? status=available
GET /notes ? offset=100 &limit=50
使用 in: query 表示查询参数:
parameters :
- in : query
name : offset
type : integer
description : The number of items to skip before starting to collect the result set.
- in : query
name : limit
type : integer
description : The numbers of items to return.