Skip to main content

Flask-RESTful plugin for apispec.

Project description

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)

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_flask_restful-0.3.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

apispec_flask_restful-0.3.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file apispec_flask_restful-0.3.1.tar.gz.

File metadata

  • Download URL: apispec_flask_restful-0.3.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for apispec_flask_restful-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e74034c986ed1304cbaff8e86c115bd806ba1efc36b3df5d739b84f679193de1
MD5 c94a1ef7e77c4a17656199d2dda39c9c
BLAKE2b-256 3dbe807b33b897b3947fc4c9ec2c85395ff7ada3a70e4e7b9e488f22db512485

See more details on using hashes here.

Provenance

The following attestation bundles were made for apispec_flask_restful-0.3.1.tar.gz:

Publisher: publish.yml on theirix/apispec-flask-restful

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file apispec_flask_restful-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for apispec_flask_restful-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c18354ee8a06aa3862f506c14e7451367e9b40535208eae184e6e905606e3752
MD5 ffe021aa114c38c87af709968d384238
BLAKE2b-256 3cef6f5f1d71ade3db30a060647bab40d25d8f3c7c8a8e532aac6ea49394a29e

See more details on using hashes here.

Provenance

The following attestation bundles were made for apispec_flask_restful-0.3.1-py3-none-any.whl:

Publisher: publish.yml on theirix/apispec-flask-restful

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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