use*_*722 3 rest swagger openapi
我有一个要求,其中请求以 YYYYMMDD 格式传递日期。基于 swagger 文档,在字符串类型下定义的日期归档。但是,它遵循 RFC 3339,第 5.6 节,文档(例如 2018-03-20 作为格式)
下面的代码不适用于 yaml。
dateOfBirth:
type: string
minLength: 8
maxLength: 8
format: date
example: 19000101
description: Birth date of the member in YYYYMMDD format.
Run Code Online (Sandbox Code Playgroud)
如何为 YYYYMMDD 的日期格式定义 YAML 定义。
根据类型字符串的文档,您可以添加正则表达式模式来定义日期格式 YYYYMMDD :
模式:'^\d{4}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$'
另外让我建议您使用 20190317 之类的日期更新示例日期格式,以便轻松理解预期的日期格式。
definitions:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
dateOfBirth:
type: string
minLength: 8
maxLength: 8
format: date
pattern: '^\d{4}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$'
example: 20190816
description: Birth date of the member in YYYYMMDD format.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3899 次 |
| 最近记录: |