Skip to content
Snippets Groups Projects
Commit 917646b0 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

try using redoc and a validator

parent fd9240e4
Branches
No related tags found
1 merge request!293Design document for replication and recovery system
sphinx sphinx
sphinxcontrib-openapi sphinxcontrib-redoc
...@@ -39,7 +39,17 @@ release = '0.0' ...@@ -39,7 +39,17 @@ release = '0.0'
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones. # ones.
extensions = [ extensions = [
"sphinxcontrib.openapi", "sphinxcontrib.redoc",
]
# Configure redoc
redoc = [
{
'name': 'ZKAPAuthorizer Backup/Recovery API',
'page': 'designs/backup-recovery-openapi',
'spec': '../../src/_zkapauthorizer/backup-recovery.yaml',
'embed': True,
},
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
...@@ -86,7 +96,7 @@ html_theme = 'alabaster' ...@@ -86,7 +96,7 @@ html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = []
# Custom sidebar templates, must be a dictionary that maps document names # Custom sidebar templates, must be a dictionary that maps document names
# to template names. # to template names.
......
...@@ -205,7 +205,7 @@ Backup operations resume as usual from this point using the existing on-grid sta ...@@ -205,7 +205,7 @@ Backup operations resume as usual from this point using the existing on-grid sta
External Interfaces External Interfaces
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
.. openapi:: ./backup-recovery.yaml See the `OpenAPI specification <backup-recovery-openapi.html>`_.
Data Integrity Data Integrity
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
......
...@@ -3,3 +3,4 @@ fixtures ...@@ -3,3 +3,4 @@ fixtures
testtools testtools
hypothesis hypothesis
pyflakes pyflakes
openapi_spec_validator
...@@ -58,7 +58,7 @@ install_requires = ...@@ -58,7 +58,7 @@ install_requires =
colorama colorama
[options.extras_require] [options.extras_require]
test = coverage; fixtures; testtools; hypothesis test = coverage; fixtures; testtools; hypothesis; openapi_spec_validator
[flake8] [flake8]
# Enforce all pyflakes constraints, and also prohibit tabs for indentation. # Enforce all pyflakes constraints, and also prohibit tabs for indentation.
......
...@@ -51,6 +51,19 @@ paths: ...@@ -51,6 +51,19 @@ paths:
properties: {} properties: {}
/storage-plugins/privatestorageio-zkapauthz-v1/backup: /storage-plugins/privatestorageio-zkapauthz-v1/backup:
get:
description: >-
Retrieve information about the backup configuration and state of this
node.
responses:
200:
description: >-
Information about backup configuration is available and included
in the response.
content:
application/json:
schema:
$ref: "#/components/schemas/BackupConfiguration"
post: post:
description: | description: |
Configure ZKAPAuthorizer to maintain an on-grid backup of its state or Configure ZKAPAuthorizer to maintain an on-grid backup of its state or
...@@ -96,6 +109,8 @@ components: ...@@ -96,6 +109,8 @@ components:
is the capability which can be submitted in order to initiate a is the capability which can be submitted in order to initiate a
recovery from the backup. recovery from the backup.
responses: responses:
ErrorResponse: ErrorResponse:
description: >- description: >-
......
...@@ -43,6 +43,8 @@ from hypothesis.strategies import ( ...@@ -43,6 +43,8 @@ from hypothesis.strategies import (
text, text,
tuples, tuples,
) )
from openapi_spec_validator import validate_spec
from openapi_spec_validator.readers import read_from_filename
from testtools import TestCase from testtools import TestCase
from testtools.content import text_content from testtools.content import text_content
from testtools.matchers import ( from testtools.matchers import (
...@@ -66,6 +68,7 @@ from twisted.web.http import BAD_REQUEST, NOT_FOUND, NOT_IMPLEMENTED, OK, UNAUTH ...@@ -66,6 +68,7 @@ from twisted.web.http import BAD_REQUEST, NOT_FOUND, NOT_IMPLEMENTED, OK, UNAUTH
from twisted.web.http_headers import Headers from twisted.web.http_headers import Headers
from twisted.web.resource import IResource, getChildForRequest from twisted.web.resource import IResource, getChildForRequest
from .. import __file__ as package_init_file
from .. import __version__ as zkapauthorizer_version from .. import __version__ as zkapauthorizer_version
from .._base64 import urlsafe_b64decode from .._base64 import urlsafe_b64decode
from .._json import dumps_utf8 from .._json import dumps_utf8
...@@ -285,6 +288,20 @@ def add_api_token_to_config(basedir, config, api_auth_token): ...@@ -285,6 +288,20 @@ def add_api_token_to_config(basedir, config, api_auth_token):
config.write_private_config("api_auth_token", api_auth_token) config.write_private_config("api_auth_token", api_auth_token)
class OpenAPITests(TestCase):
"""
Tests for the OpenAPI specification for the HTTP API.
"""
def test_backup_recovery_valid(self):
"""
The specification document is valid OpenAPI 3.0.
"""
spec_path = FilePath(package_init_file).sibling("backup-recovery.yaml")
spec_dict, spec_url = read_from_filename(spec_path.path)
# If no exception is raised then the spec is valid.
validate_spec(spec_dict)
class FromConfigurationTests(TestCase): class FromConfigurationTests(TestCase):
""" """
Tests for ``from_configuration``. Tests for ``from_configuration``.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment