0

I am creating an api using hapi framework and need to take in time as one of the data types in the payload that I receive. I have defined the validation as

payload: {
  startTime: Joi.date().timestamp().required(),
  endTime: Joi.date().timestamp().required()
}

But when I bring up the swagger documentation page for this validation I see the inputs to be received a below

{
  "startTime": 0,
  "endTime": 0
}

I was expecting a more user-friendly approach where it would display the timestamp format in swagger like below.

{
  "startTime": HH:MM:SS,
  "endTime": HH:MM:SS
}

How do I make this possible?

Abhi
  • 314
  • 1
  • 7
  • 23
  • Going by your validation you're opting to accept timestamps, which are essentially just integers which is why Swagger is defaulting to 0. If you want more explicit timestamps I suggest using `Joi.date().iso()`. – Ankh Oct 29 '18 at 11:07
  • Thanks for your suggestion. I tried validating it with ```Joi.date().iso()``` but it still shows a number in swagger. – Abhi Nov 04 '18 at 14:47
  • Now that I checked it again carefully. It definitely works for date and displays ```YYYY-MM-DD``` All I need to do now is to find a way to display the time like this ```2018-11-04T11:59:47Z``` – Abhi Nov 04 '18 at 14:56

0 Answers0