Skip to content

Automatically generate Swagger docs for Flask-Restful.

Notifications You must be signed in to change notification settings

AristotleJunior/fregger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Fregger

Automatically generate Swagger docs for Flask-Restful.

Installation

Install this extension with pip:

$ pip install fregger

Usage

from flask import Flask
from flask_restful import Api, Resource, reqparse
from fregger import Fregger

app = Flask(__name__)

# Blueprints are also supported 

api = Api(app, prefix='/api/v1')
fregger = Fregger(api, title='APIs for admins modules')

parser = reqparse.RequestParser()
parser.add_argument('name', type=str, location='json', store_missing=False)
parser.add_argument('email', type=str, location='json', store_missing=False)
parser.add_argument('password', type=str, location='json', store_missing=False)


class AdminResource(Resource):

    @fregger.generate_doc(summary='Retrieve specific admin info')
    def get(self, aid):
        return {'info': 'info of admin %d' % aid}

    @fregger.generate_doc(parser, summary='Modify specific admin info')
    def post(self, aid):

        # Modify admin info here

        return {'status': 'ok'}


# must setup fregger before add_resource
api.add_resource(AdminResource, '/admins')

if __name__ == "__main__":
    # Fregger is only enabled under DEBUG mode for security reason
    app.config['DEBUG'] = True
    app.run()

Then you can visit:

http://localhost:5000/admin/api/v1/fregger.html

Note:

Fregger is Only enabled when `flask.config['DEBUG'] = True` for security reason

About

Automatically generate Swagger docs for Flask-Restful.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages