Flask classful apispec
======================
A pluggable API specification generator generator for `Flask classful <https://flask-classful.teracy.org/>`_ based on `apispec <https://apispec.readthedocs.io/en/latest/>`_
Features
========
- Utilities for parsing flask classful docstrings
- Support for `marshmallow <https://marshmallow.readthedocs.io/>`_
Installation
============
::
$ pip install flask-classful-apispec
Usage
===================
.. code-block:: python
import json
from flask import Flask
from flask_classful import FlaskView
from flask_classful_apispec import APISpec
from marshmallow import Schema, fields
app = Flask(__name__)
app.config["DOC_TITLE"] = "Swagger petstore"
app.config["DOC_VERSION"] = "0.1.1"
app.config["DOC_OPEN_API_VERSION"] = "3.0.2"
spec = APISpec(app)
pets = [
{'id': 0, 'name': 'Kitty', 'category': 'cat'},
{'id': 1, 'name': 'Coco', 'category': 'dog'}
]
class PetSchema(Schema):
id = fields.Integer()
name = fields.String()
category = fields.String()
class PetView(FlaskView):
def index(self):
"""A pet api endpoint.
---
description: Get a list of pets
responses:
200:
schema: PetSchema
"""
return PetSchema(many=True).dumps(pets)
PetView.register(app)
spec.paths(PetView)
print(json.dumps(spec.to_dict(), indent=2))
if __name__ == "__main__":
app.run()
Generated OpenAPI Spec
=====================
.. code-block:: json
{
"paths": {
"/pet/": {
"get": {
"description": "Get a list of pets",
"responses": {
"200": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
}
},
"info": {
"title": "Swagger petstore",
"version": "0.1.1"
},
"openapi": "3.0.2",
"components": {
"schemas": {
"Pet": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "integer"
},
"category": {
"type": "string"
}
}
}
}
}
}
Documentation
=============
- For apispec see `apispec <https://apispec.readthedocs.io/en/latest/>`_
- For Flask Clasful view see `Flask classful <https://flask-classful.teracy.org/>`_
- For Schema see `marshmallow <https://marshmallow.readthedocs.io/>`_
License
=======
MIT licensed. See the bundled `LICENSE <https://github.com/dev-rijan/flask-classful-apispec/blob/master/LICENSE>`_ file for more details.
Raw data
{
"_id": null,
"home_page": "https://github.com/dev-rijan/flask-classful-apispec",
"name": "flask-classful-apispec",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "flask-classfull,flask-classful-swagger,apispec,swagger,openapi,specification,documentation,spec,rest,api,web,flask,frameworks",
"author": "Rijan adhikari",
"author_email": "rijanadhikari@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/92/d4/038d45134c4482188227cec57eb9a53a5178242f62b413630c6a362c34b6/flask-classful-apispec-0.2.0.tar.gz",
"platform": null,
"description": "Flask classful apispec\n======================\n\nA pluggable API specification generator generator for `Flask classful <https://flask-classful.teracy.org/>`_ based on `apispec <https://apispec.readthedocs.io/en/latest/>`_\n\nFeatures\n========\n- Utilities for parsing flask classful docstrings\n- Support for `marshmallow <https://marshmallow.readthedocs.io/>`_\n\nInstallation\n============\n\n::\n\n $ pip install flask-classful-apispec\n\nUsage\n===================\n\n.. code-block:: python\n\n import json\n from flask import Flask\n from flask_classful import FlaskView\n from flask_classful_apispec import APISpec\n from marshmallow import Schema, fields\n\n app = Flask(__name__)\n\n app.config[\"DOC_TITLE\"] = \"Swagger petstore\"\n app.config[\"DOC_VERSION\"] = \"0.1.1\"\n app.config[\"DOC_OPEN_API_VERSION\"] = \"3.0.2\"\n\n spec = APISpec(app)\n\n pets = [\n {'id': 0, 'name': 'Kitty', 'category': 'cat'},\n {'id': 1, 'name': 'Coco', 'category': 'dog'}\n ]\n\n class PetSchema(Schema):\n id = fields.Integer()\n name = fields.String()\n category = fields.String()\n\n class PetView(FlaskView):\n def index(self):\n \"\"\"A pet api endpoint.\n ---\n description: Get a list of pets\n responses:\n 200:\n schema: PetSchema\n \"\"\"\n return PetSchema(many=True).dumps(pets)\n\n PetView.register(app)\n spec.paths(PetView)\n\n print(json.dumps(spec.to_dict(), indent=2))\n\n if __name__ == \"__main__\":\n app.run()\n\nGenerated OpenAPI Spec\n=====================\n.. code-block:: json\n\n {\n \"paths\": {\n \"/pet/\": {\n \"get\": {\n \"description\": \"Get a list of pets\",\n \"responses\": {\n \"200\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Pet\"\n }\n }\n }\n }\n }\n },\n \"info\": {\n \"title\": \"Swagger petstore\",\n \"version\": \"0.1.1\"\n },\n \"openapi\": \"3.0.2\",\n \"components\": {\n \"schemas\": {\n \"Pet\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"id\": {\n \"type\": \"integer\"\n },\n \"category\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n }\n\nDocumentation\n=============\n- For apispec see `apispec <https://apispec.readthedocs.io/en/latest/>`_\n- For Flask Clasful view see `Flask classful <https://flask-classful.teracy.org/>`_\n- For Schema see `marshmallow <https://marshmallow.readthedocs.io/>`_\n\nLicense\n=======\n\nMIT licensed. See the bundled `LICENSE <https://github.com/dev-rijan/flask-classful-apispec/blob/master/LICENSE>`_ file for more details.\n\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Auto docs generation from marshmallow schema for flask classfy",
"version": "0.2.0",
"split_keywords": [
"flask-classfull",
"flask-classful-swagger",
"apispec",
"swagger",
"openapi",
"specification",
"documentation",
"spec",
"rest",
"api",
"web",
"flask",
"frameworks"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "73571c1e53d3283569a14389168f2948e6f0d057cc7d716fac20ec25a1065604",
"md5": "406b96d684941bd32ce9f5a0d7f527b8",
"sha256": "a0b1858c7e42656135bde1bc5d2a1e3ee072ed7861137a9795427b8305968000"
},
"downloads": -1,
"filename": "flask_classful_apispec-0.2.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "406b96d684941bd32ce9f5a0d7f527b8",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.6",
"size": 5560,
"upload_time": "2023-01-07T07:30:35",
"upload_time_iso_8601": "2023-01-07T07:30:35.103285Z",
"url": "https://files.pythonhosted.org/packages/73/57/1c1e53d3283569a14389168f2948e6f0d057cc7d716fac20ec25a1065604/flask_classful_apispec-0.2.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "92d4038d45134c4482188227cec57eb9a53a5178242f62b413630c6a362c34b6",
"md5": "0fe615201308b978f7b350ec01cbc377",
"sha256": "353d5b58efa8f9e1149ea905171b70b2aad79fbc2f669778521745f1d7fe9115"
},
"downloads": -1,
"filename": "flask-classful-apispec-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "0fe615201308b978f7b350ec01cbc377",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4765,
"upload_time": "2023-01-07T07:30:36",
"upload_time_iso_8601": "2023-01-07T07:30:36.749433Z",
"url": "https://files.pythonhosted.org/packages/92/d4/038d45134c4482188227cec57eb9a53a5178242f62b413630c6a362c34b6/flask-classful-apispec-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-07 07:30:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "dev-rijan",
"github_project": "flask-classful-apispec",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "flask-classful-apispec"
}