我正在Swagger 2.0中为OAuth JSON有效负载创建一个#definition.grant_type
是必需的,但必须是特定值(password
).
我怎么能告诉Swagger这个属性的值必须等于password
?
definitions:
TokenRequest:
required:
- userId
- password
- grant_type
properties:
userId:
type: string
password:
type: string
grant_type:
# here we need to describe that it must = 'password'
Run Code Online (Sandbox Code Playgroud)
严格来说,你会这样定义它:
definitions:
TokenRequest:
required:
- userId
- password
- grant_type
properties:
userId:
type: string
password:
type: string
grant_type:
type: string
enum:
- password
Run Code Online (Sandbox Code Playgroud)
但是,您应该知道Swagger 2.0具有指定应用程序安全属性的特定部分,包括OAuth2密码流.然后,您可以为API全局设置它,并在每次操作时根据需要覆盖它.或者,您可以按操作声明它.
有关它的更多信息:
归档时间: |
|
查看次数: |
1686 次 |
最近记录: |