JSON Schema editing can't find external reference

I am editing JSON schema files in the same directory, but they don't seem to be able to reference other schemas in the same directory. For example:

activity.schema.json:
{"$schema" : "http://json-schema.org/draft-04/schema#","definitions" : {
"Activity" : {"type" : "object","properties" :
  {"Notes" : {"type" : "array","items" : {"type" : "object","$ref" : "./note.schema.json/definitions/Note"}}
}}}

note.schema.json:
{"$schema" : "http://json-schema.org/draft-04/schema#","definitions" : {
"Note" : {"type" : "object","properties" : {
  "Body" : {"type" : "string"}}
}}}

Tried it without the extensions and without "./"

 

My version:

IntelliJ IDEA 2017.1
Build #IU-171.3780.107, built on March 22, 2017
JRE: 1.8.0_112-release-736-b13 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 7 6.1

0
2 comments

Please try

"$ref" : "note.schema.json/definitions/Note"

it should work

Note that you need registering all your schemes in Settings | Languages & Frameworks | Schemas and DTDs | JSON Schema, references won't work otherwise

0
Avatar
Permanently deleted user

Thank you.  Sorry I found the issue later that night, but couldn't find this post, to reply.

The issue was three fold,

0.  As you said, the schema's files first had to be registered.  I won't swear to it, but I think it recognized edits of the files without having to restart or readd the files.  

1. the reference was not to a fragment -- it was missing the "#", the corrected $ref was "note.schema.json#/definitions/Note".  

2. the schema's did not internally define their id, i.e., there was no id specified in note.schema.json.  Corrected this by adding the id.  All the examples had the id ending with #.  I was going to play around later to see if that was a requirement of json its has no effect per my reading of the uri specs..

0

Please sign in to leave a comment.