metaengine-openapi-go-nethttp
OpenAPI 3.x → idiomatic Go: schema-driven structs (json:"…" tags, pointers for optional fields) and a net/http client with context.Context-first methods returning (T, error), Go doc comments, bearer/basic auth, retries, timeouts, and HTTP-status error handling (>= 400 → typed *HTTPStatusError, ErrNullResponse sentinel). Shipped as a single self-contained binary — no .NET runtime required.
Pick your registry
The same generator, published to every ecosystem we support. Install however your project expects.
Drive it from the CLI or programmatically
GitHub Releases ships a zero-config CLI. NuGet ships the same generator as a C# fluent API — same options, same output.
After install, point the CLI at your schema. It writes the generated tree to your chosen output directory.
metaengine-openapi-go-nethttp <input> <output> <module> <package> [flags]Supports OpenAPI 3.0+ specifications in both JSON and YAML formats. A single self-contained binary — no .NET runtime required. <module> is the Go module path (e.g. github.com/acme/api); <package> is the generated Go package name (e.g. client).
metaengine-openapi-go-nethttp api.yaml ./client github.com/acme/api clientmetaengine-openapi-go-nethttp https://api.example.com/openapi.json ./client github.com/acme/api clientmetaengine-openapi-go-nethttp api.yaml ./client github.com/acme/api client \
--documentation \
--error-handling \
--retries 3 \
--include-tags pets,storeEvery 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.
Go Options
6WithDocumentation()Generate Go doc comments on structs and service methodsWithOptionsObjectThreshold(int)Parameter count at which a method switches to an options structWithValidateStructTags()Emit validate:"…" struct tags (for github.com/go-playground/validator)WithContext()Take context.Context as the first method parameter (engine default)WithPointersForOmittable()Use pointers (*string, *int) for optional fields (engine default)WithMethodNames(Func)Custom method naming rule
Auth · Headers · Resilience
14WithErrorHandling()Smart error handling by HTTP-status semantics (404/403 → ErrNullResponse · 400/422/409 → error body · 401/500/502/503 → *HTTPStatusError)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 via middlewareWithBearerAuth(string)Bearer token from a specific env var nameWithBearerAuth(string, string)Bearer token from an env var with a custom header nameWithBasicAuth(string, string)HTTP Basic auth from username + password env varsWithCustomHeader(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)http.Client timeout in seconds for all operationsWithTimeout(double?, double?, double?, double?)Granular timeout: connect · read · write · poolWithRetries()Retries with exponential backoff (default status 429, 503)WithRetries(int)Retries with a custom max-attempts countWithRetries(int, double, double, int[])Retries with full custom settings including status codesWithMiddleware()Emit RoundTripper middleware infrastructure (chained request/response hooks)
OpenAPI Filtering
3WithStrictValidation()Enable strict OpenAPI validationWithOperationFilter(Func)Filter operations by predicateWithHeaderFilter(Func)Filter header parameters
Naming Transformations
3Types(Func)Transform type namesPaths(Func)Transform output pathsFileNames(Func)Transform file names
File Management
5CleanDestination()Clean output directory before generationAlwaysOverwrite()Always overwrite existing filesOnlyWhenModelChanged()Update only when model changesOnlyWhenNew()Write only new files, preserve existingCleanDirectories(...)Clean specific subdirectories
Diagnostics
2Verbose()Enable verbose loggingWithLogger(Action<string>)Route generation log output to a custom sink