Skip to main content

PyPI package Build status marshmallow 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.aiohttp

  • 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.

Release files for apispec-webframeworks 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for apispec-webframeworks 1.2.0
File Size Uploaded
apispec_webframeworks-1.2.0.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for apispec-webframeworks 1.2.0
File Interpreter ABI Platform
apispec_webframeworks-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.0 kB

Release files / apispec_webframeworks-1.2.0.tar.gz

Download URL apispec_webframeworks-1.2.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5689288c266a2713c2f516eacc14ea2fec9b21f193edc8f659c770342b97fd81
BLAKE2b-256 checksum
How to use checksums
f91f8d98328269a2507b6cfe37e8a70725d168626615865dc7aec30e8720c495
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release files / apispec_webframeworks-1.2.0-py3-none-any.whl

Download URL apispec_webframeworks-1.2.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68aea0d1eeb3caeeacc7d6772a48c59c8b60b1a88d0bd51529d94597ccf33116
BLAKE2b-256 checksum
How to use checksums
712c5aa396a3bca60de3b3f419ea770b8087d52aac5221bf15ddcd9b48d61d3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page