From d0c5945f8f7a85effb2f7b485dc9ac62f1407c20 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Mon, 6 Mar 2023 12:50:00 +0000 Subject: [PATCH] Super rough work in progress - Currently trying to see how the JSON schema would look like by writing it hand before attempting to then write a script to help write the same JSON to a file by looping over types --- .../utils/json-schema/manual-schema.json | 75 +++++++++++++++++++ .../utils/json-schema/schema-generator.js | 4 + .../utils/json-schema/test-package.json | 17 +++++ 3 files changed, 96 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/utils/json-schema/manual-schema.json create mode 100644 src/Umbraco.Web.UI.Client/utils/json-schema/schema-generator.js create mode 100644 src/Umbraco.Web.UI.Client/utils/json-schema/test-package.json diff --git a/src/Umbraco.Web.UI.Client/utils/json-schema/manual-schema.json b/src/Umbraco.Web.UI.Client/utils/json-schema/manual-schema.json new file mode 100644 index 0000000000..fbbec668e3 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/utils/json-schema/manual-schema.json @@ -0,0 +1,75 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Umbraco Package", + "description": "JSON schema for creating an Umbraco pacakge with different manifest types", + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the package" + }, + "version": { + "type": "string", + "description": "The version of the package" + }, + "extensions": { + "type": "array", + "description": "The extensions that are part of the package", + "minItems": 1, + "items": { + "type": "object", + "oneOf": [ + { "$ref": "#/definitions/rootManifest" } + ] + } + } + }, + "required": [ + "name", + "version", + "extensions" + ], + "additionalProperties": false, + "definitions": { + "manifesTypes":{ + "enum": [ + "collectionView", + "dashboardCollection", + "dashboard" + ] + }, + "rootManifest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the extension" + }, + "alias": { + "type": "string", + "description": "The alias of the extension" + }, + "weight": { + "type": "integer", + "description": "The weight of the extension" + }, + "type": { + "$ref": "#/definitions/manifesTypes" + }, + "js": { + "type": "string", + "description": "The path to the javascript file" + }, + "elementName": { + "type": "string", + "description": "The name of the HTML web component element" + }, + "meta": { + "type": "object", + "description": "NOTE: This object & properties change depending on the ENUM type of extension" + } + }, + "required": [ "name", "alias", "type", "js" ] + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/utils/json-schema/schema-generator.js b/src/Umbraco.Web.UI.Client/utils/json-schema/schema-generator.js new file mode 100644 index 0000000000..b016f64ca5 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/utils/json-schema/schema-generator.js @@ -0,0 +1,4 @@ +// TODO: Based on the manual schema as a guide +// Automate generation of the schema from looping over +// The types and properties found at /libs/extensions-registry/*.models.ts + diff --git a/src/Umbraco.Web.UI.Client/utils/json-schema/test-package.json b/src/Umbraco.Web.UI.Client/utils/json-schema/test-package.json new file mode 100644 index 0000000000..af6956c3af --- /dev/null +++ b/src/Umbraco.Web.UI.Client/utils/json-schema/test-package.json @@ -0,0 +1,17 @@ +{ + "$schema": "manual-schema.json", + "name": "My Package", + "version": "1.0.0", + "extensions": [ + { + "name": "My Extension", + "alias": "myextension", + "js": "myextension.js", + "type": "dashboard", + "weight": 10, + "meta": { + + } + } + ] +} \ No newline at end of file