express-openapi-validator
express-openapi-validator copied to clipboard
formats as an array is deprecated. Use object instead
Describe the bug When using the formats property as described in the docs: https://github.com/cdimascio/express-openapi-validator/wiki/Documentation#%EF%B8%8F-formats-optional I get following warning:
formats as an array is deprecated. Use object instead https://ajv.js.org/options.html#formats
To Reproduce Setup express-server and use OpenApiValidator middleware with following config:
formats: [
{
name: 'iso8601-timestamp',
type: 'string',
validate: (value) => moment(value, moment.ISO_8601).isValid(),
},
],
Actual behavior Warning is shown on server-start.
Expected behavior No warning should be shown on server-start.
Examples and context Please consider upgrading to current Ajv schema: https://ajv.js.org/options.html#formats
This is easy to fix by using object instead of an array like:
formats: {
"iso8601-timestamp": {
type: 'string',
validate: (value) => moment(value, moment.ISO_8601).isValid(),
}
},
Right?