Bug 494111 - Validate JSON file with JSON Schema
Summary: Validate JSON file with JSON Schema
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.json (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.8.2   Edit
Assignee: Snjezana Peco CLA Friend
QA Contact: Nick Sandonato CLA Friend
URL:
Whiteboard: RHT
Keywords:
Depends on: 489452 505929
Blocks:
  Show dependency tree
 
Reported: 2016-05-20 04:27 EDT by Angelo ZERR CLA Friend
Modified: 2017-01-10 07:05 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Angelo ZERR CLA Friend 2016-05-20 04:27:15 EDT
It's a very big task, but it should be fantastic if WTP Validator could validate JSON file by using JSON Schema.

To do that:

 * JSONSchemaDocument should support the full specification of JSON Schema.
 * minimal-json should be improved to collect line, column or perhaps we could use IJSONDocument to validate it with JSON Schema.
Comment 1 Snjezana Peco CLA Friend 2016-10-19 19:43:10 EDT
The patch includes the following:

- a new preference - Window>Preferences>JSON>JSON Files>Validation>Enable Schema Validation

The preference is false by default because this is a big change that could break the workspace.

- a schema validation can be declared by adding the '$schema' property.
You can, for instance, create a schema file as follows: 

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "test": {}
    },
    "patternProperties": {
        "^(/[^/]+)+$": {}
    },
    "additionalProperties": false,
    "required": [ "test" ]
}

and use it in the following way:

{
	"$schema": "file:///C:/Users/Snjeza/test.json",
	"test":{}
}

- validate the schema according to http://json-schema.org/latest/json-schema-validation.html
Comment 2 Snjezana Peco CLA Friend 2016-10-19 19:59:58 EDT
Gerrit change: https://git.eclipse.org/r/83559