fastapi-endpoint-patterns

Installation
SKILL.md

FastAPI Endpoint Patterns

Overview

Reference guide for idiomatic FastAPI endpoint design. Apply these patterns when building, reviewing, or refactoring API endpoints to ensure proper validation, clean dependency injection, and consistent error handling.

Pydantic Model Design

Request and Response Models

Always separate request models from response models. Never expose internal fields (password hashes, internal IDs) in responses.

from pydantic import BaseModel, Field, EmailStr, field_validator, computed_field
from datetime import datetime

# Request model — what the client sends
class CreateUserRequest(BaseModel):
    name: str = Field(min_length=1, max_length=100)
Related skills
Installs
5
GitHub Stars
6
First Seen
Mar 18, 2026