API Platform version(s) affected: >4.2.0
Description
When I have defined 2 endpoints with a suffix for a resource,same suffix, different method, only the 2nd method defined now works. The error did not exist in 4.2.0 back on 24th September, but seems to have crept in somewhere in between as my tests now fail and I can confirm by changing the order of my definitions, the bug resolves for one method, and introduces for the other.
How to reproduce
My configuration (don't hate me) in XML
<resources xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="Silverback\ApiComponentsBundle\Entity\Component\Form" output="Silverback\ApiComponentsBundle\Entity\Component\Form" provider="Silverback\ApiComponentsBundle\DataProvider\StateProvider\FormStateProvider">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" />
<operation class="ApiPlatform\Metadata\Post" />
<operation class="ApiPlatform\Metadata\Get" />
<operation class="ApiPlatform\Metadata\Delete" />
<operation class="ApiPlatform\Metadata\Put" />
<operation class="ApiPlatform\Metadata\Patch" />
<operation class="ApiPlatform\Metadata\Post"
name="_api_/forms/{id}/submit{._format}"
method="POST"
uriTemplate="/forms/{id}/submit{._format}"
read="true"
deserialize="false"
validate="false"
write="false"
serialize="true">
<requirements>
<requirement property="id">[^/]+</requirement>
</requirements>
</operation>
<operation class="ApiPlatform\Metadata\Patch"
name="_api_/forms/{id}/submit{._format}"
method="PATCH"
uriTemplate="/forms/{id}/submit{._format}"
read="true"
deserialize="false"
validate="false"
write="false"
serialize="true">
<requirements>
<requirement property="id">[^/]+</requirement>
</requirements>
</operation>
</operations>
</resource>
</resources>
Possible Solution
Not sure yet, just discovered.
Additional Context
So the /submit endpoint for this resource in my case will only work for Patch in the example above. Move the Put to below the Patch definition and then Put will work and Patch will 405.
API Platform version(s) affected: >4.2.0
Description
When I have defined 2 endpoints with a suffix for a resource,same suffix, different method, only the 2nd method defined now works. The error did not exist in 4.2.0 back on 24th September, but seems to have crept in somewhere in between as my tests now fail and I can confirm by changing the order of my definitions, the bug resolves for one method, and introduces for the other.
How to reproduce
My configuration (don't hate me) in XML
Possible Solution
Not sure yet, just discovered.
Additional Context
So the
/submitendpoint for this resource in my case will only work forPatchin the example above. Move thePutto below thePatchdefinition and thenPutwill work andPatchwill 405.