metaengine-openapi-go-nethttp

command module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

metaengine-openapi-go-nethttp

Package guide · Go module · Native releases · NuGet engine

Pinned MetaEngine CLI

For openapi/go-nethttp on linux-arm64, linux-x64, osx-arm64, osx-x64, win-x64, install the MetaEngine CLI into your project. Commit the npm lockfile with the generator configuration.

npm install --save-dev --save-exact @metaengine/cli@0.1.1

Use the repository-local ./node_modules/.bin/metaengine command.

Generate idiomatic Go net/http clients and models from OpenAPI specifications. Self-contained — no .NET runtime required.

Part of MetaEngine.

Install

go install

go install github.com/meta-engine/metaengine-openapi-go-nethttp@latest

Homebrew

brew install meta-engine/tap/metaengine-openapi-go-nethttp

Shell (macOS / Linux)

curl -fsSL https://raw.githubusercontent.com/meta-engine/metaengine-openapi-go-nethttp/main/install.sh | sh

Or download a prebuilt binary for your platform from the Releases page.

Usage

metaengine-openapi-go-nethttp <input> <output> <module> <package> [flags]
Argument Description
input OpenAPI spec file path or URL
output Output directory for the generated code
module Go module name (e.g. github.com/acme/api)
package Go package name (e.g. client)
Example
metaengine-openapi-go-nethttp api.yaml ./client github.com/acme/api client \
  --documentation --error-handling --retries 3
Flags
Flag Description
--documentation Generate Go doc comments
--options-threshold <n> Use an options struct for methods with more than n parameters
--validate-struct-tags Add validate struct tags to generated models
--timeout <seconds> Set the HTTP client timeout
--base-url-env <name> Read the base URL from this environment variable at runtime
--bearer-auth <env> Add bearer-token auth; the token is read from this environment variable
--bearer-header <name> Use a custom header name for the bearer token (with --bearer-auth)
--basic-auth <userEnv:passEnv> Add basic auth; username/password read from these environment variables
--retries [n] Retry failed requests, optionally capping at n attempts
--header <name:env> Add a custom request header sourced from an environment variable (repeatable)
--middleware Generate a request/response middleware hook on the client
--error-handling Map HTTP error status codes to Go errors (>= 400 → typed *HTTPStatusError)
--throw-for <codes> Return a formatted error (HTTP <code>: <body>) for these status codes (comma-separated)
--return-null-for <codes> Return the ErrNullResponse sentinel for these status codes
--return-error-for <codes> Return a typed *HTTPStatusError for these status codes
--include-tags <tags> Only generate operations carrying these tags (comma-separated)
--strict-validation Fail on OpenAPI spec violations instead of tolerating them
--clean Remove stale files from the output directory before writing
--verbose Verbose logging

Generated clients take a context.Context and use pointers for optional fields by default.

Upgrading regenerated Microsoft Graph clients

The Go generator exports six recognized OData annotation fields as OdataType, OdataId, OdataContext, OdataNextLink, OdataCount, and OdataDeltaLink. After regeneration, update callers that reference the earlier Atodata fields. The corresponding @odata.* JSON keys are preserved. Ordinary odataId continues to map to OdataID.

License

MIT

Documentation

Overview

Command metaengine-openapi-go-nethttp launches the MetaEngine OpenAPI -> Go (net/http) generator. The generator itself is a self-contained native binary published on GitHub Releases; this thin Go launcher exists so that `go install` works for a tool that is not written in Go. On first run it downloads the platform binary for its own version, verifies it against the release checksums, caches it under the user cache dir, and execs it — forwarding all arguments unchanged.

Every failure is surfaced loudly (non-zero exit); there is no silent fallback.

Test/mirror overrides:

METAENGINE_OPENAPI_GO_NETHTTP_VERSION   pin the engine version (default: build version)
METAENGINE_OPENAPI_GO_NETHTTP_BASE_URL  override the release base URL (http(s):// or file://)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL