I want to validate multiple occurrences of the same query parameter using AJV.
My OpenApi schema looks something like this:
...
/contacts:
get:
parameters:
- name: user_id
in: query
schema:
type: integer
...
I convert it to a valid json schema to be able to validate it with AJV:
{
query: {
properties: {
user_id: { type: 'integer' }
}
}
}
Naturally, AJV validation works fine for one parameter of type integer.
I want to be able to validate multiple occurrences of user_id
.
For example: /contacts?user_id=1&user_id=2
is converted to { user_id: [1, 2] }
and I want it to actually be valid.
At this point validation fails because it expects an integer but received an array. Is there any way to validate each items of the array independently ?
Thanks