Hi guys,
It would be nice to have an alias system to reduce long filtering URL :
For
http://localhost:8000/api/offers?price=10&name=shirt&properties2=XXX&properties3=XXX&properties4=XXX&order[properties4]=ASC
we could define the alias :
http://localhost:8000/api/my-offers
It would make the life of the consumers of the API a lot easier.
Not sure how to implement this inside ApiPlatform, but I wanted to share this idea.
WDYT?
J茅r茅my.
You can you use https://symfony.com/doc/current/routing/redirect_in_config.html?
You could also use sub requests. Operation my-offers builds a new request with the query and forwards it to the router.
Why is the long URL a problem? I think it might be more problematic if it's not obvious what the aliased URL would do.
It's more a way to provide information of the endpoint to the client, you can concieve a proper API with some documented shortcut that will be more easy to use/remember.
So that's not a problem, because in all cases you can deliver the informations, but there's a way where it could be easier :)
If this is something that users ask, maybe it should added to the documentation ; if not, we can close it and I thank you for your answers :)
Having such aliases also present another challenge: documenting them in the dynamically generated API documentation.
But sure, it might be nice to have a documentation entry for this.
Throwing another idea out there: what about named filter groups, something like: http://localhost:8000/api/offers?my-offers
This is also a good idea ! But, I'm not sure both ideas should exists.
Another way is to create some DTO.
@er1z No, I think that's a horrible idea.
Why not?
Because why do that when it's the exact same resource? It's not even a different representation as these filters only work at the collection level.
Most helpful comment
Throwing another idea out there: what about named filter groups, something like: http://localhost:8000/api/offers?my-offers