Flask-More-Smorest Documentation

PyPI version Python Support Documentation Status (Latest) Documentation Status (Stable) License: MIT Downloads

Flask-More-Smorest extends Flask-Smorest with batteries-included CRUD blueprints, SQLAlchemy helpers, and an opinionated user/permission system.

Features

  • Automatic CRUD endpoints with filtering and pagination

  • Blueprint mixins for public/admin annotations and operation IDs

  • SQLAlchemy base model with Marshmallow schemas and permission hooks

  • Optional JWT-powered user, role, and token models

Quick Example

from flask import Flask
from flask_more_smorest import BaseModel, CRUDBlueprint, init_db
from flask_more_smorest.perms import Api
from flask_more_smorest.sqla import db
from sqlalchemy.orm import Mapped, mapped_column

app = Flask(__name__)
app.config.update(
    SQLALCHEMY_DATABASE_URI="sqlite:///app.db",
    SECRET_KEY="secret",
    JWT_SECRET_KEY="jwt-secret",
)

# Define your model
class Product(BaseModel):
    name: Mapped[str] = mapped_column(db.String(100))
    price: Mapped[float] = mapped_column(db.Float)

init_db(app)
api = Api(app)

# Automatic CRUD endpoints using model class
products = CRUDBlueprint(
    "products",
    __name__,
    model=Product,           # Use class (preferred)
    schema=Product.Schema,   # Auto-generated schema
    url_prefix="/api/products/",
)

api.register_blueprint(products)

This automatically creates RESTful endpoints with filtering, pagination, and permission checks.

User Authentication

Get instant authentication with UserBlueprint:

from flask_more_smorest import UserBlueprint
from flask_more_smorest.perms import init_fms

# Register all default models - no imports needed!
init_fms()

# Instant login and profile endpoints
user_bp = UserBlueprint(register=False)
api.register_blueprint(user_bp)

This provides POST /api/users/login/, GET /api/users/me/, and full CRUD for user management.

Documentation Contents

User Guide:

Indices and Tables