g0c00l.g33k
g0c00l.g33k

Reputation: 2618

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

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?

Upvotes: 3

Views: 2767

Answers (1)

Ethan Radford
Ethan Radford

Reputation: 64

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.

Upvotes: 3

Related Questions