core icon indicating copy to clipboard operation
core copied to clipboard

feat(doctrine): allow property aliasing on doctrine filters

Open Zzareb opened this issue 1 year ago • 3 comments

Q A
Branch? main, new feature
License MIT
Doc PR api-platform/docs

Add a way to alias properties used to query the api filters.

via a simple configuration on the filter declaration, we can replace the parameters such as

my.relation.nested.superField by a simple superField that will be automatically resolved under the hood.

the documentation generated in the response is up to date with the aliased fields.

Zzareb avatar Sep 05 '24 14:09 Zzareb

Interesting, although aliases are made possible using the new QueryParameter functionality since API Platform 3.2. I'm wondering how the documentation (hydra) outputs the view template for such a feature? What about OpenAPI does the parameter gets documented?

soyuka avatar Sep 06 '24 06:09 soyuka

Interesting, although aliases are made possible using the new QueryParameter functionality since API Platform 3.2. I'm wondering how the documentation (hydra) outputs the view template for such a feature? What about OpenAPI does the parameter gets documented?

@soyuka Thanks for the reply. I’ll search the docs for the QueryParameter you mention ! the hydra output returns the aliased property only, might be worthwhile returning both.

I did not tackle open api documentation for this feature, because it is more a flavour for a dedicated field in an entity than a replacement api-wide for the parameter… might be interesting to have it as well for the given routes, although I’m not sure about the implications in the swagger client etc

Zzareb avatar Sep 06 '24 07:09 Zzareb

Any news? I have an API on v3.4 and each resource is a DTO with different properties from the Doctrine entity. I would like to mapping filter DTO properties vs Entity properties

SebLevDev avatar Sep 26 '24 08:09 SebLevDev

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 25 '24 18:11 stale[bot]