oapi-codegen-client

module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT

README

oapi-codegen client

Go Report Card workflow ci

A Golang client wrapper for clients generated with oapi-codegen.

Description

This package wraps around the generated clients from oapi-codegen. By using this package it lowers the boilerplate code for adding Datadog APM or Google Cloud Platform OAuth support.

Usage

go get github.com/YourSurpriseCom/oapi-codegen-client

baseURL := "https://cataas.com"
upstreamTimeout := 5 * time.Second
apmInstance := apm.NewApm()
audience := "https://audience"

// Default client without extras
client := oapiclient.New[cataas.Client, cataas.ClientWithResponses](
	baseURL, 
	upstreamTimeout
)

// Client with Datadog instrumentation
client := oapiclient.New[cataas.Client, cataas.ClientWithResponses](
	baseURL, 
	upstreamTimeout, 
	oapiclient.WithDatadogApm(&apmInstance)
)

// Client with Google Cloud Platform authentication
client := oapiclient.New[cataas.Client, cataas.ClientWithResponses](
	baseURL, 
	upstreamTimeout, 
	oapiclient.WithGcpOAuth(audience)
)

// Client with Both Datadog instrumentation and Google Cloud Platform authentication
client := oapiclient.New[cataas.Client, cataas.ClientWithResponses](
	baseURL, 
	upstreamTimeout,
	oapiclient.WithDatadogApm(&apmInstance),
	oapiclient.WithGcpOAuth(audience)
)

See examples/example_test.go for a full usage example.

Configuration

This client support multiple configurations which can be used on top of the generated client.

Datadog Support

To enable the Datadog http tracer, use the option WithDatadogApm() which expects an instance of go-datadog-apm.

Google Cloud Platform OAuth support

To enable the Google Cloud Platform Oauth, use the option WithGcpOAuth() which expects the audience as a param.

Directories

Path Synopsis
_mocks
_test
cataas
Package cataas provides primitives to interact with the openapi HTTP API.
Package cataas provides primitives to interact with the openapi HTTP API.
internal
gcp

Jump to

Keyboard shortcuts

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