Skip to content

Instantly share code, notes, and snippets.

@rubeniskov
Created January 16, 2024 23:44
Show Gist options
  • Save rubeniskov/0f995070390355e0572670bb93bdb9f9 to your computer and use it in GitHub Desktop.
Save rubeniskov/0f995070390355e0572670bb93bdb9f9 to your computer and use it in GitHub Desktop.
SPZ Dollhouse Composition Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "composition.schema.json",
"additionalProperties": false,
"title": "DollhouseCompositionSchema",
"type": "object",
"properties": {
"version": {
"const": "0.0.1"
},
"extends": {
"oneOf": [
{
"type": "string",
"minLength": 3
},
{
"type": "array",
"items": {
"type": "string",
"minLength": 3
}
}
]
},
"name": {
"type": "string"
},
"fields": {
"$ref": "#/definitions/spz-fields"
},
"rules": {
"$ref": "#/definitions/spz-rules"
},
"order": {
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
}
},
"required": ["version", "fields", "name"],
"definitions": {
"spz-expr-vec2": {
"oneOf": [
{
"type": "array",
"items": {
"type": "number"
},
"minItems": 2,
"maxItems": 2
},
{
"type": "string"
},
{
"type": "number"
}
]
},
"spz-field-common": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"label": {
"type": "string",
"minLength": 1
},
"description": {
"type": "string"
}
},
"required": ["type"]
},
"spz-field-boolean": {
"allOf": [
{
"$ref": "#/definitions/spz-field-common"
}
],
"properties": {
"type": {
"const": "boolean"
},
"default": {
"type": "boolean"
}
}
},
"spz-field-number": {
"allOf": [
{
"$ref": "#/definitions/spz-field-common"
}
],
"properties": {
"type": {
"const": "number"
},
"min": {
"type": ["string", "number"]
},
"max": {
"type": ["string", "number"]
},
"step": {
"type": ["string", "number"]
},
"default": {
"type": ["string", "number"]
}
}
},
"spz-field-string": {
"allOf": [
{
"$ref": "#/definitions/spz-field-common"
}
],
"properties": {
"type": {
"const": "string"
},
"default": {
"type": "string",
"minLength": 1
}
}
},
"spz-field-enum": {
"allOf": [
{
"$ref": "#/definitions/spz-field-common"
}
],
"properties": {
"type": {
"const": "enum"
}
},
"oneOf": [
{
"properties": {
"options": {
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
},
"default": {
"type": "string",
"minLength": 1
}
}
},
{
"properties": {
"options": {
"type": "array",
"items": {
"type": "number"
}
},
"default": {
"type": "number"
}
}
},
{
"properties": {
"options": {
"type": "array",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string",
"minLength": 1
},
"value": {
"type": "number"
}
}
}
},
"default": {
"type": "number"
}
}
},
{
"properties": {
"options": {
"type": "array",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string",
"minLength": 1
},
"value": {
"type": "string",
"minLength": 1
}
}
}
},
"default": {
"type": "string",
"minLength": 1
}
}
}
],
"required": ["options"]
},
"spz-field-vec2": {
"allOf": [
{
"$ref": "#/definitions/spz-field-common"
}
],
"properties": {
"type": {
"const": "vec2"
},
"min": {
"$ref": "#/definitions/spz-expr-vec2"
},
"max": {
"$ref": "#/definitions/spz-expr-vec2"
},
"step": {
"$ref": "#/definitions/spz-expr-vec2"
},
"default": {
"$ref": "#/definitions/spz-expr-vec2"
}
}
},
"spz-field-polygon": {
"allOf": [
{
"$ref": "#/definitions/spz-field-common"
}
],
"properties": {
"type": {
"const": "polygon"
},
"default": {
"type": ["string", "number"]
}
}
},
"spz-fields": {
"type": "object",
"patternProperties": {
".{1,}": {
"oneOf": [
{
"$ref": "#/definitions/spz-field-boolean"
},
{
"$ref": "#/definitions/spz-field-number"
},
{
"$ref": "#/definitions/spz-field-string"
},
{
"$ref": "#/definitions/spz-field-enum"
},
{
"$ref": "#/definitions/spz-field-vec2"
},
{
"$ref": "#/definitions/spz-field-polygon"
}
]
}
}
},
"spz-rule-condition-change": {
"type": "object",
"properties": {
"type": {
"const": "change"
},
"field": {
"type": "string",
"minLength": 1
}
},
"required": ["type", "field"]
},
"spz-rule-action-set": {
"type": "object",
"properties": {
"type": {
"const": "set"
},
"field": {
"type": "string",
"minLength": 1
},
"value": {
"type": ["string", "number"]
}
},
"required": ["type", "field", "value"]
},
"spz-rule": {
"type": "object",
"properties": {
"conditions": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#/definitions/spz-rule-condition-change"
}
]
}
},
"actions": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#/definitions/spz-rule-action-set"
}
]
}
}
}
},
"spz-rules": {
"type": "array",
"items": {
"$ref": "#/definitions/spz-rule"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment