-
Notifications
You must be signed in to change notification settings - Fork 25
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
Pattern validation not applied to individual values in case of comma separated query params #54
Comments
@TageNielsen FYI.. |
Hey @KPranith , the example you provided is taking the whole |
Thank You @supertong , You meant the query string has to be parsed Are there any other such parsing (pre processing) that has to be done before its passed in for validation ? Would submitting a PR to parse comma separated values to an array would help as a feature for other users ? |
Hey @KPranith , we have library like https://github.com/atlassian/koa-oas3 that using this library under the hood and it's also using the https://github.com/sindresorhus/query-string for parsing that. |
Steps to recreate the issue
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}"
}
}
}
should coerce query parameter to an array
inquery.spec.ts
as belowit('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
The text was updated successfully, but these errors were encountered: