Skip to content

Add attributes to metadata XSD file #1080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/Metadata/schema/metadata.xsd
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" ?>

<xsd:schema
xmlns="https://api-platform.com/schema/metadata"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://api-platform.com/schema/metadata"
elementFormDefault="qualified">

<xsd:element name="resources" type="resources"/>
Expand Down
5 changes: 4 additions & 1 deletion tests/Fixtures/FileConfigurations/propertyinvalid.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" ?>

<resources>
<resources xmlns="https://api-platform.com/schema/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata
https://api-platform.com/schema/metadata/metadata-2.0.xsd">
<resource class="ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy">
<property name="foo">
<foo>Foo</foo>
Expand Down
5 changes: 4 additions & 1 deletion tests/Fixtures/FileConfigurations/resourcenotfound.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>

<resources>
<resources xmlns="https://api-platform.com/schema/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata
https://api-platform.com/schema/metadata/metadata-2.0.xsd">
<resource class="ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ThisDoesNotExist">
</resource>
</resources>
7 changes: 5 additions & 2 deletions tests/Fixtures/FileConfigurations/resources.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" ?>

<resources>
<resources xmlns="https://api-platform.com/schema/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata
https://api-platform.com/schema/metadata/metadata-2.0.xsd">
<resource class="ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy"/>
<resource
class="ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy"
Expand Down Expand Up @@ -56,6 +59,6 @@
<attribute name="baz">Baz</attribute>
</property>

<property name="name" description="The dummy name" />
<property name="name" description="The dummy name"/>
</resource>
</resources>
11 changes: 7 additions & 4 deletions tests/Fixtures/FileConfigurations/resourcesinvalid.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>

<resources>
<resource class="ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy">
<foo name="my_op_name" />
</resource>
<resources xmlns="https://api-platform.com/schema/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata
https://api-platform.com/schema/metadata/metadata-2.0.xsd">
<resource class="ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy">
<foo name="my_op_name"/>
</resource>
</resources>
15 changes: 9 additions & 6 deletions tests/Fixtures/FileConfigurations/resourcesoptional.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>

<resources>
<resource class="ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy">
<itemOperation name="my_op_name">
<attribute name="method">POST</attribute>
</itemOperation>
</resource>
<resources xmlns="https://api-platform.com/schema/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata
https://api-platform.com/schema/metadata/metadata-2.0.xsd">
<resource class="ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy">
<itemOperation name="my_op_name">
<attribute name="method">POST</attribute>
</itemOperation>
</resource>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testCreateWithNonexistentPropertyXml()

/**
* @expectedException \ApiPlatform\Core\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /.+Element 'foo': This element is not expected\..+/
* @expectedExceptionMessageRegExp #.+Element '\{https://api-platform.com/schema/metadata\}foo': This element is not expected\..+#
*/
public function testCreateWithInvalidXml()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testCreateWithNonexistentResourceXml()

/**
* @expectedException \ApiPlatform\Core\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /.+Element 'foo': This element is not expected\..+/
* @expectedExceptionMessageRegExp #.+Element '\{https://api-platform.com/schema/metadata\}foo': This element is not expected\..+#
*/
public function testCreateWithInvalidXml()
{
Expand Down