PyPI NuGet v1.0.0 MIT

metaengine-openapi-httpx

OpenAPI 3.x → 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
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

1
  • EnableVerboseLogging()Enable detailed logging
Features

Why this package is different

Deterministic output
Same spec + same options produce byte-identical files. Safe to commit, safe to diff in review, safe to cache in CI.
Tree-shakeable
One file per tag (or per operation) means bundlers drop unused code at build time. No runtime dispatch table.
Zero runtime
Validation and clients opt in. The default emit is pure types with no dependency surface beyond your HTTP lib.
Flexible naming
Case conventions configurable per role — types, properties, operations, enums. Idiomatic in the target by default.
Type resolution
Discriminated unions for oneOf, proper nullability, bigint when the spec mandates it, refs flattened only when safe.
Semver-honest
Spec diff drives the version bump. Additive changes = minor, removed ops = major. Never a surprise in your lockfile.