gpt4 book ai didi

rest - YYYYMMDD yaml 定义的日期格式

转载 作者:行者123 更新时间:2023-12-04 02:45:08 26 4
gpt4 key购买 nike

我有一个要求,要求以 YYYYMMDD 格式传递日期。基于 swagger 文档,date filed 在 string 类型下定义。但是,它遵循 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.

YYYYMMDD的日期格式如何定义YAML定义。

最佳答案

根据 type string 的文档你可以添加regex pattern定义日期格式 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.

关于rest - YYYYMMDD yaml 定义的日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57496507/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com