Skip to main content

A Flask extension for automatic API documentation generation

Project description

Flask Automate Docs

A Flask extension that automatically generates OpenAPI (Swagger) documentation for your Flask application's routes and SQLAlchemy models.

Features

  • Automatic route documentation extraction
  • SQLAlchemy model schema generation
  • Type hint support for request/response schemas
  • Security scheme detection
  • Beautiful Swagger UI interface
  • Customizable documentation settings

Installation

pip install flask-automate-docs

Quick Start

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_automate_docs import AutomateDocs

app = Flask(__name__)
db = SQLAlchemy(app)

# Initialize the extension
docs = AutomateDocs(app, db)

# Enable documentation
app.config['AUTOMATE_DOCS_ENABLED'] = True
app.config['AUTOMATE_DOCS_SQLALCHEMY'] = True  # Enable SQLAlchemy model documentation

# Your routes and models here...

if __name__ == '__main__':
    app.run(debug=True)

Visit /documentation to see the Swagger UI interface, or /api/docs for the raw OpenAPI JSON.

Configuration

The extension supports the following configuration options:

  • AUTOMATE_DOCS_ENABLED: Enable/disable documentation (default: False)
  • AUTOMATE_DOCS_SQLALCHEMY: Enable/disable SQLAlchemy model documentation (default: False)
  • AUTOMATE_DOCS_MODELS: Specify models module or object (default: None)
  • AUTOMATE_DOCS_TITLE: Documentation title (default: 'API Documentation')
  • AUTOMATE_DOCS_VERSION: API version (default: '1.0')
  • AUTOMATE_DOCS_DESCRIPTION: API description (default: 'Auto-generated API documentation')
  • AUTOMATE_DOCS_PATH: Swagger UI path (default: '/documentation')
  • AUTOMATE_DOCS_JSON_PATH: OpenAPI JSON path (default: '/api/docs')

Type Hints

The extension supports Python type hints for better schema generation:

from typing import List, Dict
from dataclasses import dataclass

@dataclass
class User:
    name: str
    age: int
    hobbies: List[str]

@app.route('/users', methods=['POST'])
def create_user(request: User) -> Dict[str, str]:
    # Your code here...
    return {"message": "User created"}

Security

The extension automatically detects common security decorators:

from functools import wraps

def login_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        # Your authentication logic here
        return f(*args, **kwargs)
    decorated_function._login_required = True
    return decorated_function

@app.route('/protected')
@login_required
def protected_route():
    return {"message": "Protected content"}

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_automate_docs-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_automate_docs-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file flask_automate_docs-0.1.0.tar.gz.

File metadata

  • Download URL: flask_automate_docs-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for flask_automate_docs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 180555cef5dfa139c646928aa75bd6d489e8eb0435c9e2bf6321fe5dc1cdc09f
MD5 3b13f8f5a1d0c539d0d5a620d8a7dacb
BLAKE2b-256 a25ff92adc40fe622cef9b088400fa65df26cf52cf482490f37c2961c4d89281

See more details on using hashes here.

File details

Details for the file flask_automate_docs-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_automate_docs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47038e218f64d734da248bfded2e348d787ed36ac8545b1d21de5c990e0f2669
MD5 21733e43ff714ad13037eb3e1142a2b1
BLAKE2b-256 159f950acbd844b063942d7b74b4ffb4e6576a02ed3fc7c1d5dcaf94bc67ea46

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page