Swagger规格中表示时间(无日期)的最佳方法 [英] Best way to denote time (without date) in Swagger spec

查看:886
本文介绍了Swagger规格中表示时间(无日期)的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在摇摇欲坠的规范中表示时间字段的最佳方法是什么,最接近的类型表示它类似于date-time,但这使标准反序列化程序期望日期字段与时间一起传递...是否存在是一种标准的或最佳的做法,以一种能与杰克逊反序列器很好地配合使用的标准来表示时间?

What is the best way to represent a time field in a swagger specification, the closest type to denote it looks like date-time but this makes standard deserialisers to expect date field to be passed along with the time... Is there a standard or best practice to just denote time in a swagger spec that works well with the Jackson deserialisers?

以毫秒/秒为单位表示时间,并大摇大摆地使用类型string是可以接受的方法吗?

Is denoting time in milliseconds/seconds and using type string in swagger an acceptable approach?

推荐答案

根据您要表示的内容,这可能是一个好主意,也可能不是一个好主意.

Depending on what you're trying to represent, this may or may not be a good idea.

如果要表示特定的时间戳,那么包括日期可能会更安全.

If you want to represent a specific timestamp, then it's probably much safer to include the date.

如果日期真的不重要(例如,您想表明某个事件在每天的14:00发生),那么我不认为swagger具有内置格式.但是,打开了格式设置字段,并且设置了支持 ECMA 262正则表达式字符串模式.

If the date really isn't important (eg. you want to indicate that an event takes place at 14:00 every day), then I don't believe swagger has a built in format for that. However, the swagger format field is open and swagger has support for ECMA 262 regex string patterns.

这篇关于Swagger规格中表示时间(无日期)的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆