core icon indicating copy to clipboard operation
core copied to clipboard

ExactFilter generate an array on the OpenApi doc

Open johndodev opened this issue 3 months ago • 2 comments

API Platform version(s) affected: 4.2.5

Description
By copy/pasting the code on the doc here : https://api-platform.com/docs/core/doctrine-filters/#exact-filter it result in an array on the doc :

Image

In my real case, where I want to search on an enum field (string in database, enum in symfony entity), when I search with a possible value, it actually works, but the query string include the [] in the query, which is not ok for production. https://api.url.com/foo?page=1&itemsPerPage=30&type%5B%5D=bar

If I try to fix that with "schema" (because as it's an enum, I'd like to have a select in the doc, not an input text), it get worse : I can select a value, but it result in a 422 ConstraintViolation (Cette valeur doit être l'un des choix proposés)

Image

and I did not succeeded to make the query parameter not an array.

Also, some links in the doc leads to nothing, like

  • the "new search filters" here: https://api-platform.com/docs/core/doctrine-filters/#exact-filter
  • links here: https://api-platform.com/docs/core/doctrine-filters/#built-in-new-search-filters-api-platform--42

johndodev avatar Nov 19 '25 12:11 johndodev

I made the openapi doc ok by adding "openApi" in my QueryParameter

Image

I don't know if it's assumed / necessary / .. as the example in the doc is not an array, but is not mentioning anything about that https://api-platform.com/docs/core/doctrine-filters/#exact-filter

johndodev avatar Nov 19 '25 16:11 johndodev

Interesting, my guess is that castToArray is actually true on the parameter, could you screenshot the profiler for this? Indeed by overriding the openapi parameter we don't change it manually therefore its working.. This is looking like a bug I'm transfering this to core.

soyuka avatar Nov 20 '25 14:11 soyuka