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

Add attributes to metadata XSD file #1080

merged 1 commit into from
Apr 26, 2017

Conversation

scollado
Copy link
Contributor

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR TBD

Not a critical thing, but as I tend to prefer XML for configuration files I'm sure other will enjoy the change :
Added attributes allow to validate resources.xml files as developers can do with other Symfony config files (ex: routing, services, ...)
This would ease auto-completion by editors supporting XML structure hints from the XSD (like PHPStorm) by defining the namespace in the XML header, as other XML config files do in Symfony :

<!-- src/AppBundle/Resources/config/api_resources/resources.xml -->

<?xml version="1.0" encoding="UTF-8" ?>
<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">
   [...]
</resources>

The proposed URI for the schema (https://api-platform.com/schema/metadata/metadata-2.0.xsd) is subject of discussion as it implies that the last stable version of the XSD file for the choosen branch is publicly available.

I'll make the PR to the Getting-Started page of the documentation once those details will be sorted out.
WHat do you think about this ?

@scollado
Copy link
Contributor Author

I did not commit updated fixtures as the XSD is not yet available from a public URL, I'll update the PR when the final location will be chosen (or is this not required ? I tried locally by defining a valid internal URL for the xsd file).

@dunglas
Copy link
Member

dunglas commented Apr 24, 2017

Great. But as with Symfony, it should not rely on nor request an external server in production. So you can add fixtures without the file being publicly available, it will be a good test that it works.

@scollado scollado changed the title Add attributes to metadata XSD file WIP: Add attributes to metadata XSD file Apr 25, 2017
@scollado scollado closed this Apr 25, 2017
Added attributes allow to validate resources.xml files as developers can
do with other Symfony config files (ex: routing, services, ...)

Expected messages have been updated to match new syntax with XML
namespace.
@scollado scollado reopened this Apr 25, 2017
@scollado
Copy link
Contributor Author

@dunglas Updated fixtures & exception message regexp in tests to include proposed namespace (after messing up with my git remotes while updating 😕 ).
Forking the documentation right-now to prepare a PR including the changes.

@scollado scollado changed the title WIP: Add attributes to metadata XSD file Add attributes to metadata XSD file Apr 25, 2017
@dunglas dunglas merged commit 2ec8626 into api-platform:2.0 Apr 26, 2017
@dunglas
Copy link
Member

dunglas commented Apr 26, 2017

Thank you @scollado

@dunglas
Copy link
Member

dunglas commented Apr 28, 2017

This PR breaks tests: https://travis-ci.org/api-platform/core/jobs/226752482

Do you have an idea of the problem @scollado?

@soyuka soyuka mentioned this pull request Apr 28, 2017
@soyuka
Copy link
Member

soyuka commented Apr 28, 2017

ping @scollado would you be able to patch the documentation about XML declarations there?

@soyuka
Copy link
Member

soyuka commented Apr 28, 2017

@dunglas fixed, it was only an issue on master where we had more tests on XML than on 2.0.

@jakesylvestre
Copy link

As per #1229, does this need to be done to the filter.xml file as well?

@jakesylvestre
Copy link

Nevermind. #1229 is fixed.

hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
Add attributes to metadata XSD file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants