{{ message }}
Repository navigation
How do I add an array QueryParameter correctly? #2859
Unanswered
momocode-de
asked this question in
Q&A
Replies: 1 comment
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
I have a resource with a custom provider (not an entity). I would like to give this resource a query parameter in which multiple values can be specified. So I have added the following to my resource:
#[QueryParameter( key: 'topics', schema: ['type' => 'array', 'maxItems' => 5], required: false, )]Swagger then shows me the following fields:
If I then send it, this URL will be created: ...?topics=sport,fun
But then the following error occurs:
{ "@context": "/api/contexts/ConstraintViolation", "@id": "/api/validation_errors/0=;1=ba785a8c-82cb-4283-967c-3cf342181b40", "@type": "ConstraintViolation", "status": 422, "violations": [ { "propertyPath": "topics", "message": "This value should be of type array|\\Countable.", "code": null }, { "propertyPath": "topics", "message": "This value should be of type array.", "code": "ba785a8c-82cb-4283-967c-3cf342181b40" } ], "detail": "topics: This value should be of type array|\\Countable.\ntopics: This value should be of type array.", "description": "topics: This value should be of type array|\\Countable.\ntopics: This value should be of type array.", "type": "/validation_errors/0=;1=ba785a8c-82cb-4283-967c-3cf342181b40", "title": "An error occurred" }What do I have to change to make this work? Unfortunately, I haven't found anything on this and I would say that this is not an unusual case.
All reactions