Skip to main content

Simple library that helps you validate your API endpoints requests/responses with json schema

Project description

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.

Project details


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.1.tar.gz (14.4 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: aiohttp_validate-1.0.1.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for aiohttp_validate-1.0.1.tar.gz
Algorithm Hash digest
SHA256 afb6bdca172d83ab7f9f539b3e6c424b1c80ce77bdd20793e5865eb3d83bad5f
MD5 ba5629abcba52b8a3164a14d8fd87ef7
BLAKE2b-256 d02640838d856f0492540ee5bc6c887b79679b3d3729164a0ef3db0e234f856d

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 Pingdom Monitoring Sentry Error logging StatusPage Status page