I have an entity name PowerDNSDomain. I would like to keep this name but change the path for /dns/... instead of /power_d_n_s_domain/*.
The only way I found is to set the path on each operation definition:
/**
* @ApiResource(
* collectionOperations={
* "get"={"path"="/dns"}
* "post"={"path"="/dns"}
* }
* )
*/
It works, but it is cumbersome.
It would be great to have a basePath option to replace the path of all operations.
I also tried routePrefix, but this does not replace /power_d_n_s_domain on this case.
What do you think?
Did you try to change the short name? IIRC something like that should do the trick:
/**
* @ApiResource(
* shortName="Dns",
* ...
* )
*/
Anyway, the basePath sounds like a good idea to me.
@meyerbaptiste yes but it does not fit my need. I don't want the model to appear as Dns on the documentation.
馃憤 for basePath as well.
But transforming PowerDNSDomain in power_d_n_s_domain looks faulty to me. I would expect power_dns_domain. Maybe the regex should be updated.
@dunglas Not sure about that. This is not the first bundle doing this kind of transformation.
Maybe is the "way to do" to convert to snake_case.
You could always override the OperationPathResolver only for this resource.
Thank you @soyuka, I will take a look!
Having the resource class as an argument of the OperationPathResolverInterface::resolveOperationPath() method could improve the dx in this specific case...