Skip to content
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

Mime type for schema issues #540

Closed
dylanneild opened this issue Oct 29, 2018 · 6 comments
Closed

Mime type for schema issues #540

dylanneild opened this issue Oct 29, 2018 · 6 comments

Comments

@dylanneild
Copy link

Having a minor issue with validation against a Schema that's being served off of GitHub (using the raw URL retrieve):

Stack trace:
#0 /Users/dylan/GitHub/swimguide-web/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php(190): JsonSchema\Uri\UriRetriever->confirmMediaType(Object(JsonSchema\Uri\Retrievers\FileGetContents), 'https://raw.git...')
#1 /Users/dylan/GitHub/swimguide-web/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php(162): JsonSchema\Uri\UriRetriever->loadSchema('https://raw.git...')
#2 /Users/dylan/GitHub/swimguide-web/vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php(52): JsonSchema\Uri\UriRetriever->retrieve('https://raw.git...')
#3 /Users/dylan/GitHub/swimguide-web/vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php(115): JsonSchema\SchemaStorage->addSchema('https://raw.git...')
#4 /Users/dylan/GitHub/swimguide-web/vendor/justinrainb in /Users/dylan/GitHub/swimguide-web/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php on line 73

Basically, it looks like UriRetriever.php is demanding that the mime type of the schema document is application/schema+json. GitHub spits out text/plain.

Any flag or option possible to make UrlValidator ignore this and simply validate the schema syntactically?

@estahn
Copy link
Contributor

estahn commented Nov 6, 2018

@simplepanda This should be available in master now.

@dylanneild
Copy link
Author

@estahn Thanks. I'm seeing UriRetriever->addInvalidContentTypeEndpoint($endPoint) and the associated data structures but by default the invalid content type array only lists json-schema.org.

What's the best practice for adding a URL to this list other than editing the module directly? I can't see where to get access to the UriRetriever instance from my validator. I can see getUriRetriever() in the Factory class, but BaseConstraint->factory is a protected variable and there is no BaseConstruct->getFactory() - so getting access to the factory via my validator seems like it's not the intended practice here?

Fatal error: Uncaught Error: Cannot access protected property JsonSchema\Validator::$factory in /Users/dylan/GitHub/swimguide-web/resources/classes/RecML.php:85

@erayd
Copy link
Contributor

erayd commented Nov 7, 2018

@simplepanda Create a factory first, and then create a validator which uses it.

@dylanneild
Copy link
Author

All good. Tx.

erayd pushed a commit to erayd/json-schema that referenced this issue Jan 10, 2019
@DannyvdSluijs
Copy link
Collaborator

@dylanneild in an attempt to cleanup this repo we are trying to filter the issues and see which ones might be closed. Is it safe to assume this is a rather old issue, which sadly was left unanswered, and can be closed? Feel free to close it yourself with some comments if helpful.

Also this seem related to what I've been addressing in #709 where the HTTPS redirect returns a Content-Type header which is matched first instead of the last Content-Type: application/schema+json

@dylanneild
Copy link
Author

@DannyvdSluijs - The project I had using this code has been EOL'd for a while so I'm not sure what the current state of this is in terms of workarounds/production. If you feel it's closable, it can be closed.

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

No branches or pull requests

4 participants