Skip to main content
https://badge.fury.io/py/apispec-flask-restful.svg

Flask-RESTful plugin.

Includes a path helper that allows you to pass a Flask-RESTful resource object to path.

Inspired by AndrewPashkin/apispec_restful plugin.

Install

pip install apispec_flask_restful

Usage

Typical usage

from pprint import pprint

from flask_restful import Api, Resource
from flask import Flask
from apispec import APISpec
from apispec_flask_restful import RestfulPlugin

class HelloResource(Resource):
    def get(self, hello_id):
        '''A greeting endpoint.
               ---
               description: get a greeting
               responses:
                   200:
                       description: a pet to be returned
                       schema:
                           $ref: #/definitions/Pet
        '''
        pass

app = Flask(__name__)
api = Api(app)
spec = APISpec(title='Spec', version='1.0', openapi_version='3.0.2', plugins=[RestfulPlugin()])

api.add_resource(HelloResource, '/hello')

spec.path(resource=HelloResource, api=api)
pprint(spec.to_dict()['paths'])

# OrderedDict([('/hello',
#          {'get': {'description': 'get a greeting',
#                   'responses': {200: {'description': 'a pet to be returned',
#                                       'schema': {'$ref': None}}}}})])

Without API

Method path can be invoked with a resource path in a path parameter instead of api parameter:

spec.path(resource=HelloResource, path='/hello')

With Blueprint

Flask blueprints are supported too by passing Flask app in app parameter:

spec.path(resource=HelloResource, api=api, app=app)

Metadata

Release files for apispec-flask-restful 0.3.1

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-flask-restful 0.3.1
File Size Uploaded
apispec_flask_restful-0.3.1.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for apispec-flask-restful 0.3.1
File Interpreter ABI Platform
apispec_flask_restful-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 kB

Release files / apispec_flask_restful-0.3.1.tar.gz

Download URL apispec_flask_restful-0.3.1.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e74034c986ed1304cbaff8e86c115bd806ba1efc36b3df5d739b84f679193de1
BLAKE2b-256 checksum
How to use checksums
3dbe807b33b897b3947fc4c9ec2c85395ff7ada3a70e4e7b9e488f22db512485
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 10, 2024.

Transparency log

Release files / apispec_flask_restful-0.3.1-py3-none-any.whl

Download URL apispec_flask_restful-0.3.1-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c18354ee8a06aa3862f506c14e7451367e9b40535208eae184e6e905606e3752
BLAKE2b-256 checksum
How to use checksums
3cef6f5f1d71ade3db30a060647bab40d25d8f3c7c8a8e532aac6ea49394a29e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 10, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.2

1 release file

0.1

1 release file

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