Closed dannylane closed 4 years ago
wouldnt it be better to use the "$schema" field as this is usually used for referencing the schema (usually an URL but file path is also fine i suppose)?
I thought about $schema
but I think that already has a meaning that is different from this.
From here
The $schema keyword is used to declare that a JSON fragment is actually a piece of JSON Schema.
The URL is normally the schema standard used, not to point to a specific schema instance.
We don't want to say these documents are schemas, rather point to a location of a schema instance.
I'm not tied to the name of the property, I could make it something more descriptive like _schemaLocation
or _schemaPath
.
I could even go with $schema
but I'm not sure that would be the right approach.
What do you think?
But the value in $schema is the URL to the JSON Schema schema :-): http://json-schema.org/draft/2019-09/schema
Got it, that makes sense.
Have updated the PR to look for $schema
v2.10
If the build still works than this should be soon available via the download link.
Use Case We have multiple JSON documents that share the same schema. Instead of always prompting the user to select the schema file it would be useful if the document could point to its own schema.
Change Proposed This PR allows a document to specify a
_schema
property at the root of the JSON containing a relative path to the schema. Relative paths are supported so"myschema.json"
and"../../schemas/myschema.json"
would be valid examples.As a side effect of this change I also set the
SaveAsync(bool saveSchema)
flag to use thesaveAs
flag so the schema is only persisted when the user is doing a 'Save As' operation