From 25a93fc1aba1aff733b17f8f5062ec46d18d40d1 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Fri, 6 Nov 2020 18:51:34 +0100 Subject: [PATCH] Add JSON Schema for documentation and metadata --- README.md | 2 + public/schema/documentation.schema.json | 54 +++++++++++++++++++++++++ public/schema/meta.schema.json | 50 +++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 public/schema/documentation.schema.json create mode 100644 public/schema/meta.schema.json diff --git a/README.md b/README.md index 8ff70029..3db87cca 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,8 @@ The end result is a set of normalized HTML partials and two JSON files (index + More information about [scrapers](./docs/scraper-reference.md) and [filters](./docs/filter-reference.md) is available in the `docs` folder. +The [JSON Schema](https://json-schema.org/) for a documentation and its metadata is provided in https://github.com/freeCodeCamp/devdocs/tree/master/public/schema. + ## Available Commands The command-line interface uses [Thor](http://whatisthor.com). To see all commands and options, run `thor list` from the project's root. diff --git a/public/schema/documentation.schema.json b/public/schema/documentation.schema.json new file mode 100644 index 00000000..7fc5109e --- /dev/null +++ b/public/schema/documentation.schema.json @@ -0,0 +1,54 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$ref": "#/definitions/Documentation", + "definitions": { + "Documentation": { + "type": "object", + "properties": { + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/Entry" + } + }, + "types": { + "type": "array", + "items": { + "$ref": "#/definitions/Type" + } + } + }, + "required": ["entries", "types"] + }, + "Entry": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "path": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": ["name", "path", "type"] + }, + "Type": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "count": { + "type": "integer" + }, + "slug": { + "type": "string" + } + }, + "required": ["count", "name", "slug"] + } + } +} diff --git a/public/schema/meta.schema.json b/public/schema/meta.schema.json new file mode 100644 index 00000000..79e306ea --- /dev/null +++ b/public/schema/meta.schema.json @@ -0,0 +1,50 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$ref": "#/definitions/Doc", + "definitions": { + "Doc": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "slug": { + "type": "string" + }, + "type": { + "type": "string" + }, + "links": { + "$ref": "#/definitions/Links" + }, + "version": { + "type": "string" + }, + "release": { + "type": "string" + }, + "mtime": { + "type": "integer" + }, + "db_size": { + "type": "integer" + } + }, + "required": ["db_size", "mtime", "name", "release", "slug", "type"] + }, + "Links": { + "type": "object", + "properties": { + "home": { + "type": "string", + "format": "uri" + }, + "code": { + "type": "string", + "format": "uri" + } + }, + "required": ["code", "home"] + } + } +}