Skip to content

Commit

Permalink
fix(metadata): allow extracting routeName from XML config (#6329)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacquesDurand committed Apr 25, 2024
1 parent 50c738c commit c083af3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Metadata/Extractor/XmlResourceExtractor.php
Expand Up @@ -404,6 +404,7 @@ private function buildOperations(\SimpleXMLElement $resource, array $root): ?arr
'queryParameterValidate' => $this->phpize($operation, 'queryParameterValidate', 'bool'),
'priority' => $this->phpize($operation, 'priority', 'integer'),
'name' => $this->phpize($operation, 'name', 'string'),
'routeName' => $this->phpize($operation, 'routeName', 'string'),
]);
}

Expand Down
1 change: 1 addition & 0 deletions src/Metadata/Extractor/schema/resources.xsd
Expand Up @@ -48,6 +48,7 @@
<xsd:attribute type="xsd:positiveInteger" name="priority"/>
<xsd:attribute type="xsd:string" name="name"/>
<xsd:attribute type="xsd:string" name="itemUriTemplate"/>
<xsd:attribute type="xsd:string" name="routeName"/>
</xsd:complexType>

<xsd:complexType name="graphQlOperations">
Expand Down
2 changes: 2 additions & 0 deletions src/Metadata/Tests/Extractor/XmlExtractorTest.php
Expand Up @@ -273,6 +273,7 @@ public function testValidXML(): void
'itemUriTemplate' => null,
'stateOptions' => null,
'links' => null,
'routeName' => 'custom_route_name',
],
[
'name' => null,
Expand Down Expand Up @@ -373,6 +374,7 @@ public function testValidXML(): void
'provider' => null,
'stateOptions' => null,
'links' => null,
'routeName' => null,
],
],
'graphQlOperations' => null,
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/Tests/Extractor/xml/valid.xml
Expand Up @@ -95,7 +95,7 @@
</exceptionToStatus>

<operations>
<operation class="ApiPlatform\Metadata\GetCollection" name="custom_operation_name"/>
<operation class="ApiPlatform\Metadata\GetCollection" name="custom_operation_name" routeName="custom_route_name"/>
<operation class="ApiPlatform\Metadata\Get" uriTemplate="/users/{userId}/comments/{id}{._format}">
<uriVariables>
<uriVariable parameterName="userId" fromClass="ApiPlatform\Metadata\Tests\Fixtures\ApiResource\User" fromProperty="author"/>
Expand Down

0 comments on commit c083af3

Please sign in to comment.