-
Notifications
You must be signed in to change notification settings - Fork 52
Cannot use local JSON file #46
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
Comments
In order to refer external schema you need to provide it to validator. It works automatically for HTTP-accessible resources, but for local files and any other identifiers it is manual. Here is an example what you likely need to do:
Another example in test suite. It is quite common to refer to local resources by Just be aware that |
@vearutop thanks for your reply. The solution you presented works but if i want to have multiple defintions files for each part of my application it's easier to use my current workaround (i think).
and then in my code i do:
For now this works and lets everyone use their definitions without the need for validators. Your solution with |
Hi! Absolutely. And give attention to "id" property which declares a base "URL" against which related $ref "URL"s are resolved. You do not want BTW due to hi-load i use |
tagged @massadm I agree that totally makes sense performance-wise. |
Please note that |
@massadm thanks, the main use-case is for absolute paths |
@massadm oh, indeed, I didn't even think that |
Uh oh!
There was an error while loading. Please reload this page.
I'm using php-json-schema to validate the responses of my server endpoints.
I'm testing it locally and i can't seem to find a way to reference another schma with definitions.
My endpoint schema validator has the following:
"tasks": { "$ref": "definitions.json#/taskDefinition"},
The other file called definitions.json has the following:
It always returns an error:
I tried using
id: "file://"
, and a bunch of other things but didn't found a way to make it work.I changed the code of the
BasicFetcher.php
so that the$url
is the absolute path of thedefinitions.json
file and it worked, but clearly it's not a solution for this problem.PS: Searching on google for similar problem got me on this issue of another project
The text was updated successfully, but these errors were encountered: