Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as this is not declared on every operation I'm not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I got an error when I used
itemUriTemplete
.Element '{https://api-platform.com/schema/metadata/resources-3.0}operation', attribute 'itemUriTemplate': The attribute 'itemUriTemplate' is not allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
itemUriTemplate
is only available on GetCollection and Post operations. But I'm not sure it's possible to handle such difference with XML schema...A solution would be to allow this attribute on XML and YAML schemas, and add a specific validation on XmlResourceExtractor and YamlResourceExtractor services to ensure this attribute is only set on a GetCollection or Post operation, otherwise throw an error. The XmlExtractorTest and YamlExtractorTest should help to test this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: apparently, I already did a similar check in resource extractors 😃
https://github.com/api-platform/core/blob/3.1/src/Metadata/Extractor/XmlResourceExtractor.php#L387-L389
https://github.com/api-platform/core/blob/3.1/src/Metadata/Extractor/YamlResourceExtractor.php#L323-L325
Throwing an exception if the operation does not match could improve the DX instead of just ignoring the key (PR in progress).