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 `path` inspects the view and its route,
# we need to be in a Flask request context
with app.test_request_context():
spec.path(view=gist_detail)
Documentation
For documentation for a specific plugin, see its module docstring.
Development
Clone and cd into this repo
Create and activate a virtual environment
Install this package (in editable mode) and the development dependencies
$ pip install '.[dev]'
Install pre-commit hooks
$ pre-commit install
Running tests
To run all tests:
$ pytest
To run syntax checks:
$ tox -e lint
(Optional) To run tests in all supported Python versions in their own virtual environments (must have each interpreter installed):
$ tox
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
File details
Details for the file apispec-webframeworks-0.5.2.tar.gz
.
File metadata
- Download URL: apispec-webframeworks-0.5.2.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0db35b267914b3f8c562aca0261957dbcb4176f255eacc22520277010818dcf3 |
|
MD5 | c3b4b8f65fd228f797ca5f08872e936a |
|
BLAKE2b-256 | bd35a1eb70cd9eaee7400941ca01acff9b593a12a558031f62332927970ee400 |
File details
Details for the file apispec_webframeworks-0.5.2-py2.py3-none-any.whl
.
File metadata
- Download URL: apispec_webframeworks-0.5.2-py2.py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 482c563abbcc2a261439476cb3f1a7c7284cc997c322c574d48c111643e9c04e |
|
MD5 | d0b3a6669e797d40ba31a8c75eeb46a0 |
|
BLAKE2b-256 | 4eca5c8c9d8faf46d98ece6b39d95730d008a868beb011c7cb61b7d61d49b0f5 |