Reputation: 22292
In one of the request I use, I want some attribute to be a moment duration.
How can I define that in Swagger descriptor ?
As far as I understand, something like
type: string
format: iso8601
would be good. But is it the right way yo do ?
EDIT Durations will be expressed using ISO8601 durations. Which means they will be in the form
P1D
for a one day durationP1Y2D
for a one year and two days durationUpvotes: 3
Views: 2215
Reputation: 22292
I chose the following solution
warrantyDuration:
type: string
format: iso8601
description: Warranty duration expressed as an iso8601 duration. Typical values are P1Y, P2Y, ...
example: P1Y
I use the string
type as values are transferred as strings, and the iso8601
format, which is the parent format for dates and durations.
Upvotes: 2