Skip to main content

Pydantic OpenAPI Generator

PyPI Status Python Version License

Tests Codecov

pre-commit Black


Documentation: here


Migration from auth-broker

As of pydantic-openapi-generator version 2.2.8, this package has moved out of the auth-broker organisation, been renamed, and had its import namespace updated.

Item Previous Current
GitHub repository auth-broker/openapi-python-generator mattcoulter7/pydantic-openapi-generator
PyPI package ab-openapi-python-generator pydantic-openapi-generator
CLI command ab-openapi-python-generator pydantic-openapi-generator
Import namespace ab_openapi_python_generator pydantic_openapi_generator

The old PyPI package is retained as an archived historical package. New work should use pydantic-openapi-generator and pydantic_openapi_generator.

Features

  • Ease of use. Provide input, output and the library, and the generator will do the rest.
  • Type safety and type hinting. Pydantic OpenAPI Generator makes heavy use of pydantic models to provide type-safe data structures.
  • Support for multiple rest frameworks. Pydantic OpenAPI Generator currently supports the following:
  • Async and sync code generation support, depending on the framework. It will automatically create both for frameworks that support both.
  • Easily extendable using Jinja2 templates. The code is designed to be easily extendable and should support even more languages and frameworks in the future.
  • Fully tested. Every generated code is automatically tested against the OpenAPI spec and we have 100% coverage.
  • Usage as CLI or as library.

Requirements

  • Python 3.12+

Installation

You can install Pydantic OpenAPI Generator via pip from PyPI:

$ pip install pydantic-openapi-generator

Usage

Please see the Quick start page for details.

HTTP client configuration

Generated httpx clients default to a 30 second timeout. You can override that and enable an httpx-retries policy from the generator configuration file:

default_timeout: 30.0
retry:
  total: 3
  backoff_factor: 0.5
  status_forcelist:
    - 429
    - 502
    - 503
    - 504

When retry is configured, the generated client project must include httpx-retries. Retry settings use the same Pydantic RetryFactory model in the generator configuration and the generated package's utils/retry.py.

Clients also accept retry settings directly from JSON:

client = AsyncClient.model_validate_json('{"timeout": 30.0, "retry": {"total": 3, "backoff_factor": 0.5}}')

RetryFactory.get_retry() constructs the httpx-retries policy, and get_transport() constructs its transport. Set retry to null to disable retries.

Roadmap

  • Support for all commonly used http libraries in the python ecosystem (requests, urllib, ...)
  • Support for multiple languages
  • Support for multiple authentication schemes
  • Support custom themes

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, Openapi Python Generator is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Credits

Special thanks to the peeps from openapi-schema-pydantic, which already did a lot of the legwork by providing a pydantic schema for the OpenAPI 3.0.0+ specification.

This project was generated from @cjolowicz's Hypermodern Python Cookiecutter template.

Metadata

Release files for pydantic-openapi-generator 2.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydantic-openapi-generator 2.11.0
File Size Uploaded
pydantic_openapi_generator-2.11.0.tar.gz 36.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-openapi-generator 2.11.0
File Interpreter ABI Platform
pydantic_openapi_generator-2.11.0-py3-none-any.whl Python 3 none any Details

Total release size: 88.6 kB

Release files / pydantic_openapi_generator-2.11.0.tar.gz

Download URL pydantic_openapi_generator-2.11.0.tar.gz
Size 36.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6c4ab2e803070027247425d4f0e00a5018829478c5dad4e7e9f852d8605bb7d2
BLAKE2b-256 checksum
How to use checksums
798f5be9a0e081714ccd84c2f2cf2eea5e8e614c88704bbd34bafd22d8595a17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pydantic_openapi_generator-2.11.0-py3-none-any.whl

Download URL pydantic_openapi_generator-2.11.0-py3-none-any.whl
Size 52.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62311e1129b453799d772085dd945118643aae35f365a1ffbcfcb085936b101f
BLAKE2b-256 checksum
How to use checksums
17d7dbf58b92c4ff928141678ebcee23b494f3ecd7a8c496f4cbe6894bc440ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

2.11.0 This release

2 release files

2.10.2

2 release files

2.10.1

2 release files

2.10.0

2 release files

2.9.0

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.0

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page