Skip to main content

Bottle + APISpec + Marshmallow integration

Project description

bottle-apispec

Simple plugin to easily enable integrate Bottle, APISpec and Marshmallow.

Example

from bottle import Bottle, run
from bottle_apispec import APISpecPlugin
from marshmallow import Schema
from marshmallow.fields import String

app = Bottle()


class MySchema(Schema):
    id = String()
    value = String()


@app.get('/')
def index():
    """API endpoint that return MySchema
    ---
    get:
        description: API endpoint that return MySchema
        responses:
            200:
                description: It works!!!!
                schema: MySchema
    """
    data, error = MySchema.load('id', 'value')
    return data


app.install(APISpecPlugin(
    title='Example API',
    version='1.0.0',
    openapi_version='2.0',
    scan_package='.')
)

run(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

bottle-apispec-0.9.0.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

bottle_apispec-0.9.0-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

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