flask-marshmallow-openapi


Nameflask-marshmallow-openapi JSON
Version 0.6.3 PyPI version JSON
download
home_pageNone
SummaryFlask + marshmallow + OpenAPI
upload_time2024-05-08 07:40:44
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords openapi swaggerui redoc
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Overview

[![PyPI Status](https://badge.fury.io/py/flask-marshmallow-openapi.svg)](https://badge.fury.io/py/flask-marshmallow-openapi)
[![license](https://img.shields.io/pypi/l/flask-marshmallow-openapi.svg)](https://opensource.org/licenses/MIT)
[![python_versions](https://img.shields.io/pypi/pyversions/flask-marshmallow-openapi.svg)](https://pypi.org/project/flask-marshmallow-openapi/)
[![documentation](https://readthedocs.org/projects/flask-marshmallow-openapi/badge/?version=latest)](https://flask-marshmallow-openapi.readthedocs.io/en/latest/?badge=latest)


Provides OpenAPI documentation generated from code for
[Flask](https://flask.palletsprojects.com/en/latest/) APIs built around
[marshmallow](https://marshmallow.readthedocs.io/en/stable/) schemas.

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

Similar projects:

- [flasgger](https://github.com/flasgger/flasgger)
- [flask-openapi3](https://github.com/luolingchun/flask-openapi3)

## Installation

~~~sh
pip install flask-marshmallow-openapi
~~~

## Documentation

[Read the Docs](https://flask-marshmallow-openapi.readthedocs.io/en/latest)

## What does it do?

Searches your codebase for [marshmallow](https://marshmallow.readthedocs.io/en/stable/)
schemas and 🎖️ decorated 🎖️ Flask routes.

It then produces `swagger.json` and injects it into self-hosted
[ReDoc](https://github.com/Redocly/redoc) and
[SwaggerUI](https://github.com/swagger-api/swagger-ui) documentation viewers.

```py
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:

```sh
$ 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
# ...
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "flask-marshmallow-openapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "OpenAPI SwaggerUI ReDoc",
    "author": null,
    "author_email": "Tomislav Adamic <tomislav.adamic@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ec/17/2d901ca88ee5924ba35c71c6bb4f8b3f0171f599e1c766bd54b41111910c/flask_marshmallow_openapi-0.6.3.tar.gz",
    "platform": "any",
    "description": "# Overview\n\n[![PyPI Status](https://badge.fury.io/py/flask-marshmallow-openapi.svg)](https://badge.fury.io/py/flask-marshmallow-openapi)\n[![license](https://img.shields.io/pypi/l/flask-marshmallow-openapi.svg)](https://opensource.org/licenses/MIT)\n[![python_versions](https://img.shields.io/pypi/pyversions/flask-marshmallow-openapi.svg)](https://pypi.org/project/flask-marshmallow-openapi/)\n[![documentation](https://readthedocs.org/projects/flask-marshmallow-openapi/badge/?version=latest)](https://flask-marshmallow-openapi.readthedocs.io/en/latest/?badge=latest)\n\n\nProvides OpenAPI documentation generated from code for\n[Flask](https://flask.palletsprojects.com/en/latest/) APIs built around\n[marshmallow](https://marshmallow.readthedocs.io/en/stable/) schemas.\n\nThis hackish and organically grown \u2122 package was created because no other similar\nprojects worked exactly the way I wanted them.\n\nSimilar projects:\n\n- [flasgger](https://github.com/flasgger/flasgger)\n- [flask-openapi3](https://github.com/luolingchun/flask-openapi3)\n\n## Installation\n\n~~~sh\npip install flask-marshmallow-openapi\n~~~\n\n## Documentation\n\n[Read the Docs](https://flask-marshmallow-openapi.readthedocs.io/en/latest)\n\n## What does it do?\n\nSearches your codebase for [marshmallow](https://marshmallow.readthedocs.io/en/stable/)\nschemas and \ud83c\udf96\ufe0f decorated \ud83c\udf96\ufe0f Flask routes.\n\nIt then produces `swagger.json` and injects it into self-hosted\n[ReDoc](https://github.com/Redocly/redoc) and\n[SwaggerUI](https://github.com/swagger-api/swagger-ui) documentation viewers.\n\n```py\napi = flask.Blueprint(\"my_api\", __name__)\n\n\nclass BookSchema(ma.Schema):\n    id = ma.fields.Integer(as_string=True)\n    title = ma.fields.String(allow_none=False)\n    publisher = ma.fields.String(allow_none=False)\n    isbn = ma.fields.String(allow_none=False)\n\n\n@open_api.get_list(BookSchema)\n@api.route(\"/books\", methods=[\"GET\"])\ndef books_list():\n    return \"<p>Hello, World!</p>\"\n\n\napp = flask.Flask(__name__)\napp.register_blueprint(api, url_prefix=\"/v1\")\n\n\nconf = OpenAPISettings(\n    api_version=\"v1\", api_name=\"My API\", app_package_name=\"my_api\", mounted_at=\"/v1\"\n)\ndocs = OpenAPI(config=conf)\ndocs.init_app(app)\n```\n\nNew app routes:\n\n```sh\n$ flask routes\n\nEndpoint               Methods  Rule\n---------------------  -------  -------------------------------\n# ...\nopen_api.re_doc        GET      /v1/docs/re_doc\nopen_api.static        GET      /v1/docs/static/<path:filename>\nopen_api.swagger_json  GET      /v1/docs/static/swagger.json\nopen_api.swagger_ui    GET      /v1/docs/swagger_ui\nopen_api.swagger_yaml  GET      /v1/docs/static/swagger.yaml\n# ...\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Flask + marshmallow + OpenAPI",
    "version": "0.6.3",
    "project_urls": {
        "Source": "https://github.com/tadams42/flask-marshmallow-openapi"
    },
    "split_keywords": [
        "openapi",
        "swaggerui",
        "redoc"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1b965ab4ea097bb46b83682a220c86322f1c96244eb4368585dd852928d25a2a",
                "md5": "498ffb531ab97ed1562a20e6f9d1a5fa",
                "sha256": "097325f288fec345feb57603e2a4e3121d44be54edf33d5b39a0e4d3b4495b35"
            },
            "downloads": -1,
            "filename": "flask_marshmallow_openapi-0.6.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "498ffb531ab97ed1562a20e6f9d1a5fa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 991958,
            "upload_time": "2024-05-08T07:40:40",
            "upload_time_iso_8601": "2024-05-08T07:40:40.315800Z",
            "url": "https://files.pythonhosted.org/packages/1b/96/5ab4ea097bb46b83682a220c86322f1c96244eb4368585dd852928d25a2a/flask_marshmallow_openapi-0.6.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ec172d901ca88ee5924ba35c71c6bb4f8b3f0171f599e1c766bd54b41111910c",
                "md5": "373d07f3a19e7bf20696c0b1d7049d03",
                "sha256": "4a55250cd6b5a05cfca87de89885ceb525bafa8cb0e245e24463ec1bec087ac5"
            },
            "downloads": -1,
            "filename": "flask_marshmallow_openapi-0.6.3.tar.gz",
            "has_sig": false,
            "md5_digest": "373d07f3a19e7bf20696c0b1d7049d03",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 983021,
            "upload_time": "2024-05-08T07:40:44",
            "upload_time_iso_8601": "2024-05-08T07:40:44.202048Z",
            "url": "https://files.pythonhosted.org/packages/ec/17/2d901ca88ee5924ba35c71c6bb4f8b3f0171f599e1c766bd54b41111910c/flask_marshmallow_openapi-0.6.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-08 07:40:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tadams42",
    "github_project": "flask-marshmallow-openapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "flask-marshmallow-openapi"
}
        
Elapsed time: 0.25135s