Auto docs generation from marshmallow schema for flask classfy
Project description
Flask classful apispec
A pluggable API specification generator generator for Flask classful based on apispec
Features
Utilities for parsing flask classful docstrings
Support for marshmallow
Installation
$ pip install flask-classful-apispec
Usage
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)
with app.test_request_context():
spec.paths(PetView, app)
print(json.dumps(spec.to_dict(), indent=2))
if __name__ == "__main__":
app.run()
Generated OpenAPI Spec
Documentation
For apispec see apispec
For Flask Clasful view see Flask classful
For Schema see marshmallow
License
MIT licensed. See the bundled LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for flask-classful-apispec-0.1.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a304a8f63fcc6785d6752216a7963dda2be7761a42005fc80f154d54579ff0d8 |
|
MD5 | d333685276bfb89817f1e261e78ba14b |
|
BLAKE2b-256 | 76be733187db620397278dfd647191b2cb48e7aab85b24290c56a59124ddd9c6 |
Close
Hashes for flask_classful_apispec-0.1.8-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5a6e7009f32c02f52611c4bb112b4e43744332a2861db3a73e0911b901a40c4 |
|
MD5 | b11245f93ac5d6cbc3b34625f6182253 |
|
BLAKE2b-256 | 79a753f411df02063439d996ed18805140888923d6689f6d3fd33ed1d8a4363f |