Skip to content

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

License

Notifications You must be signed in to change notification settings

dchaplinsky/aiohttp_validate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f47034c · May 12, 2020

History

38 Commits
Oct 11, 2016
Aug 2, 2019
Dec 12, 2016
Aug 2, 2019
Oct 11, 2016
Oct 11, 2016
Oct 11, 2016
Oct 11, 2016
Oct 11, 2016
Dec 12, 2016
Oct 11, 2016
Oct 11, 2016
Oct 11, 2016
May 7, 2020
Aug 2, 2019
Oct 11, 2016
Aug 2, 2019
Nov 21, 2018
Oct 11, 2016

Repository files navigation

aiohttp_validate

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

Versioning

This software follows Semantic Versioning

License

  • Free software: MIT license

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published