Created
September 15, 2023 00:15
-
-
Save lmcintyre/9fd2d92dd717f08800503f8710eaf236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"$ref": "#/definitions/Sheet", | |
"type": "object", | |
"additionalProperties": false, | |
"properties": { | |
"sheet": { | |
"$ref": "#/definitions/Sheet" | |
} | |
}, | |
"definitions": { | |
"Sheet": { | |
"title": "Sheet", | |
"type": "object", | |
"additionalProperties": false, | |
"properties": { | |
"name": { | |
"description": "The name of the sheet.", | |
"type": "string" | |
}, | |
"displayField": { | |
"description": "The name of the field to use for displaying a reference to this sheet in a cell. Useful only for UI-based consumption.", | |
"type": "string" | |
}, | |
"fields": { | |
"description": "The fields of the sheet. Sheets must specify all fields present in the EXH file for that sheet, meaning they all must have at least one field.", | |
"type": "array", | |
"minItems": 1, | |
"items": { | |
"$ref": "#/definitions/Field" | |
} | |
}, | |
"comment": { | |
"type": "string" | |
} | |
}, | |
"anyOf": [ | |
{ "required": ["name", "fields"] }, | |
{ "required": ["name", "fields" ,"comment"] }, | |
{ "required": ["name", "displayField", "fields"] }, | |
{ "required": ["name", "displayField", "fields", "comment"] } | |
] | |
}, | |
"Field": { | |
"description": "A field in a sheet. Describes one or more columns.", | |
"title": "Field", | |
"type": "object", | |
"additionalProperties": false, | |
"properties": { | |
"name": { | |
"description": "The name of the field.", | |
"type": "string" | |
}, | |
"type": { | |
"description": "Defines the type of the field. Scalar should be assumed by default, and has no meaning. The only other type that affects parsing is array.", | |
"type": "string", | |
"enum": ["scalar", "array", "icon", "modelId", "color"] | |
}, | |
"count": { | |
"description": "Only valid for array types. Defines the number of elements in the array.", | |
"type": "integer" | |
}, | |
"link": { | |
"description": "Only valid for scalar types. Defines the link to another sheet.", | |
"$ref": "#/definitions/Link" | |
}, | |
"fields": { | |
"description": "Only valid for array types. Defines the fields of the array. Fields are not available on non-array types because grouping non-array types is meaningless. They should be defined at the top-level.", | |
"type": "array", | |
"minItems": 0, | |
"items": { | |
"$ref": "#/definitions/Field" | |
} | |
}, | |
"comment": { | |
"type": "string" | |
} | |
}, | |
"allOf": [ | |
{ | |
"description": "If the field is an array, it must have a count and fields.", | |
"oneOf": [ | |
{ | |
"description": "Arrays require count and fields keys.", | |
"if": { | |
"properties": { | |
"type": { | |
"const": "array" | |
} | |
} | |
}, | |
"then": { | |
"required": ["count", "fields"] | |
} | |
}, | |
{ | |
"description": "Non-arrays may not have count or fields keys.", | |
"if": { | |
"anyOf": [ | |
{ | |
"description": "Type is not array.", | |
"not": { | |
"properties": { | |
"type": { | |
"const": "array" | |
} | |
} | |
} | |
}, | |
{ | |
"description": "Type is not defined (scalar).", | |
"not": { | |
"required": ["type"] | |
} | |
} | |
] | |
}, | |
"then": { | |
"allOf": [ | |
{ | |
"not": { | |
"required": ["count", "fields"] | |
} | |
}, | |
{ | |
"not": { | |
"required": ["count"] | |
} | |
}, | |
{ | |
"not": { | |
"required": ["fields"] | |
} | |
} | |
] | |
} | |
} | |
] | |
}, | |
{ | |
"description": "Fields with a link must not have sub-fields.", | |
"if": { | |
"required": ["link"] | |
}, | |
"then": { | |
"not": { | |
"required": ["fields"] | |
} | |
} | |
}, | |
{ | |
"description": "Fields with a count must be an array.", | |
"if": { | |
"required": ["count"] | |
}, | |
"then": { | |
"required": ["type"], | |
"properties": { | |
"type": { | |
"const": "array" | |
} | |
} | |
} | |
} | |
] | |
}, | |
"Link": { | |
"type": "object", | |
"additionalProperties": false, | |
"properties": { | |
"target": { | |
"type": "array", | |
"items": { | |
"type": "string" | |
} | |
}, | |
"condition": { | |
"$ref": "#/definitions/Condition" | |
} | |
}, | |
"required": [ | |
"target" | |
], | |
"title": "Link" | |
}, | |
"Condition": { | |
"type": "object", | |
"additionalProperties": false, | |
"properties": { | |
"switch": { | |
"type": "string" | |
}, | |
"cases": { | |
"type": "object", | |
"additionalProperties": { | |
"type": "array", | |
"items": { | |
"type": "integer" | |
} | |
} | |
} | |
}, | |
"required": ["cases", "switch"], | |
"title": "Condition" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment