Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Metadata/Extractor/schema/resources.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<xsd:attribute type="xsd:boolean" name="openapi"/>
<xsd:attribute type="xsd:positiveInteger" name="priority"/>
<xsd:attribute type="xsd:string" name="name"/>
<xsd:attribute type="xsd:string" name="itemUriTemplate"/>
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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).

</xsd:complexType>

<xsd:complexType name="graphQlOperations">
Expand Down