Skip to content

Commit

Permalink
feat(metadata): throw exception if itemUriTemplate if used on invalid…
Browse files Browse the repository at this point in the history
… operation (xml/yaml formats) (#6053)
  • Loading branch information
vincentchalamon authored Dec 19, 2023
1 parent 2a43268 commit c13c88e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Metadata/Extractor/XmlResourceExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ private function buildOperations(\SimpleXMLElement $resource, array $root): ?arr

if (\in_array((string) $operation['class'], [GetCollection::class, Post::class], true)) {
$datum['itemUriTemplate'] = $this->phpize($operation, 'itemUriTemplate', 'string');
} elseif (isset($operation['itemUriTemplate'])) {
throw new InvalidArgumentException(sprintf('"itemUriTemplate" option is not allowed on a %s operation.', $operation['class']));
}

$data[] = array_merge($datum, [
Expand Down
2 changes: 2 additions & 0 deletions src/Metadata/Extractor/YamlResourceExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ private function buildOperations(array $resource, array $root): ?array

if (\in_array((string) $class, [GetCollection::class, Post::class], true)) {
$datum['itemUriTemplate'] = $this->phpize($operation, 'itemUriTemplate', 'string');
} elseif (isset($operation['itemUriTemplate'])) {
throw new InvalidArgumentException(sprintf('"itemUriTemplate" option is not allowed on a %s operation.', $class));
}

$data[] = array_merge($datum, [
Expand Down

0 comments on commit c13c88e

Please sign in to comment.