Skip to content

Commit c13c88e

Browse files
feat(metadata): throw exception if itemUriTemplate if used on invalid operation (xml/yaml formats) (#6053)
1 parent 2a43268 commit c13c88e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/Metadata/Extractor/XmlResourceExtractor.php

+2
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ private function buildOperations(\SimpleXMLElement $resource, array $root): ?arr
388388

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

393395
$data[] = array_merge($datum, [

src/Metadata/Extractor/YamlResourceExtractor.php

+2
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ private function buildOperations(array $resource, array $root): ?array
324324

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

329331
$data[] = array_merge($datum, [

0 commit comments

Comments
 (0)