Giter Site home page Giter Site logo

falguard's Introduction

Falguard travis codecov python-versions

Falguard is a Python library that provides request validation helpers for Falcon web framework. Falguard relies on Yelp's bravado-core library.

Features

  • Validation of OpenAPI (Swagger) schema
  • Error serialization compliant with JSON:API specification
  • Validator may be used either as a hook or a middleware component

Installation

$ pip install falguard

Usage

Instantiate Validator with the path to OpenAPI specification (both json and yaml are supported)...

import falguard

validator = falguard.Validator('spec.json')

...and use it as the hook on the responder...

class Resource:

    @falcon.before(validator)
    def on_get(self, request, response, **validated):
        pass

...or the hook on the whole resource...

@falcon.before(validator)
class Resource:
    pass

...or globally, as the middleware component.

import falcon

api = falcon.API(middleware=validator)

All validated parameters (path, query, body) are injected back to the responder so it MUST accept relevant number of arguments, eg.

class Resource:

    def on_put(self, request, response, resource_id, data):
        pass

    def on_post(self, request, response, **validated):
        pass

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.