Skip to content

glanzz/flask_doc_gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask Document Generator

Flask Doc Gen is a simple flask extension which allows you to generate Open API Documentation for your flask applications by just increasing your code testing coverage

Installation

Install Flask Document Generator with pip by running the below command:

pip3 install git+https://github.com/bhargavcn/flask_doc_gen.git

Getting Started

Initialize a document generator instance

doc_gen = DocGen(
    title="My Flask App",
    version="1.0.0",
    description="APIs of My Flask App",
    servers=[
        {
            "url": "https://flaskapp.com/api/v1",
            "description": "Production URL of the application",
        },
        {
            "url": "https://flaskapp.dev/api/v1",
            "description": "Dev Environment",
        },
    ],
)

Initalize the document generator instance with the flask app

doc_gen.init_app(app)

Pass the request and response object to the generate function in the flask after request handler

from flask import request
@app.after_request
def after_request_handler(response):
    doc_gen.generate(request, response)
    return response

Enable the document generator in the app's configuration

FLASK_DOC_GEN_ACTIVE=True

Run the test cases and watch the document generated for your application. NOTE: Make sure you return the response object in the after request handler(This is required as per flask)

About

Auto Open API document generator for flask applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages