Skip to main content

aiohttp_validate

https://img.shields.io/pypi/v/aiohttp_validate.svg https://img.shields.io/travis/dchaplinsky/aiohttp_validate.svg Documentation Status 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.

Installation

Install from PyPI:

pip install aiohttp_validate

Usage

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"])

Features

  • The decorator to (optionally) validate the request to your aiohttp endpoint and it’s response.

  • Easily integrates with aiohttp_swaggerify to automatically document your endpoints with swagger.

  • Validation errors are standardized and can be easily parsed by the clients of your service and also human-readable.

Developing

Install requirement and launch tests:

pip install -r requirements-dev.txt
py.test

Credits

That package is influenced by Tornado-JSON written by Hamza Faran Code to parse errors is written by Ruslan Karalkin

License

  • Free software: MIT license

History

1.0.0 (2016-12-12)

  • Better documentation.

  • Updated requirements.

  • Out of alpha!

0.1.0 (2016-10-12)

  • First release on PyPI.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohttp_validate-1.0.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiohttp_validate-1.0.0-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file aiohttp_validate-1.0.0.tar.gz.

File metadata

File hashes

Hashes for aiohttp_validate-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a26871ffb9a8a2410db8729fba0881b064cb4682a964cf51de28cffc9fdd25ee
MD5 732c522c13d618d588dd730990d94a96
BLAKE2b-256 8b6d1012d5055c97abca00cbbf4fc8ac1b58c6b4671f013eea3708f2db450d34

See more details on using hashes here.

File details

Details for the file aiohttp_validate-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for aiohttp_validate-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 756d1d5ad31b45b06afeb56644a8840fd629c8b8178af19642881c6052e6eddb
MD5 a0524e1e1708f4ab95bfe7be412c9403
BLAKE2b-256 74fcdfde4558b3d3d212443169fec68d0880604b0b5a4d48997bb68f37605544

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page