Steps to recreate the issue
- Change
query.json /pets petId parameter like below
{
"name": "petId",
"in": "query",
"required": true,
"description": "The id of the pet to retrieve",
"schema": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Z0-9]+-[0-9]{4}"
}
}
}
- change the test case
should coerce query parameter to an array in query.spec.ts as below
it('should coerce query parameter to an array', () => {
const queryMeta = {
method: 'get',
query: {
petId:'ACD-2016,ACD-213'
}
};
expect(chowchow.validateRequest('/pets', queryMeta)).toEqual(expect.objectContaining({
query: {
petId: ['ACD-2016,ACD-213']
}
}));
expect(queryMeta.query.petId).toEqual('ACD-2016,ACD-213');
});
As the string ACD-213 is not matching the pattern it should fail but it doesn't
