--- id: flask-pydantic-spec version: "0.8.7" license: unclear license_treatment: unclear maintenance: aging --- # flask-pydantic-spec — generate OpenAPI document and validate request & response with Python annotations. License: unclear · Maintenance: aging · Downloads: 77.3K/mo ## What it is and what it does Flask Pydantic Spec is a library that integrates Pydantic validation and OpenAPI documentation generation into Flask applications. It lets you define request and response schemas using Pydantic models, then automatically validates incoming requests against those schemas and generates interactive API documentation (Redoc or Swagger UI). Instead of writing separate YAML specs or manual validation logic, you annotate your Flask route handlers with Pydantic models, and the library handles validation, error responses (422 on failure), and documentation generation. The library depends on pydantic for schema definition and validation, and inflection for string transformations. It supports validation of query parameters, JSON bodies, headers, and cookies, plus response type declarations. When validation fails, it returns a 422 status with structured error details. You access validated data via a context object attached to the request, though you can also use Flask's standard request object. The library began as a fork of Spectree and aims to reduce boilerplate by combining documentation and validation in one annotation-driven interface. Use it for: - Build a REST API with automatic OpenAPI documentation and request validation without writing separate spec files. - Validate incoming JSON payloads and query parameters against Pydantic models, returning 422 errors with detailed validation messages. - Generate interactive Swagger UI or Redoc documentation automatically from your Flask route annotations. - Enforce consistent request/response schemas across a Flask application using Pydantic's validation and serialization. - Add before/after hooks to validation to log failures, record metrics, or customize error responses per endpoint. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds OpenAPI documentation generation and request/response validation to Flask applications using Pydantic models and Python annotations. Yes, if you need OpenAPI documentation and Pydantic validation in Flask and can tolerate unclear licensing and aging maintenance. The library is low-friction to install and actively works with current Python versions (3.9–3.13), but verify the license status before use and be aware that the project shows limited community adoption (1 star, 262 days since last release). No known vulnerabilities. ## Install pip install flask-pydantic-spec uv add flask-pydantic-spec poetry add flask-pydantic-spec ## Installing flask-pydantic-spec Before you install: Low friction: pure Python wheel with only two runtime dependencies (pydantic and inflection). Last commit was recent; however, the project shows aging maintenance signals with only 1 star and 262 days since the last release. License in practice: License status is unclear—no SPDX identifier or raw license text is available in the package metadata. Verify the actual license before using in proprietary or restricted contexts. Quickstart: pip install flask-pydantic-spec from flask import Flask from pydantic import BaseModel from flask_pydantic_spec import FlaskPydanticSpec, Response, Request class UserModel(BaseModel): name: str age: int app = Flask(__name__) api = FlaskPydanticSpec('flask') @app.route('/api/user', methods=['POST']) @api.validate(body=Request(UserModel), resp=Response(HTTP_200=UserModel)) def create_user(): return {'name': 'alice', 'age': 18} api.register(app) app.run() Requires Python 3.9 or later. Verify before relying: - Whether the unclear license status is a blocker for your use case (no SPDX or raw license metadata available). - Current maintenance commitment and roadmap—only 1 GitHub star and 262 days since last release suggest limited community adoption. ## Package facts - License: not declared (unclear) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 77.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags flask openapi documentation, pydantic request validation flask, api spec generation python, flask swagger redoc, automatic api documentation, flask request validation, openapi schema flask, openapi-generation, request-validation, flask-integration [View on SkillFed](https://skillfed.io/packages/flask-pydantic-spec) · [View on PyPI](https://pypi.org/project/flask-pydantic-spec/)