Skip to main content

Web framework plugins for apispec.

Project description

PyPI version TravisCI build status marshmallow 2/3 compatible

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 on Python 2.7, 3.5, 3.6, and 3.7 virtual environments (must have each interpreter installed):

$ tox

License

MIT licensed. See the bundled LICENSE file for more details.

Project details


Download files

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

Source Distribution

apispec-webframeworks-0.4.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

apispec_webframeworks-0.4.0-py2.py3-none-any.whl (12.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file apispec-webframeworks-0.4.0.tar.gz.

File metadata

  • Download URL: apispec-webframeworks-0.4.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

File hashes

Hashes for apispec-webframeworks-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6ef0179614ab92a0df0ab9f5f90692d11aec378d2d2e3af7c355cef6610463d7
MD5 72cae5ca3ee9ca17a7ad78c2ba5d2dd7
BLAKE2b-256 da14e57abcc87a2e276ceab1ef1ccd2c1810d6b79066df8371619ac713158148

See more details on using hashes here.

File details

Details for the file apispec_webframeworks-0.4.0-py2.py3-none-any.whl.

File metadata

  • Download URL: apispec_webframeworks-0.4.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

File hashes

Hashes for apispec_webframeworks-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c138482361d6bde96c1f643136a44e8f1c958710bdd622328fd662e096be20e7
MD5 8ccfd5fa66b66d28df6834828f4b78da
BLAKE2b-256 424fd9ffb3552c991284f461cf0f0c52c013c6b353ab8ae81d276c09773fa665

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page