Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal B for JSON Schema generation #20

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = tab
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{yml,yaml}]
indent_style = space
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ _site
.jekyll-metadata
.obsidian
vendor
node_modules/
.DS_Store
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"*.canvas": "json"
}
}
163 changes: 163 additions & 0 deletions jsoncanvas.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/JsonCanvas",
"definitions": {
"JsonCanvas": {
"type": "object",
"properties": {
"nodes": {
"type": "array",
"items": {
"$ref": "#/definitions/CanvasNode"
}
},
"edges": {
"type": "array",
"items": {
"$ref": "#/definitions/Edge"
}
}
},
"additionalProperties": false,
"description": "Top-level interface for the JSON Canvas Spec"
},
"CanvasNode": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"text",
"file",
"link",
"group"
]
},
"x": {
"type": "number"
},
"y": {
"type": "number"
},
"width": {
"type": "number"
},
"height": {
"type": "number"
},
"color": {
"$ref": "#/definitions/CanvasColor"
}
},
"required": [
"id",
"type",
"x",
"y",
"width",
"height"
],
"additionalProperties": false,
"description": "Base node interface for common attributes"
},
"CanvasColor": {
"anyOf": [
{
"type": "string"
},
{
"type": "number",
"const": 1
},
{
"type": "number",
"const": 2
},
{
"type": "number",
"const": 3
},
{
"type": "number",
"const": 4
},
{
"type": "number",
"const": 5
},
{
"type": "number",
"const": 6
}
],
"description": "Type for color, either a string for hex values or a number for preset colors"
},
"Edge": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"fromNode": {
"type": "string"
},
"fromSide": {
"type": "string",
"enum": [
"top",
"right",
"bottom",
"left"
],
"description": "Optional side of the node where the edge starts"
},
"fromEnd": {
"type": "string",
"enum": [
"none",
"arrow"
],
"description": "Optional style of the edge end"
},
"toNode": {
"type": "string"
},
"toSide": {
"type": "string",
"enum": [
"top",
"right",
"bottom",
"left"
],
"description": "Optional side of the node where the edge ends"
},
"toEnd": {
"type": "string",
"enum": [
"none",
"arrow"
],
"description": "Optional style of the edge end"
},
"color": {
"$ref": "#/definitions/CanvasColor"
},
"label": {
"type": "string",
"description": "Optional label for the edge"
}
},
"required": [
"id",
"fromNode",
"toNode"
],
"additionalProperties": false,
"description": "Edge interface for connections between nodes"
}
}
}
Loading