Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

flask api toolset

Project description


PyPI version

flask API toolset

pip install flask-api-spec

started with a simple idea


  • write validation codes for requests
  • write validation and serialization codes for responses
  • write API body
  • integrate authorizations then protect the APIs
  • swaggerize all of them automatically
  • with Flask



import flask_api_spec

app = Flask(__name__)


from flask_api_spec import Value

@app.route('/hello', apispec=dict(
    query=dict(  # constraints for request.args
        id=Value(int, error='There is not id or id is not int.')
def hello_id():
    return dict(result='The id is %s' % request.args['id'])

Focus on what begins with apispec=. We've got a robust feature for the API using the extended app.route with the apispec keyword argument.

from flask_api_spec import Value

@app.route('/hello/<string:name>', apispec=dict(
    param=dict(  # constraints for parameters
        name=Value(str, lambda x: len(x) > 3, error='name is no string or the length is not greater than 3')
def hello_name(name):
    return dict(result='Hello %s!' % name)

A param keyword in apispec= indicates in-path parameters. We can state some more detailed rules about them explicitly. In the case above, size of <string:name> should exceed 3.


  • <input type="checkbox" disabled="" /> support more mashmallow functionalities
  • <input type="checkbox" disabled="" /> support more schema functionalities
  • <input type="checkbox" disabled="" /> integrate authorization
  • <input type="checkbox" disabled="" /> generate full swagger yaml
  • <input type="checkbox" disabled="" /> support flask class view

Project details

Download files

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

Files for flask-api-spec, version 0.1.10
Filename, size File type Python version Upload date Hashes
Filename, size flask-api-spec-0.1.10.tar.gz (410.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page