我尝试使用flasgger实现项目的swagger文档。当我描述body字段时,它可以正常工作,但是当我试图描述标题字段时,flasgger并没有给出web上参数的描述。
flasgger的.yml文件示例。
description: Client side interaction with server
consumes:
- "application/json"
parameters:
- in: header
name: headers_params
required: true
schema:
id: endpoint_header
required:
- session_token
properties:
session_token:
type: string
description: session token
- in: body
name: body_params
required: true
schema:
id: endpoint_body
required:
- parameter1
- parameter2
properties:
parameter1:
type: string
description: The parameter1 description
parameter2:
type: string
description: The parameter2 description
responses:
500:
description: The error on the server side
200:
description: Access token for user intercation这就是我在网上看到的:在这里输入图像描述
我应该遵循什么样的.yml文件结构来获得头和正文参数中描述的会话令牌?
发布于 2021-11-14 13:53:07
看起来您使用的是OpenAPI 2.0语法。在OAS2中,标头参数的描述如下:
- in: header
name: session_token # <---- HTTP header name
required: true
type: string
description: session token
或者,与身份验证相关的标头(如会话令牌)可以被描述为安全方案,例如API密钥。
swagger: '2.0'
...
securityDefinitions:
session_token:
type: apiKey
in: header
name: session_token # <---- HTTP header name
# Add the "security" section either on the root level (if all endpoints
# are secured with this token), or inside individual GET/POST/etc. operations
security:
- session_token: []https://stackoverflow.com/questions/69953865
复制相似问题