From cd27815b2eaa79690b4876dfc2a2ba8f943da912 Mon Sep 17 00:00:00 2001 From: Daniel Kluge Date: Thu, 23 Jun 2022 16:05:41 +0200 Subject: [PATCH] Add JSON schema (close #1) --- list.schema.json | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 list.schema.json diff --git a/list.schema.json b/list.schema.json new file mode 100644 index 0000000..4532483 --- /dev/null +++ b/list.schema.json @@ -0,0 +1,85 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://c0ntroller.de/content/list.schema.json", + "title": "Content List", + "description": "A list of projects and diaries for my homepage.", + "type": "array", + "items": { + "anyOf": [ + { "$ref": "#/$defs/project" }, + { "$ref": "#/$defs/diary" } + ] + }, + "$defs": { + "content": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["project", "diary"] + }, + "name": { + "type": "string", + "pattern": "^[a-z0-9-_]+$" + }, + "short_desc": { + "type": "string", + "maxLength": 100 + }, + "desc": { + "type": "array", + "items": { + "type": "string" + } + }, + "more": { + "type": "string", + "format": "uri" + }, + "repo": { + "type": "string", + "format": "uri" + } + }, + "required": ["type", "name", "short_desc", "desc"] + }, + "project": { + "type": "object", + "allOf": [ + { "$ref": "#/$defs/content" } + ], + "properties": { + "type": { + "const": "project" + } + } + }, + "diary": { + "type": "object", + "allOf": [ + { "$ref": "#/$defs/content" } + ], + "properties": { + "type": { + "const": "diary" + }, + "entries": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "required": ["title", "filename"] + } + } + }, + "required": ["entries"] + } + } + } \ No newline at end of file