Open javadev686 opened 10 years ago
I am facing same issue. Any resolution?
Bump
Also seeing the same issue :(
Aha - there's a good workaround.
In your target schema, you need to add an id property that documents the path to the file.
So, in the above example, you would modify commonsMixed.json
to contain its own relative path to the file, within a folder on your class path like so
{
"$schema" : "http://json-schema.org/draft-04/schema" ,
"id": "resource:/path/within/your/maven/resources/folder/commonsMixed.json#",
"definitions": {
... ( properties go here)
}
}
If you've got a maven project (like me) this is the path to the schema file within your src/main/resources
folder.
It's a bit annoying but it will get you through. Hope that helps!
-------------sampleJosnSchema.json--------------- { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "AccountUpdateRequest": { "$ref": "commonsMixed.json#/definitions/d_Locales" } } }
------------------commonsMixed.json---------------------- { "definitions": { "d_NonZeroLengthString": { "description": "Non Zero Length String", "type": "string", "minLength": 1 }, "d_Locales": { "$ref": "#/definitions/d_NonZeroLengthString", "enum": [ "en", "es" ] } } }
---------------sampleJson.json--------- { "AccountUpdateRequest": "es" }
------used maven dependecy-----
on validating sampleJson.json with sampleJosnSchema.json i am getting below error com.github.fge.jsonschema.core.exceptions.ProcessingException: fatal: URI "commonsMixed.json#" is not absolute
Note : sampleJosnSchema.json and commonsMixed.json are at same location for example desktop
I found similar issue reported in https://github.com/fge/json-schema-validator/issues/94 but how can some one expect to put hard coded path in json schema. i believe there must be some other work around atleast.
can some one please help me.