了解REST API并关注https://apihandyman.io/writing-openapi-swagger-specification-tutorial-part-2-the-basics/。REST API具有“required”响应属性意味着什么?
API可以接收两个参数:username
和bla
,但只有username
,通过使用required
关键字所需。这对我有意义。
的API将返回firstname
,lastname
,并username
,但只有username
是通过使用required
关键字所需。这对我没有意义。缺少关键字required
是否表明其他两个有时可能不需要?什么影响他们是否是?
paths:
/persons/{username}:
get:
summary: Gets a person
description: Returns a single person for its username.
parameters:
- name: username
in: path
required: true
description: The person's username
type: string
- name: bla
in: query
description: bla bla bla
type: string
responses:
200:
description: A Person
schema:
required:
- username
properties:
firstName:
type: string
lastName:
type: string
username:
type: string
404:
description: The Person does not exists.