diff --git a/jsoncanvas.schema.json b/jsoncanvas.schema.json index 4742ed3..62bf77a 100644 --- a/jsoncanvas.schema.json +++ b/jsoncanvas.schema.json @@ -1,41 +1,31 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "default": { - "edges": [], - "nodes": [] - }, - "properties": { - "required": true, - "edges": { - "items": { - "$ref": "#/definitions/JSONCanvasEdge" - }, - "type": "array" - }, - "nodes": { - "items": { - "$ref": "#/definitions/JSONCanvasNode" - }, - "type": "array" - } - }, + "$ref": "#/definitions/JsonCanvas", "definitions": { - "JSONCanvasColor": { - "anyOf": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/JSONCanvasColorPreset" + "JsonCanvas": { + "type": "object", + "properties": { + "required": { + "type": "boolean", + "const": true + }, + "edges": { + "type": "array", + "items": { + "$ref": "#/definitions/JSONCanvasEdge" + } + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/JSONCanvasNode" + } } - ] - }, - "JSONCanvasColorPreset": { - "enum": [1, 2, 3, 4, 5, 6], - "type": "number" + }, + "additionalProperties": {} }, "JSONCanvasEdge": { - "additionalProperties": false, + "type": "object", "properties": { "color": { "$ref": "#/definitions/JSONCanvasColor" @@ -62,38 +52,89 @@ "$ref": "#/definitions/JSONCanvasEdgeSide" } }, - "required": ["id", "fromNode", "toNode"], - "type": "object" + "required": [ + "fromNode", + "id", + "toNode" + ], + "additionalProperties": false }, - "JSONCanvasEdgeEnd": { - "enum": ["none", "arrow"], - "type": "string" + "JSONCanvasColor": { + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/definitions/JSONCanvasColorPreset" + } + ] + }, + "JSONCanvasColorPreset": { + "type": "number", + "enum": [ + 1, + 2, + 3, + 4, + 5, + 6 + ] }, "JSONCanvasEdgeSide": { - "enum": ["top", "right", "bottom", "left"], - "type": "string" + "type": "string", + "enum": [ + "top", + "right", + "bottom", + "left" + ] }, - "JSONCanvasFileNode": { - "additionalProperties": false, + "JSONCanvasEdgeEnd": { + "type": "string", + "enum": [ + "none", + "arrow" + ] + }, + "JSONCanvasNode": { + "anyOf": [ + { + "$ref": "#/definitions/JSONCanvasNodeType" + }, + { + "$ref": "#/definitions/JSONCanvasTextNode" + }, + { + "$ref": "#/definitions/JSONCanvasFileNode" + }, + { + "$ref": "#/definitions/JSONCanvasLinkNode" + }, + { + "$ref": "#/definitions/JSONCanvasGroupNode" + } + ] + }, + "JSONCanvasNodeType": { + "type": "object", "properties": { "color": { "$ref": "#/definitions/JSONCanvasColor" }, - "file": { - "type": "string" - }, "height": { "type": "number" }, "id": { "type": "string" }, - "subpath": { - "type": "string" - }, "type": { - "const": "file", - "type": "string" + "type": "string", + "enum": [ + "text", + "file", + "link", + "group" + ] }, "width": { "type": "number" @@ -105,19 +146,19 @@ "type": "number" } }, - "required": ["file", "height", "id", "type", "width", "x", "y"], - "type": "object" + "required": [ + "height", + "id", + "type", + "width", + "x", + "y" + ], + "additionalProperties": false }, - "JSONCanvasGroupNode": { - "additionalProperties": false, + "JSONCanvasTextNode": { + "type": "object", "properties": { - "background": { - "type": "string" - }, - "backgroundStyle": { - "enum": ["cover", "ratio", "repeat"], - "type": "string" - }, "color": { "$ref": "#/definitions/JSONCanvasColor" }, @@ -127,12 +168,12 @@ "id": { "type": "string" }, - "label": { + "text": { "type": "string" }, "type": { - "const": "group", - "type": "string" + "type": "string", + "const": "text" }, "width": { "type": "number" @@ -144,27 +185,38 @@ "type": "number" } }, - "required": ["height", "id", "type", "width", "x", "y"], - "type": "object" + "required": [ + "height", + "id", + "text", + "type", + "width", + "x", + "y" + ], + "additionalProperties": false }, - "JSONCanvasLinkNode": { - "additionalProperties": false, + "JSONCanvasFileNode": { + "type": "object", "properties": { "color": { "$ref": "#/definitions/JSONCanvasColor" }, + "file": { + "type": "string" + }, "height": { "type": "number" }, "id": { "type": "string" }, - "type": { - "const": "link", + "subpath": { "type": "string" }, - "url": { - "type": "string" + "type": { + "type": "string", + "const": "file" }, "width": { "type": "number" @@ -176,30 +228,19 @@ "type": "number" } }, - "required": ["height", "id", "type", "url", "width", "x", "y"], - "type": "object" + "required": [ + "file", + "height", + "id", + "type", + "width", + "x", + "y" + ], + "additionalProperties": false }, - "JSONCanvasNode": { - "anyOf": [ - { - "$ref": "#/definitions/JSONCanvasNodeType" - }, - { - "$ref": "#/definitions/JSONCanvasTextNode" - }, - { - "$ref": "#/definitions/JSONCanvasFileNode" - }, - { - "$ref": "#/definitions/JSONCanvasLinkNode" - }, - { - "$ref": "#/definitions/JSONCanvasGroupNode" - } - ] - }, - "JSONCanvasNodeType": { - "additionalProperties": false, + "JSONCanvasLinkNode": { + "type": "object", "properties": { "color": { "$ref": "#/definitions/JSONCanvasColor" @@ -211,7 +252,10 @@ "type": "string" }, "type": { - "enum": ["text", "file", "link", "group"], + "type": "string", + "const": "link" + }, + "url": { "type": "string" }, "width": { @@ -224,12 +268,31 @@ "type": "number" } }, - "required": ["id", "type", "x", "y", "width", "height"], - "type": "object" + "required": [ + "height", + "id", + "type", + "url", + "width", + "x", + "y" + ], + "additionalProperties": false }, - "JSONCanvasTextNode": { - "additionalProperties": false, + "JSONCanvasGroupNode": { + "type": "object", "properties": { + "background": { + "type": "string" + }, + "backgroundStyle": { + "type": "string", + "enum": [ + "cover", + "ratio", + "repeat" + ] + }, "color": { "$ref": "#/definitions/JSONCanvasColor" }, @@ -239,12 +302,12 @@ "id": { "type": "string" }, - "text": { + "label": { "type": "string" }, "type": { - "const": "text", - "type": "string" + "type": "string", + "const": "group" }, "width": { "type": "number" @@ -256,8 +319,15 @@ "type": "number" } }, - "required": ["height", "id", "text", "type", "width", "x", "y"], - "type": "object" + "required": [ + "height", + "id", + "type", + "width", + "x", + "y" + ], + "additionalProperties": false } } }