PyPI NuGet v1.0.0 MIT

OpenAPI to Python httpx Client Generator

metaengine-openapi-httpx

Convert OpenAPI 3.x to idiomatic Python: Pydantic v2 models and an async httpx client, with docstrings, smart HTTP-status error handling, retries, timeouts, and camelCase field aliases. Delivered as a pip-installable CLI — no .NET required.

OpenAPI 3.xMetaEngine IRPython · httpx
Open the browser UI for hosted OpenAPI to Python httpx generation
Install

Pick your registry

The same generator, published to every ecosystem we support. Install however your project expects.

PyPIPrimarymetaengine-openapi-httpx
$pip install metaengine-openapi-httpx
v1.0.0
NuGetMetaEngine.Python.OpenApi.Httpx
$dotnet add package MetaEngine.Python.OpenApi.Httpx
v1.0.0
Usage

Drive it from the CLI or programmatically

PyPI ships a zero-config CLI. NuGet ships the same generator as a C# fluent API — same options, same output.

PyPI · pip · CI-friendly

After install, point the CLI at your schema. It writes the generated tree to your chosen output directory.

Basic syntax
terminal
metaengine-openapi-httpx <input> <output> [options]

Supports OpenAPI 3.0+ specifications in both JSON and YAML formats. The wheel bundles a platform-native runner, so no .NET install is required.

Quick examples
Generate from a local file
metaengine-openapi-httpx ./petstore.json ./generated
Generate from a URL
metaengine-openapi-httpx https://api.example.com/openapi.json ./generated
With docstrings and camelCase aliases
metaengine-openapi-httpx ./petstore.json ./generated \
  --documentation \
  --camel-case-aliases \
  --include-tags pets,store
CLI options
Option
Description
--include-tags <tags>
Only generate operations with these tags (comma-separated)
--service-suffix <name>
Service naming suffix [default: Service]
--options-threshold <n>
Parameter count at which a method switches to an options object [default: 4]
--camel-case-aliases
Generate camelCase field aliases for Pydantic models
--documentation
Generate docstring comments
--strict-validation
Enable strict OpenAPI validation
--verbose
Enable verbose logging
Options reference

Every knob, documented

Every option is available on the C# fluent API as a method, and most are also exposed as CLI flags. Cross-cutting auth, headers, retries and timeouts apply across frameworks.

Python Options

6
  • WithDocumentation()Generate Python docstrings on models and service methods
  • WithOptionsObjectThreshold(int)Parameter count at which a method switches to an options object (default: 4)
  • WithCamelCaseAliases()Add camelCase Field aliases on Pydantic models (populate_by_name=True) so JSON accepts both snake_case and camelCase
  • WithSyncMethods()Generate synchronous variants alongside the async methods (named with a _sync suffix)
  • WithMiddleware()Emit httpx transport middleware infrastructure (chained request/response hooks)
  • WithMethodNames(Func)Custom method naming rule

Auth · Headers · Resilience

13
  • WithErrorHandling()Smart error handling based on HTTP status semantics (404/403 → None · 400/422 → error body · 401/500 → raise)
  • WithErrorHandling(errors => errors...)Per-status routing: ReturnNullFor(404, 403) · ReturnErrorFor(400, 422) · ThrowFor(401, 500)
  • WithBearerAuth()Bearer token from env var (default API_TOKEN) — adds an Authorization header
  • WithBearerAuth(string)Bearer token from a specific env var name
  • WithBearerAuth(string, string)Bearer token from an env var with a custom header name
  • WithBasicAuth(string, string)HTTP Basic auth from username + password env vars
  • WithCustomHeader(string, string)Static header read from an env var. Repeatable.
  • WithBaseUrlEnvVar(string)Read the base URL from an env var (default API_BASE_URL)
  • WithTimeout(double)Request timeout in seconds for all operations
  • WithTimeout(double?, double?, double?, double?)Granular httpx timeout: connect · read · write · pool
  • WithRetries()Retries with exponential backoff (default status 429, 503)
  • WithRetries(int)Retries with a custom max-attempts count
  • WithRetries(int, double, double, int[])Retries with full custom settings including status codes

OpenAPI Filtering

3
  • WithStrictValidation()Enable strict OpenAPI validation
  • WithOperationFilter(Func)Filter operations by predicate
  • WithHeaderFilter(Func)Filter header parameters

Naming Transformations

3
  • Types(Func)Transform type names
  • Paths(Func)Transform output paths
  • FileNames(Func)Transform file names

File Management

5
  • CleanDestination()Clean output directory before generation
  • AlwaysOverwrite()Always overwrite existing files
  • OnlyWhenModelChanged()Update only when model changes
  • OnlyWhenNew()Write only new files, preserve existing
  • CleanDirectories(...)Clean specific subdirectories

Diagnostics

2
  • Verbose()Enable verbose logging
  • WithLogger(Action<string>)Route generation log output to a custom sink
Features

Why this package is different

Pydantic v2 or dataclass
Models as Pydantic v2 classes, or dependency-free @dataclass with slots=True when you would rather not take the dependency.
Async-first httpx
Async httpx clients with full PEP 604 type hints. Synchronous methods are opt-in.
pip-installable CLI
Ships as a pip-installable CLI — no .NET runtime required to generate.
Deterministic output
Same spec + same options produce byte-identical files. Safe to commit, safe to diff in review, safe to cache in CI.
Flexible naming
Case conventions are configurable per role — types, properties, operations, enums. Idiomatic in the target by default.
Semver-honest
Spec diff drives the version bump. Additive changes = minor, removed operations = major. Never a surprise in your lockfile.