koa-swagger-decorator
koa-swagger-decorator copied to clipboard
date format should check 'yyyy-MM-dd' as stated in OpenAPI definition
Hello,
It seems date
and date-time
formats are both treated as date-time
in the validation, but date
should accept date only values like 2022-01-01
.
According to OpenAPI documentation:
An optional format modifier serves as a hint at the contents and format of the string. OpenAPI defines the following built-in string formats:
date – full-date notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), for example, 2017-07-21
date-time – the date-time notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), for example, 2017-07-21T17:32:28Z
Culprit is in check.ts
if ((expect.format === 'date' || expect.format === 'date-time') && !validator.isRFC3339(val)) return { is: false };
Thanks