-
Notifications
You must be signed in to change notification settings - Fork 145
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
A URI with 'file' protocol is not handled as it should #252
Comments
The validator program you're using is just a test program, an example showing how to use the library. The simple If you use the library please write your own loader-script matching your infrastructure. To solve your problem validator library needs to be aware of the initial filename and path of the root-schema. As of today it isn't. It seems the python one is doing that. If you don't want to integrate the library in your program and just want to use an executable, why not stick with the python one? Otherwise, do not hesitate to suggest a patch for the example so that it does what you want. Btw. Isn't it very strange that the $id-tag contains a local file path? |
Thanks for responding.
When your system/application has no access to webservers then this is the only option. I assumed the I tried fix it in the code but a path is prefixed with |
No, it seems common usage to put http-addresses as $ids, even though nothing is looking up anything on the internet.
The library also does not support ../-relative path references. This might be related. Someone with time needs to take a look. |
My understanding is it when the |
The other schema-validators I saw all use callbacks for the user to handle the loading of additional schemas. So, it's up to the application handling the evaluation of the URL of $id. The problem you have is, that file:// is not (correctly) handled in the URL-class (probably). OK, but you are also using an example program which is not really designed to be generic. Maybe we can fix it there? In the loader callback, if the protocol is file, we remove the |
I can make a contribution trying to fixing it. BTW... I used file: # FetchContent added in CMake 3.11, downloads during the configure step
include(FetchContent)
# Import Json library.
FetchContent_Declare(
nlohmann-json
GIT_REPOSITORY https://github.com/nlohmann/json
GIT_TAG v3.8.0
)
# Adds nlohmann_json::nlohmann_json
FetchContent_MakeAvailable(nlohmann-json) Addition in main # Make it so our own packages are found and also the ones in the sub-module library.
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") |
Problem
When the
$id
is set to use a file protocol like in this casefile:///mnt/server/userdata/source/json-schemas/schema/customer.schema.json
an error is reported when other schema files are referenced for definitions.Directory Structure & Command
Files
Command
Both commands are executed when the current directory is the project root.
Python
C++ json-schema-validator
json-schema-validate schema/customer.schema.json < json/test.customer.json
Main Schema File
The file below references other files.
Those files can be found at this location.
Error Log
The text was updated successfully, but these errors were encountered: