Flask-More-Smorest Documentation
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:
- Getting Started
- Configuration
- Permissions System
- User Model Extension Guide
- Custom User Context Integration
- When to Use Custom User Context
- Quick Start
- How It Works
- Flask-Login Integration
- Custom JWT Implementation
- OAuth Integration (Google, GitHub, etc.)
- SAML Integration
- LDAP Integration
- Multi-Tenant Applications
- Type Safety with AbstractUser
- Custom Role Checking
- User Object Requirements
- Testing with Custom Context
- Troubleshooting
- Demoapp-Style Integration
- CRUD Blueprints
- User Models & Authentication
- Testing Guide
API Reference: