Best way to denote time (without date) in Swagger spec

匆匆过客 提交于 2019-12-19 10:17:17

问题


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?

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/46698681/best-way-to-denote-time-without-date-in-swagger-spec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!