Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String schema format:date #188

Open
danailch456 opened this issue Mar 4, 2021 · 1 comment
Open

String schema format:date #188

danailch456 opened this issue Mar 4, 2021 · 1 comment

Comments

@danailch456
Copy link

I have the following query parameter in the spec:

name: fromDate
in: query
description: A beginning date of the time range in yyyy-mm-dd format
required: false
schema:
  type: string
  format: date

When I setup the route with hapi-openapi and send a request with query ?fromDate=2014-10-14, the validation passes successfully, but the route handler recieves ?fromDate=Tue+Oct+14+2014+03%3A00%3A00+GMT%2B0300+%28Eastern+European+Summer+Time%29.
According to the openapi specification the 'date' format' should represent a date in yyyy-mm-dd.
Modifying the query params during validation seems odd and unnecessary. I hope this gets fixed soon.

@danailch456
Copy link
Author

danailch456 commented Mar 15, 2021

I think the bug comes from generating the joi schema for validating date. After converting the string to date, .raw should be called to preserve the input yyyy-mm-dd format. More info here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant