对于这种格式的日期,OpenAPI 和 JSON Schema 没有内置的 format。但是,format 是一个开放值关键字,因此您可以指定任何您喜欢的值,例如 format: http-date 甚至
format: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
无法识别给定format 值的工具将忽略它并仅使用type。
也就是说,我建议您使用不带format 的type: string,并可选择提供example 值。或者您可以将其设为字符串和整数的oneOf,以反映替代格式Retry-After: 120。 (然而,一个简单的type: string 也适用于这种情况。)
使用type: string 的示例:
responses:
'429':
description: Rate limit exceeded
headers:
Retry-After:
description: Indicates how long the client should wait before making a follow-up request.
schema:
type: string
# example: 'Wed, 21 Oct 2022 07:28:00 GMT'
# optionally add examples for both date and delay-seconds
examples:
http-date:
value: 'Wed, 21 Oct 2022 07:28:00 GMT'
delay-seconds:
value: 120
使用type: string + type: integer 的示例:
schema:
oneOf:
- type: string
example: 'Wed, 21 Oct 2022 07:28:00 GMT'
description: A date after which to retry.
- type: integer
minimum: 0
example: 120
description: The seconds to delay after the response is received.