Skip to content

Commit

Permalink
add first draft of schema
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoIeni committed Aug 21, 2020
1 parent ed51fe2 commit b331678
Show file tree
Hide file tree
Showing 5 changed files with 331 additions and 0 deletions.
178 changes: 178 additions & 0 deletions src/schemas/bindingOverrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Binding Overrides",
"type": "object",
"additionalProperties": false,
"definitions": {
"bindingOverride": {
"type": "object",
"additionalProperties": false,
"properties": {
"keys": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "string"
}
]
},
"position": {
"type": "integer"
},
"name": {
"type": "string"
},
"type": {
"$ref": "definitions.json#/definitions/bindingType"
},
"command": {
"$ref": "definitions.json#/definitions/command"
},
"commands": {
"$ref": "definitions.json#/definitions/commands"
},
"args": {
"$ref": "definitions.json#/definitions/args"
},
"bindings": {
"$ref": "definitions.json#/definitions/bindings"
}
},
"required": [
"keys"
],
"allOf": [
{
"if": {
"properties": {
"position": {
"minimum": 0
}
}
},
"then": {
"required": [
"name",
"type"
]
}
},
{
"if": {
"anyOf": [
{
"properties": {
"type": {
"const": "command"
}
}
},
{
"allOf": [
{
"properties": {
"type": {
"const": "transient"
}
},
"not": {
"required": [
"commands"
]
}
}
]
}
]
},
"then": {
"required": [
"command"
]
}
},
{
"if": {
"anyOf": [
{
"properties": {
"type": {
"const": "commands"
}
}
},
{
"allOf": [
{
"properties": {
"type": {
"const": "transient"
}
},
"not": {
"required": [
"command"
]
}
}
]
}
]
},
"then": {
"required": [
"commands"
]
}
},
{
"if": {
"properties": {
"type": {
"const": "commands"
}
}
},
"then": {
"properties": {
"args": {
"type": "array"
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "bindings"
}
}
},
"then": {
"required": [
"bindings"
]
}
}
]
}
},
"properties": {
"$schema": {
"type": "string",
"description": "uri to schema"
},
"bindingOverrides": {
"type": "array",
"items": {
"$ref": "#/definitions/bindingOverride"
}
}
}
}
21 changes: 21 additions & 0 deletions src/schemas/bindings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Bindings",
"type": "object",
"additionalProperties": false,
"properties": {
"$schema": {
"type": "string",
"description": "uri to schema"
},
"bindings": {
"type": "array",
"items": {
"$ref": "definitions.json#/definitions/bindingItem"
}
}
},
"required": [
"bindings"
]
}
77 changes: 77 additions & 0 deletions src/schemas/definitions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Bindings",
"type": "object",
"additionalProperties": false,
"definitions": {
"bindingItem": {
"type": "object",
"additionalProperties": false,
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"$ref": "definitions.json#/definitions/bindingType"
},
"command": {
"$ref": "definitions.json#/definitions/command"
},
"commands": {
"$ref": "definitions.json#/definitions/commands"
},
"args": {
"$ref": "definitions.json#/definitions/args"
},
"bindings": {
"$ref": "definitions.json#/definitions/bindings"
}
},
"required": [
"key",
"name",
"type"
]
},
"bindingType": {
"type": "string",
"enum": [
"command",
"commands",
"bindings",
"transient"
]
},
"command": {
"type": "string"
},
"commands": {
"type": "array",
"items": {
"type": "string"
}
},
"args": {
"anyOf": [
{
"type": "object"
},
{
"type": "array",
"items": {
"type": "object"
}
}
]
},
"bindings": {
"type": "array",
"items": {
"$ref": "definitions.json#/definitions/bindingItem"
}
}
}
}
18 changes: 18 additions & 0 deletions src/schemas/examples/bindingOverrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "../bindingOverrides.json",
"bindingOverrides": [
{
"keys": "g",
"name": "Go...",
"type": "bindings",
"bindings": [
{
"key": "s",
"name": "Go to",
"type": "command",
"command": "workbench.action.gotoLine"
}
]
}
]
}
37 changes: 37 additions & 0 deletions src/schemas/examples/bindings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "../bindings.json",
"bindings": [
{
"key": "f",
"name": "File...",
"type": "bindings",
"bindings": [
{
"key": "f",
"name": "Open file",
"type": "command",
"command": "workbench.action.files.openFileFolder"
},
{
"key": "i",
"name": "Indentation...",
"type": "bindings",
"bindings": [
{
"key": "i",
"name": "Change indentation",
"type": "command",
"command": "changeEditorIndentation"
},
{
"key": "d",
"name": "Detect indentation",
"type": "command",
"command": "editor.action.detectIndentation"
}
]
}
]
}
]
}

0 comments on commit b331678

Please sign in to comment.