--- id: openapi-schema-pydantic version: "1.2.4" license: unclear license_treatment: permissive maintenance: dormant --- # openapi-schema-pydantic — OpenAPI (v3) specification schema as pydantic class License: permissive · Maintenance: dormant · Downloads: 1.1M/mo ## What it is and what it does openapi-schema-pydantic wraps the OpenAPI v3 specification as a set of Pydantic data classes, letting you build and validate OpenAPI documents programmatically in Python. Instead of hand-writing JSON or YAML specs, you instantiate Pydantic objects (OpenAPI, Info, Operation, Response, etc.) that follow the official schema naming and structure, then serialize them to spec-compliant JSON or dict. The package leverages Pydantic's validation and schema generation to handle the complexity of OpenAPI's nested structure. It supports both object-oriented construction and mixed dict/object input, and includes utilities to embed Pydantic model schemas directly into OpenAPI documents as JSON Schema references. It offers both OpenAPI 3.1.0 and 3.0.3 versions via separate import paths. Use it for: - Generate OpenAPI specs programmatically from Python code instead of maintaining separate YAML/JSON files. - Validate OpenAPI documents at runtime using Pydantic's built-in validation before publishing or serving them. - Embed Pydantic model schemas into OpenAPI definitions to keep request/response types in sync with your code. - Build API documentation tooling that constructs OpenAPI specs from Python function signatures and type hints. - Migrate or transform existing OpenAPI specs by parsing them into Pydantic objects, modifying them, and re-serializing. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides Pydantic classes that map to the OpenAPI v3 specification schema, enabling programmatic construction and validation of OpenAPI documents. Yes, with conditions. The package is stable and widely used, but maintenance is dormant—last release was 2022-06-29. Install it if you need to work with OpenAPI specs in Python and can tolerate slow or no updates. Verify compatibility with your Pydantic version and confirm that OpenAPI 3.0.3 or 3.1.0 support meets your needs. No known security vulnerabilities. ## Install pip install openapi-schema-pydantic uv add openapi-schema-pydantic poetry add openapi-schema-pydantic ## Installing openapi-schema-pydantic Before you install: Low install friction with a single runtime dependency. Maintenance is dormant—last release was 2022-06-29, though the repository remains active and the package is widely used. License in practice: MIT License (permissive). No restrictions on commercial or private use; you may modify and distribute freely with attribution. Quickstart: pip install openapi-schema-pydantic from openapi_schema_pydantic import OpenAPI, Info, Operation, Response open_api = OpenAPI( info=Info(title="My API", version="v1"), paths={"/ping": {"get": Operation(responses={"200": Response(description="pong")})}} ) print(open_api.json(by_alias=True, exclude_none=True)) Requires Python >=3.6.1; when serializing to JSON, must use by_alias=True and exclude_none=True to comply with OpenAPI standard. Verify before relying: - Whether dormant maintenance status affects compatibility with recent OpenAPI spec updates or pydantic breaking changes. - Support level for OpenAPI 3.1.0 vs 3.0.3 in production environments and tooling ecosystem. - Compatibility with current versions of pydantic, especially pydantic v2. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 1.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags openapi schema pydantic models, openapi v3 specification classes, construct openapi documents programmatically, openapi schema validation, pydantic openapi definitions, openapi 3.0.3 and 3.1.0 schema, openapi, api-specification, schema-validation [View on SkillFed](https://skillfed.io/packages/openapi-schema-pydantic) · [View on PyPI](https://pypi.org/project/openapi-schema-pydantic/)