If array query parameter is wrapped inside anyOf, it does not behave similar to non-wrapped parameter when querying for single elements.
https://github.com/Arskah/prism-anyof-single-array/blob/main/schema/api.json
"paths": {
"/users": {
"get": {
"parameters": [
{
"name": "id",
"in": "query",
"required": false,
"schema": {
"anyOf": [
{
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
},
"minItems": 1,
"maxItems": 500,
"title": "Id"
}
]
}
}
],
...
Current Behavior
Querying a single element throws UNPROCESSABLE_ENTITY
{
"type": "https://stoplight.io/prism/errors#UNPROCESSABLE_ENTITY",
"title": "Invalid request",
"status": 422,
"detail": "Your request is not valid and no HTTP validation response was found in the spec, so Prism is generating this error for you.",
"validation": [
{
"location": [
"query",
"id"
],
"severity": "Error",
"code": "type",
"message": "Request query parameter id must be array"
},
{
"location": [
"query",
"id"
],
"severity": "Error",
"code": "anyOf",
"message": "Request query parameter id must match a schema in anyOf"
}
]
}
Expected Behavior
?id=1 should validate as an array, similar to unwrapped array.
Possible Workaround/Solution
One can query single array element with ?id[]=1 format.
Steps to Reproduce
https://github.com/Arskah/prism-anyof-single-array
Repro steps in README.
Environment
If
arrayquery parameter is wrapped insideanyOf, it does not behave similar to non-wrapped parameter when querying for single elements.https://github.com/Arskah/prism-anyof-single-array/blob/main/schema/api.json
Current Behavior
Querying a single element throws UNPROCESSABLE_ENTITY
{ "type": "https://stoplight.io/prism/errors#UNPROCESSABLE_ENTITY", "title": "Invalid request", "status": 422, "detail": "Your request is not valid and no HTTP validation response was found in the spec, so Prism is generating this error for you.", "validation": [ { "location": [ "query", "id" ], "severity": "Error", "code": "type", "message": "Request query parameter id must be array" }, { "location": [ "query", "id" ], "severity": "Error", "code": "anyOf", "message": "Request query parameter id must match a schema in anyOf" } ] }Expected Behavior
?id=1should validate as an array, similar to unwrapped array.Possible Workaround/Solution
One can query single array element with
?id[]=1format.Steps to Reproduce
https://github.com/Arskah/prism-anyof-single-array
Repro steps in README.
Environment
stoplight/prism:5.12.1@sha256:271dc94c174a95d9c44b4a4e1b5eb335db1edb7ab88edb4cc9a2cbd7b210ef94