Adding ui-json schemas (#188)

This commit is contained in:
Daan Verstraten
2023-10-24 00:31:52 +02:00
committed by GitHub
parent 6643219664
commit 325b02b2e3
17 changed files with 1875 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
{
"title": "Anchor",
"description": "An anchor is a reference to an element in the UI.",
"type": "string",
"enum": ["bottom", "bottom_left", "bottom_right", "bottom_middle", "center", "left", "left_middle", "right", "right_middle", "top", "top_left", "top_right", "top_middle"]
}

View File

@@ -0,0 +1,5 @@
{
"title": "Any",
"description": "An any value.",
"type": ["array", "boolean", "integer", "number", "object", "string"]
}

View File

@@ -0,0 +1,14 @@
{
"title": "Boolean",
"description": "A boolean value.",
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"$ref": "./item_ref.json"
}
],
"examples": ["true", "false", "$variable", "($variable)"]
}

View File

@@ -0,0 +1,40 @@
{
"definitions": {
"color_item": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"oneOf": [
{
"type": "string",
"description": "A variable",
"$ref": "./item_ref.json"
},
{
"type": "array",
"description": "A size with width and height.",
"items": [
{
"title": "Red",
"type": "string",
"description": "A variable",
"$ref": "#/definitions/color_item"
},
{
"title": "Green",
"type": "string",
"description": "A variable",
"$ref": "#/definitions/color_item"
},
{
"title": "Blue",
"type": "string",
"description": "A variable",
"$ref": "#/definitions/color_item"
}
]
}
]
}

View File

@@ -0,0 +1,14 @@
{
"title": "Integer",
"description": "A integer value.",
"oneOf": [
{
"type": "integer"
},
{
"type": "string",
"$ref": "./item_ref.json"
}
],
"examples": [0, 1, 2, "$variable", "($variable)"]
}

View File

@@ -0,0 +1,35 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"anyOf": [
{
"title": "Item reference",
"description": "A reference to an item: using the following syntax: [element_name]@[namespace_reference].[element_name_reference]",
"type": "string",
"examples": ["button@minecraft", "button@minecraft:ui"],
"pattern": "^[a-zA-Z0-9_]*@[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)?$"
},
{
"title": "Item reference",
"description": "A reference to an item: using the following syntax: [namespace_reference].[element_name_reference]",
"type": "string",
"examples": ["button@minecraft", "button@minecraft:ui"],
"pattern": "[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)?$"
},
{
"title": "Variable reference",
"description": "A variable is a reference to a value that can be used in the UI.",
"type": "string",
"anyOf": [
{
"pattern": "^\\$[a-zA-Z0-9_]+$"
},
{
"pattern": "^#[a-zA-Z0-9_]+$"
},
{
"pattern": "^\\(.*\\)$"
}
]
}
]
}

View File

@@ -0,0 +1,14 @@
{
"title": "Number",
"description": "A Number value.",
"oneOf": [
{
"type": "number"
},
{
"type": "string",
"$ref": "./item_ref.json"
}
],
"examples": [0, 1, 2, "$variable", "($variable)"]
}

View File

@@ -0,0 +1,51 @@
{
"title": "Size",
"description": "The size of the element.",
"definitions": {
"size_coord": {
"title": "Size Coord",
"description": "A size coordinate.",
"oneOf": [
{
"type": "string",
"enum": ["default", "fill"]
},
{
"type": "string",
"pattern": "^[0-9]+(px|%)$"
},
{
"type": "integer",
"minimum": 0
}
],
"examples": ["default", "fill", "100px", "100%", "100% - 2px"]
}
},
"oneOf": [
{
"type": "string",
"description": "A variable",
"$ref": "./item_ref.json"
},
{
"type": "array",
"description": "A size with width and height.",
"items": [
{
"title": "Width",
"type": "string",
"description": "A variable",
"$ref": "#/definitions/size_coord"
},
{
"title": "Height",
"type": "string",
"description": "A variable",
"$ref": "#/definitions/size_coord"
}
]
}
],
"examples": ["default", "fill", ["100%", "100%"]]
}

View File

@@ -0,0 +1,5 @@
{
"title": "String",
"description": "A string value.",
"anyOf": [{ "type": "string" }, { "type": "string", "$ref": "./item_ref.json" }]
}

View File

@@ -0,0 +1,20 @@
{
"title": "Variable",
"description": "A variable is a reference to a value that can be used in the UI.",
"type": "string",
"anyOf": [
{
"type": "string",
"pattern": "^\\$[a-zA-Z0-9_]+$"
},
{
"type": "string",
"pattern": "^#[a-zA-Z0-9_]+$"
},
{
"type": "string",
"pattern": "^\\(.*\\)$"
}
],
"examples": ["$variable", "($variable)"]
}

View File

@@ -0,0 +1,47 @@
{
"definitions": {
"size_coord": {
"oneOf": [
{
"type": "string",
"enum": ["default", "fill"]
},
{
"type": "string",
"pattern": "^[0-9]+(px|%)$"
},
{
"type": "integer",
"minimum": 0
}
],
"examples": ["default", "fill", "100px", "100%", "100% - 2px"]
}
},
"oneOf": [
{
"type": "string",
"description": "A variable",
"$ref": "./item_ref.json"
},
{
"type": "array",
"description": "A size with width and height.",
"items": [
{
"title": "Width",
"type": "string",
"description": "A variable",
"$ref": "#/definitions/size_coord"
},
{
"title": "Height",
"type": "string",
"description": "A variable",
"$ref": "#/definitions/size_coord"
}
]
}
],
"examples": ["default", "fill", ["100%", "100%"]]
}

View File

@@ -0,0 +1,55 @@
{
"definitions": {
"size_coord": {
"oneOf": [
{
"type": "string",
"enum": ["default", "fill"]
},
{
"type": "string",
"pattern": "^[0-9]+(px|%)$"
},
{
"type": "integer",
"minimum": 0
}
],
"examples": ["default", "fill", "100px", "100%", "100% - 2px"]
}
},
"oneOf": [
{
"type": "string",
"description": "A variable",
"$ref": "./item_ref.json"
},
{
"type": "array",
"description": "A size with width and height.",
"items": [
{
"title": "X",
"description": "A variable",
"$ref": "#/definitions/size_coord"
},
{
"title": "Y",
"description": "A variable",
"$ref": "#/definitions/size_coord"
},
{
"title": "Width",
"description": "A variable",
"$ref": "#/definitions/size_coord"
},
{
"title": "Height",
"description": "A variable",
"$ref": "#/definitions/size_coord"
}
]
}
],
"examples": ["default", "fill", ["100%", "100%"]]
}