Skip to main content

Flask + marshmallow + OpenAPI

Project description

Overview

PyPI Status license python_versions documentation

Provides OpenAPI documentation generated from code for Flask APIs built around marshmallow schemas.

This hackish and organically grown ™ package was created because no other similar projects worked exactly the way I wanted them.

Similar projects:

Installation

pip install flask-marshmallow-openapi

Documentation

Read the Docs

What does it do?

Searches your codebase for marshmallow schemas and 🎖️ decorated 🎖️ Flask routes.

It then produces swagger.json and injects it into self-hosted ReDoc and SwaggerUI documentation viewers.

api = flask.Blueprint("my_api", __name__)


class BookSchema(ma.Schema):
    id = ma.fields.Integer(as_string=True)
    title = ma.fields.String(allow_none=False)
    publisher = ma.fields.String(allow_none=False)
    isbn = ma.fields.String(allow_none=False)


@open_api.get_list(BookSchema)
@api.route("/books", methods=["GET"])
def books_list():
    return "<p>Hello, World!</p>"


app = flask.Flask(__name__)
app.register_blueprint(api, url_prefix="/v1")


conf = OpenAPISettings(
    api_version="v1", api_name="My API", app_package_name="my_api", mounted_at="/v1"
)
docs = OpenAPI(config=conf)
docs.init_app(app)

New app routes:

$ flask routes

Endpoint               Methods  Rule
---------------------  -------  -------------------------------
# ...
open_api.re_doc        GET      /v1/docs/re_doc
open_api.static        GET      /v1/docs/static/<path:filename>
open_api.swagger_json  GET      /v1/docs/static/swagger.json
open_api.swagger_ui    GET      /v1/docs/swagger_ui
open_api.swagger_yaml  GET      /v1/docs/static/swagger.yaml
# ...

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

flask_marshmallow_openapi-0.8.0.tar.gz (985.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_marshmallow_openapi-0.8.0-py3-none-any.whl (994.9 kB view details)

Uploaded Python 3

File details

Details for the file flask_marshmallow_openapi-0.8.0.tar.gz.

File metadata

File hashes

Hashes for flask_marshmallow_openapi-0.8.0.tar.gz
Algorithm Hash digest
SHA256 bd9506a7822030653aab14838a2a1d64949a319c080fc94d06473a12b70b00e1
MD5 d9f4d18f3f8978fff1a9f8d35b58dee1
BLAKE2b-256 86647d110fbd76b7af2b845c9d3df59ab92ffddfd58a8b5041fd0d7ec3b949a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for flask_marshmallow_openapi-0.8.0.tar.gz:

Publisher: pypi-publish.yaml on tadams42/flask-marshmallow-openapi

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

File details

Details for the file flask_marshmallow_openapi-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_marshmallow_openapi-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3466d5938475303e18607294478f4cf765ecea2f968ce260761647b24667488e
MD5 2ab0ba01d7bf8ea7a4239baab59f6f55
BLAKE2b-256 eaf8e69cba46292ad27afb1f281d7f9a8c05d31f72b7c1ee247dc2c9f9a2fa06

See more details on using hashes here.

Provenance

The following attestation bundles were made for flask_marshmallow_openapi-0.8.0-py3-none-any.whl:

Publisher: pypi-publish.yaml on tadams42/flask-marshmallow-openapi

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 Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page