Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up$ref not detecting the schema #93
Comments
|
Hello, Can you provide the full code and error message please? Also, what version are you using? |
|
I made this simple schema: PersonSchema.json has a reference to AddressSchema.json PersonSchema.Json { AdderssSchema.json address{ } Both of them are in the same directory. Now I register this schema, using the vertx-json-schema-validator as follows: Register_Person.js var vertx = require('vertx'); var eb = vertx.eventBus; } Register_Address.js var vertx = require('vertx'); var eb = vertx.eventBus; var y = { } } And then, I send this for validation: Validate_Person.js: var vertx = require('vertx'); var eb = vertx.eventBus; var x = { This is the error I see: com.github.fge.jsonschema.exceptions.ProcessingException: URI is not absolute Thanks for helping me out. |
|
Also the vertx project use version 2.0.1. Thanks |
|
OK, first of all, you have a problem with the address schema (it is not valid). The problem here is that you don't load the Person schema via a URI. As such, when resolving the JSON Reference, you only get I don't know vertx but what is needed here is one of two things:
Do you have a link to vertx? |
|
This is the vertx project: https://github.com/campudus/vertx-json-schema-validator Is it not possible to access the schema, even if it lies in the same folder? I have seen some examples like here: http://spacetelescope.github.io/understanding-json-schema/structuring.html The pound symbol (#) refers to the current document, and then the slash (/) separated keys thereafter just traverse the keys in the objects in the document. Therefore, in our example "#/definitions/address" means: { "$ref": "definitions.json#/address" } Is this not supported in your project? Only absolute URI? Thanks. |
Well yes it is (I even have the best JSON Reference support out there, without boasting); but the URI has to point somewhere. And here it can't point anywhere, since to start with, Person does not have a URI. I cannot point to Address out of thin air! I have had a look at the vertx project in question and it loads schemas anonymously; the loading process therefore does not have a base URI to base itself upon. I can work with the module author so that a URI be produced and this way cross schema referencing will work; in the meantime you have to include all schemas into one I'm afraid. |
|
I am able to reference the schema if I provide an absolute file path. For now, I can work with that, like you explained in the other issue. And yes this project is really good and comprises of everything I need. :) After working on it, I realised the issues are with vertx project I am using and it only supports draft v3. :( Thanks. |
|
Hmwell, as I said, this vertx module supports everything this library supports, so v4 is supported. Anyway, can I close this issue? |
|
Yes please. Also, I mentioned on the vertx project thread, that the "id" property in my schema was causing issues and not the project. Thanks. |
|
OK! Yes, that is true that |
Hi,
I have two schema files in the same folder:
NS.json and NB.json.
NS.json has a reference to NB.json like this:
$ref = "NB.json#/network"
Everytime I try to validate the schema, it fails with a message "cannot dereference URI"
I tried giving the whole file path, but that fails as well. Is there any other way to reference a schema in seperate file, to another schema to make the validator work?
Thanks.