我在为 OpenAPI (Swagger) 文档定义自定义请求标头时遇到问题。我查看了文档https://swagger.io/docs/specification/describing-parameters/#header-parameters但我无法让它工作。
在我下面的示例中,是一个具有正文的 POST 请求。我还希望它有一个像我的第二个片段一样的自定义标头,但这无效。
还行吧:
/search:
post:
tags:
- Domain
summary: Search for domains
description: Returns a domain if it was found.
produces:
- application/json
parameters:
- in: body
name: body
description: Array of Domain Names
required: true
schema:
$ref: '#/definitions/DomainNames'
Run Code Online (Sandbox Code Playgroud)
这是不行的:
/search:
post:
tags:
- Domain
summary: Search for domains
description: Returns a domain if it was found.
produces:
- application/json
parameters:
- in: header
name: X-Request-ID
schema:
type: string
format: uuid
required: true …Run Code Online (Sandbox Code Playgroud)