You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
{
"errors":[
{
"type":"query",
"dataPath":"q",
"keyword":"type",
"schema":"array",
"data":"narf",
"message":"Invalid type, expected array"
}
],
"stack":"BadRequestError: Request failed to validate against RAML definition\n at createValidationError (/home/cf/.nvm/versions/node/v6.9.4/lib/node_modules/osprey-mock-service/node_modules/osprey-method-handler/osprey-method-handler.js:746:14)\n at ospreyQuery (/home/cf/.nvm/versions/node/v6.9.4/lib/node_modules/osprey-mock-service/node_modules/osprey-method-handler/osprey-method-handler.js:210:19)\n at handle (/home/cf/.nvm/versions/node/v6.9.4/lib/node_modules/osprey-mock-service/node_modules/compose-middleware/lib/index.js:56:16)\n at dispatch (/home/cf/.nvm/versions/node/v6.9.4/lib/node_modules/osprey-mock-service/node_modules/compose-middleware/lib/index.js:39:20)\n at next (/home/cf/.nvm/versions/node/v6.9.4/lib/node_modules/osprey-mock-service/node_modules/compose-middleware/lib/index.js:37:24)\n at ospreyAccepts (/home/cf/.nvm/versions/node/v6.9.4/lib/node_modules/osprey-mock-service/node_modules/osprey-method-handler/osprey-method-handler.js:187:12)\n at handle (/home/cf/.nvm/versions/node/v6.9.4/lib/node_modules/osprey-mock-service/node_modules/compose-middleware/lib/index.js:56:16)\n at dispatch (/home/cf/.nvm/versions/node/v6.9.4/lib/node_modules/osprey-mock-service/node_modules/compose-middleware/lib/index.js:39:20)\n at IncomingMessage.next (/home/cf/.nvm/versions/node/v6.9.4/lib/node_modules/osprey-mock-service/node_modules/compose-middleware/lib/index.js:37:24)\n at emitNone (events.js:86:13)"
}
... providing two or more works fine
$ curl "localhost:3333/bar?q=narf&q=poit"
OK
$ curl "localhost:3333/bar?q=narf&q=poit&q=zort"
OK
The text was updated successfully, but these errors were encountered:
The issue is that a single q is passed as a string to the validator, and hence it does not validate against type: array. For reference, the RAML spec has a section about this scenario:
RAML does not define validation when a query parameter declaration specifies any of the following types for the value of the query parameter: an object type, a union of non-scalar types, or an array type if the underlying type of the array is an object type or union of non-scalar types. Processors MAY default to treating the format of the query parameter value as JSON in applying the type to instances of that query parameter, or they MAY allow other treatments based on annotations.
Have you tried declaring q as type: array | string? wouldn't it be a more accurate definition in your case?
Hi,
a query parameter that is declared as
type: array
isn't allowed to contain only one value.Providing one query parameter causes an error...
$ curl "localhost:3333/bar?q=narf"
... providing two or more works fine
$ curl "localhost:3333/bar?q=narf&q=poit" OK
$ curl "localhost:3333/bar?q=narf&q=poit&q=zort" OK
The text was updated successfully, but these errors were encountered: