.. image:: https://img.shields.io/pypi/v/aiohttp_validate.svg :target: https://pypi.python.org/pypi/aiohttp_validate
.. image:: https://img.shields.io/travis/dchaplinsky/aiohttp_validate.svg :target: https://travis-ci.org/dchaplinsky/aiohttp_validate
.. image:: https://readthedocs.org/projects/aiohttp-validate/badge/?version=latest :target: https://aiohttp-validate.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status
.. image:: https://pyup.io/repos/github/dchaplinsky/aiohttp_validate/shield.svg :target: https://pyup.io/repos/github/dchaplinsky/aiohttp_validate/ :alt: Updates
Simple library that helps you validate your API endpoints requests/responses with jsonschema_. Documentation is also available here at https://aiohttp-validate.readthedocs.io.
Install from PyPI::
pip install aiohttp_validate
Complete example of validation for text tokenization microservice
_::
from aiohttp_validate import validate
@validate(
request_schema={
"type": "object",
"properties": {
"text": {"type": "string"},
},
"required": ["text"],
"additionalProperties": False
},
response_schema={
"type": "array",
"items": {
"type": "array",
"items": {
"type": "array",
"items": {"type": "string"}
}
}
}
)
async def tokenize_text_handler(request, *args):
return tokenize_text(request["text"])
Install requirement and launch tests::
pip install -r requirements-dev.txt
py.test
That package is influenced by Tornado-JSON written by Hamza Faran
Code to parse errors is written by Ruslan Karalkin
This software follows Semantic Versioning
_
.. _Semantic Versioning: http://semver.org/
.. _jsonschema: http://json-schema.org/
.. _aiohttp_swaggerify: https://github.com/dchaplinsky/aiohttp_swaggerify
.. Tornado-JSON: https://github.com/hfaran/Tornado-JSON/
.. Ruslan Karalkin
: https://github.com/rkaralkin
.. _text tokenization microservice
: https://github.com/lang-uk/tokenize-ms