Skip to main content

OpenAPI Integration for Bottle

Project description

About

The Bottle OpenAPI 3 Plugin is a toolkit for performing validation of requests against an OpenAPI document for Bottle applications. It is built on the openapi-core and openapi-spec-validator libraries, and supports the OpenAPI 3 specification.

License

This codebase is MIT licensed.

Requirements

A relatively recent version of Python (3.5+) is required. This plugin depends on the aforementioned openapi-core and openapi-spec-validator libraries, and also requires a relatively recent version of bottle (0.12+).

Quickstart

The Bottle OpenAPI 3 plugin may either be installed from pypi as the bottle-openapi-3 package:

pip install bottle-openapi-3

or may be installed from source from the git repository:

python setup.py install

Once the plugin is installed, it may be used in a Bottle application by loading the OpenAPI schema and installing the plugin. An example:

import bottle
import yaml
from bottle_openapi_3 import OpenAPIPlugin

app = bottle.Bottle()

with open("swagger.yaml") as f:
    spec = yaml.load(f)

@app.route("/api/foo")
def foo_handler():
    return {"foo": "bar"}

app.install(OpenAPIPlugin(spec))

app.run()

The example’s specification:

openapi: 3.0.0
info:
  title: My API
servers:
  - url: /api
paths:
  /foo:
    get:
       summary: Fetch an object
       responses:
         "200":
            description: "An object was successfully generated."
            content:
              application/json:
                schema: {"type": "object"}

Advanced Usage

TODO

Changelog

0.1.0 (Jan 2021)

Initial alpha release of the OpenAPI 3 plugin for Bottle. Most functionality should be implemented.

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-openapi-3-0.1.1.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

bottle_openapi_3-0.1.1-py2.py3-none-any.whl (1.1 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file bottle-openapi-3-0.1.1.tar.gz.

File metadata

  • Download URL: bottle-openapi-3-0.1.1.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.6.9

File hashes

Hashes for bottle-openapi-3-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5b72191329875c5b9e843711ac42868b54ec192bb55c3bceace9d7a7a3f5ba7a
MD5 4f44e747442fc61f0463241ebe7e5e02
BLAKE2b-256 519a1d12165193506300596f94677aa56577e9ab32a925dc6daa2ab3c354c0a8

See more details on using hashes here.

File details

Details for the file bottle_openapi_3-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: bottle_openapi_3-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.6.9

File hashes

Hashes for bottle_openapi_3-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0532d9d943569d0d0fd065d76a59515d8e3240864eb4a8561eafcf74455818b5
MD5 d4f689efb9b7b9b5d39f50d74bd5ae82
BLAKE2b-256 53eaf6f8eb5c97648b7578428fc516a0f3e87e22597c8ee771b82370f5d22c87

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