HTTP JSON 端点
使用 application/json 内容类型记录 HTTP JSON API
OpenAPI 中的端点定义在 paths 键下。以下是定义单个端点的示例:
openapi.yml
paths:/pets:post:summary: Create a new petdescription: Creates a new pet with the provided informationrequestBody:required: truecontent:application/json:schema:$ref: '#/components/schemas/Pet'responses:'200':description: User created successfullycontent:application/json:schema:$ref: '#/components/schemas/Pet'
示例
您可以通过使用 examples 键来提供请求和响应的示例。
openapi.yml
paths:/pets:post:summary: Create a new petdescription: Creates a new pet with the provided informationrequestBody:required: truecontent:application/json:schema:$ref: '#/components/schemas/Pet'examples:PetExample:summary: This is an example of a Petvalue:name: Markleyid: 44responses:'200':description: A Pet objectcontent:application/json:schema:$ref: '#/components/schemas/Pet'examples:PetExample:summary: This is an example of a Petvalue:name: Markleyid: 44