diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 03363ab..462aa15 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ test: - cp config.yaml.example config.yaml - apt update && apt install build-essential - pip install -r requirements.txt - - pip install -U sphinx sphinx-press-theme + - pip install -U sphinx sphinx-press-theme sphinx-jsonschema - sphinx-build -b html docs public rules: - if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH @@ -17,7 +17,7 @@ pages: - cp config.yaml.example config.yaml - apt update && apt install build-essential - pip install -r requirements.txt - - pip install -U sphinx sphinx-press-theme + - pip install -U sphinx sphinx-press-theme sphinx-jsonschema - sphinx-build -b html docs public artifacts: paths: diff --git a/docs/conf.py b/docs/conf.py index 9989199..100fe0d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,7 +16,8 @@ author = 'Bypass Censorship' # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc' + 'sphinx.ext.autodoc', + 'sphinx-jsonschema' ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs/index.rst b/docs/index.rst index 5794f42..0775650 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -29,6 +29,7 @@ Documentation Home tech/index.rst tech/conf.rst tech/resource.rst + tech/schemas.rst Indices and tables @@ -77,4 +78,4 @@ Supported by [*]_ .. rubric:: Footnotes -.. [*] Support received does not imply endorsement. \ No newline at end of file +.. [*] Support received does not imply endorsement. diff --git a/docs/tech/schemas.rst b/docs/tech/schemas.rst new file mode 100644 index 0000000..12e20d2 --- /dev/null +++ b/docs/tech/schemas.rst @@ -0,0 +1,8 @@ +Mirror List Formats +=================== + +Bypass Censorship Version 2 +--------------------------- + +.. jsonschema:: ../../schemas/bc2.json + diff --git a/schemas/bc2.json b/schemas/bc2.json new file mode 100644 index 0000000..d630f07 --- /dev/null +++ b/schemas/bc2.json @@ -0,0 +1,87 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "$id": "https://bypass.censorship.guide/schema/bc2.json", + "type": "object", + "title": "Bypass Censorship Version 2", + "required": [ + "sites", + "version" + ], + "properties": { + "sites": { + "$id": "#/properties/sites", + "type": "array", + "title": "The sites schema", + "additionalItems": true, + "items": { + "$id": "#/properties/sites/items", + "type": "object", + "title": "The items schema", + "required": [ + "available_alternatives", + "main_domain" + ], + "properties": { + "available_alternatives": { + "$id": "#/properties/sites/items/properties/available_alternatives", + "type": "array", + "title": "The available_alternatives schema", + "additionalItems": true, + "items": { + "$id": "#/properties/sites/items/properties/available_alternatives/items", + "type": "object", + "title": "The items schema", + "required": [ + "created_at", + "proto", + "type", + "updated_at", + "url" + ], + "properties": { + "created_at": { + "$id": "#/properties/sites/items/properties/available_alternatives/items/properties/created_at", + "type": "string", + "title": "The created_at schema" + }, + "proto": { + "$id": "#/properties/sites/items/properties/available_alternatives/items/properties/proto", + "type": "string", + "title": "The proto schema" + }, + "type": { + "$id": "#/properties/sites/items/properties/available_alternatives/items/properties/type", + "type": "string", + "title": "The type schema" + }, + "updated_at": { + "$id": "#/properties/sites/items/properties/available_alternatives/items/properties/updated_at", + "type": "string", + "title": "The updated_at schema" + }, + "url": { + "$id": "#/properties/sites/items/properties/available_alternatives/items/properties/url", + "type": "string", + "title": "The url schema" + } + }, + "additionalProperties": true + } + }, + "main_domain": { + "$id": "#/properties/sites/items/properties/main_domain", + "type": "string", + "title": "The main_domain schema" + } + }, + "additionalProperties": true + } + }, + "version": { + "$id": "#/properties/version", + "type": "string", + "title": "The version schema" + } + }, + "additionalProperties": true +} \ No newline at end of file