Web framework plugins for apispec.
Project description
apispec plugins for integrating with various web frameworks.
These plugins used to be in apispec.ext but have since been moved to their own package.
Included plugins:
apispec_webframeworks.bottle
apispec_webframeworks.flask
apispec_webframeworks.tornado
Migration from apispec<1.0.0
To migrate from older versions of apispec, install this package with
pip install apispec-webframeworks
Change your imports, like so:
# apispec<1.0.0
from apispec.ext.flask import FlaskPlugin
# apispec>=1.0.0
from apispec_webframeworks.flask import FlaskPlugin
Example Usage
from flask import Flask
from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
from apispec_webframeworks.flask import FlaskPlugin
from marshmallow import Schema, fields
spec = APISpec(
title='Gisty',
version='1.0.0',
info=dict(
description='A minimal gist API'
),
plugins=[
FlaskPlugin(),
MarshmallowPlugin(),
]
)
app = Flask(__name__)
class GistParameter(Schema):
gist_id = fields.Int()
class GistSchema(Schema):
id = fields.Int()
content = fields.Str()
@app.route('/gists/<gist_id>')
def gist_detail(gist_id):
"""Gist detail view.
---
get:
parameters:
- in: path
schema: GistParameter
responses:
200:
schema: GistSchema
"""
return 'details about gist {}'.format(gist_id)
# Since add_path inspects the view and its route,
# we need to be in a Flask request context
with app.test_request_context():
spec.add_path(view=gist_detail)
Documentation
For documentation for a specific plugin, see its module docstring.
License
MIT licensed. See the bundled LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for apispec-webframeworks-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f32211535b6dff2978106ead70f084034a592e22db2318f36f51c999c10b2dc2 |
|
MD5 | 0a9af75ed10a8bf0cc704995e42b93e7 |
|
BLAKE2b-256 | 594b6b5ff7eaa804b7ab2d16f4334b2bf6b8afefd85ea179043535a6f1cb480c |
Close
Hashes for apispec_webframeworks-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d05df725e76fb9a7804634359908d2f40dbc12efbaa13d5cd4d43f4c13f04173 |
|
MD5 | 88bcfddd4fcdc9ac11ff7e8b333172e0 |
|
BLAKE2b-256 | c6b9cd8550d80b35e264eeb04ebc70d388c8310dd3083b3d429b8d40b7ee1217 |