We have a rather standard symfony + api-platform project.
A while ago, when a route was created it had a typo in it. I noticed that and want to fix it for the future. The problem is that some of our clients may have implemented it already like that. I want it to still work for a while, without being exposed in documentation. I can take care of the documentation part by overriding the generator service so that’s not a problem.
The problem is that I find no way to create an alias in api-platform. Any idea how I may go about that? The item operations definition looks like this:
* get"={
* "method"="GET",
* "path"="/pathWithTypo/{id}",
* "requirements"={"id"="[0-9A-Z]+-[0-9A-Z]+"},
* "normalization_context"={"groups"={"someGroup"}}
* }
Advertisement
Answer
Just copy “get” operation and name it different:
itemOperations={
"get"={
"method"="GET",
"path"="/pathWithTypo/{id}",
"requirements"={"id"="[0-9A-Z]+-[0-9A-Z]+"},
"normalization_context"={"groups"={"someGroup"}}
},
"get_without_typo"={
"method"="GET",
"path"="/pathWithoutTypo/{id}",
"requirements"={"id"="[0-9A-Z]+-[0-9A-Z]+"},
"normalization_context"={"groups"={"someGroup"}}
}
So, then you can easily remove old get
operation and rename get_without_typo
to get
.
To remove some endpoints from the documentation – I have created my own option – remove_from_docs
. I can share it with you.