governing-schema-implementation

Govern Pydantic V2 schema configurations for API payloads.

Updated Mar 6, 2026
One-click install
npx skills add https://github.com/musher-dev/bundles --skill governing-schema-implementation
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: governing-schema-implementation
Source: https://github.com/musher-dev/bundles/tree/main/api-route-governance/skills/governing-schema-implementation
Command: npx skills add https://github.com/musher-dev/bundles --skill governing-schema-implementation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill ensures your API schemas are secure, accurate, and maintainable by enforcing best practices for Pydantic V2 model configuration, preventing common pitfalls like data leaks and mass-assignment vulnerabilities.

Core Features & Use Cases

  • Response Model Enforcement: Guarantees that API responses are strictly defined and filtered, protecting sensitive data.
  • Absent-Over-Null Compliance: Configures responses to omit null fields, leading to cleaner and more compact data transfer.
  • Polymorphism: Enables clear definition of complex, varied response structures using OpenAPI's oneOf with Pydantic's Discriminator.
  • Alias Generation: Manages API wire format conventions (e.g., camelCase) while maintaining Pythonic snake_case in the codebase.
  • Model Naming Conventions: Enforces a standardized naming pattern for API models (ResourceCreate, ResourceResponse, etc.) for clarity and consistency.
  • Use Case: Reviewing a new Pydantic model for an API endpoint to ensure it adheres to security standards, uses correct naming conventions, and generates an accurate OpenAPI schema.

Quick Start

Use the governing-schema-implementation skill to audit the Pydantic models in the 'models/' directory for adherence to response model enforcement and naming conventions.

Frequently Asked Questions about governing-schema-implementation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent mass-assignment vulnerabilities in Pydantic API models?▼

Preventing mass-assignment vulnerabilities in Pydantic API models requires strict response_model enforcement and standardized ResourceCreate/ResourceUpdate/ResourcePatch/ResourceResponse naming conventions to isolate writable fields from exposed data.

How do I configure Pydantic V2 to omit null fields from OpenAPI responses?▼

To omit null fields from OpenAPI responses in Pydantic V2, configure your models with response_model_exclude_none to ensure absent-over-null compliance, resulting in cleaner and more compact data transfer.

Does Pydantic V2 support OpenAPI oneOf polymorphism with discriminators?▼

Yes, Pydantic V2 supports OpenAPI oneOf polymorphism by using the Discriminator annotation, enabling clear definition of complex and varied response structures with accurate schema generation.

What is the best way to maintain camelCase API wire format with snake_case Python models?▼

The best way to maintain camelCase API wire format with snake_case Python models is using Pydantic's alias_generator with to_camel and populate_by_name, ensuring wire format consistency without sacrificing Pythonic code conventions.

How do I audit an existing Pydantic model for API schema security and consistency?▼

Auditing a Pydantic model for API schema security involves reviewing response_model enforcement, verifying absent-over-null compliance, checking model naming conventions, and validating OpenAPI schema generation against security standards.

Why distinguish between validation and serialization modes in Pydantic V2 schemas?▼

Distinguishing between validation and serialization modes using Pydantic V2's JsonSchemaMode ensures accurate OpenAPI schema generation by explicitly separating input validation rules from output serialization structures.