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.
Metadata
Release files for flask-classful-apispec 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flask-classful-apispec-0.2.0.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_classful_apispec-0.2.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 10.3 kB
Release files / flask-classful-apispec-0.2.0.tar.gz
| Download URL | flask-classful-apispec-0.2.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
353d5b58efa8f9e1149ea905171b70b2aad79fbc2f669778521745f1d7fe9115
|
|
BLAKE2b-256 checksum How to use checksums |
92d4038d45134c4482188227cec57eb9a53a5178242f62b413630c6a362c34b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.10
|
Release files / flask_classful_apispec-0.2.0-py2.py3-none-any.whl
| Download URL | flask_classful_apispec-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a0b1858c7e42656135bde1bc5d2a1e3ee072ed7861137a9795427b8305968000
|
|
BLAKE2b-256 checksum How to use checksums |
73571c1e53d3283569a14389168f2948e6f0d057cc7d716fac20ec25a1065604
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.10
|