client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package client contains the generated client for the parameter roundtrip test.

Index

Constants

View Source
const DateFormat = "2006-01-02"

Variables

This section is empty.

Functions

func GetOpenAPISpecJSON

func GetOpenAPISpecJSON() ([]byte, error)

GetOpenAPISpecJSON returns the raw OpenAPI spec as JSON bytes.

func MarshalDeepObject

func MarshalDeepObject(i any, paramName string) (string, error)

MarshalDeepObject marshals an object to deepObject style query parameters.

func NewGetContentObjectRequest

func NewGetContentObjectRequest(server string, param string) (*http.Request, error)

NewGetContentObjectRequest creates a GET request for /contentObject/{param}

func NewGetCookieRequest

func NewGetCookieRequest(server string, params *GetCookieParams) (*http.Request, error)

NewGetCookieRequest creates a GET request for /cookie

func NewGetDeepObjectRequest

func NewGetDeepObjectRequest(server string, params *GetDeepObjectParams) (*http.Request, error)

NewGetDeepObjectRequest creates a GET request for /queryDeepObject

func NewGetHeaderRequest

func NewGetHeaderRequest(server string, params *GetHeaderParams) (*http.Request, error)

NewGetHeaderRequest creates a GET request for /header

func NewGetLabelExplodeArrayRequest

func NewGetLabelExplodeArrayRequest(server string, param []int32) (*http.Request, error)

NewGetLabelExplodeArrayRequest creates a GET request for /labelExplodeArray/{.param*}

func NewGetLabelExplodeObjectRequest

func NewGetLabelExplodeObjectRequest(server string, param Object) (*http.Request, error)

NewGetLabelExplodeObjectRequest creates a GET request for /labelExplodeObject/{.param*}

func NewGetLabelExplodePrimitiveRequest

func NewGetLabelExplodePrimitiveRequest(server string, param int32) (*http.Request, error)

NewGetLabelExplodePrimitiveRequest creates a GET request for /labelExplodePrimitive/{.param*}

func NewGetLabelNoExplodeArrayRequest

func NewGetLabelNoExplodeArrayRequest(server string, param []int32) (*http.Request, error)

NewGetLabelNoExplodeArrayRequest creates a GET request for /labelNoExplodeArray/{.param}

func NewGetLabelNoExplodeObjectRequest

func NewGetLabelNoExplodeObjectRequest(server string, param Object) (*http.Request, error)

NewGetLabelNoExplodeObjectRequest creates a GET request for /labelNoExplodeObject/{.param}

func NewGetLabelPrimitiveRequest

func NewGetLabelPrimitiveRequest(server string, param int32) (*http.Request, error)

NewGetLabelPrimitiveRequest creates a GET request for /labelPrimitive/{.param}

func NewGetMatrixExplodeArrayRequest

func NewGetMatrixExplodeArrayRequest(server string, id []int32) (*http.Request, error)

NewGetMatrixExplodeArrayRequest creates a GET request for /matrixExplodeArray/{.id*}

func NewGetMatrixExplodeObjectRequest

func NewGetMatrixExplodeObjectRequest(server string, id Object) (*http.Request, error)

NewGetMatrixExplodeObjectRequest creates a GET request for /matrixExplodeObject/{.id*}

func NewGetMatrixExplodePrimitiveRequest

func NewGetMatrixExplodePrimitiveRequest(server string, id int32) (*http.Request, error)

NewGetMatrixExplodePrimitiveRequest creates a GET request for /matrixExplodePrimitive/{;id*}

func NewGetMatrixNoExplodeArrayRequest

func NewGetMatrixNoExplodeArrayRequest(server string, id []int32) (*http.Request, error)

NewGetMatrixNoExplodeArrayRequest creates a GET request for /matrixNoExplodeArray/{.id}

func NewGetMatrixNoExplodeObjectRequest

func NewGetMatrixNoExplodeObjectRequest(server string, id Object) (*http.Request, error)

NewGetMatrixNoExplodeObjectRequest creates a GET request for /matrixNoExplodeObject/{.id}

func NewGetMatrixPrimitiveRequest

func NewGetMatrixPrimitiveRequest(server string, id int32) (*http.Request, error)

NewGetMatrixPrimitiveRequest creates a GET request for /matrixPrimitive/{;id}

func NewGetPassThroughRequest

func NewGetPassThroughRequest(server string, param string) (*http.Request, error)

NewGetPassThroughRequest creates a GET request for /passThrough/{param}

func NewGetQueryFormRequest

func NewGetQueryFormRequest(server string, params *GetQueryFormParams) (*http.Request, error)

NewGetQueryFormRequest creates a GET request for /queryForm

func NewGetSimpleExplodeArrayRequest

func NewGetSimpleExplodeArrayRequest(server string, param []int32) (*http.Request, error)

NewGetSimpleExplodeArrayRequest creates a GET request for /simpleExplodeArray/{param*}

func NewGetSimpleExplodeObjectRequest

func NewGetSimpleExplodeObjectRequest(server string, param Object) (*http.Request, error)

NewGetSimpleExplodeObjectRequest creates a GET request for /simpleExplodeObject/{param*}

func NewGetSimpleExplodePrimitiveRequest

func NewGetSimpleExplodePrimitiveRequest(server string, param int32) (*http.Request, error)

NewGetSimpleExplodePrimitiveRequest creates a GET request for /simpleExplodePrimitive/{param}

func NewGetSimpleNoExplodeArrayRequest

func NewGetSimpleNoExplodeArrayRequest(server string, param []int32) (*http.Request, error)

NewGetSimpleNoExplodeArrayRequest creates a GET request for /simpleNoExplodeArray/{param}

func NewGetSimpleNoExplodeObjectRequest

func NewGetSimpleNoExplodeObjectRequest(server string, param Object) (*http.Request, error)

NewGetSimpleNoExplodeObjectRequest creates a GET request for /simpleNoExplodeObject/{param}

func NewGetSimplePrimitiveRequest

func NewGetSimplePrimitiveRequest(server string, param int32) (*http.Request, error)

NewGetSimplePrimitiveRequest creates a GET request for /simplePrimitive/{param}

func StyleParameter

func StyleParameter(paramName string, value any, opts ParameterOptions) (string, error)

StyleParameter serializes a Go value into an OpenAPI-styled parameter string. This is the entry point for client-side parameter serialization. The Style field in opts selects the serialization format. If Style is empty, "simple" is assumed.

Types

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the OpenAPI spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

NewClient creates a new Client with reasonable defaults.

func (*Client) GetContentObject

func (c *Client) GetContentObject(ctx context.Context, param string, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetCookie

func (c *Client) GetCookie(ctx context.Context, params *GetCookieParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetDeepObject

func (c *Client) GetDeepObject(ctx context.Context, params *GetDeepObjectParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetHeader

func (c *Client) GetHeader(ctx context.Context, params *GetHeaderParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetLabelExplodeArray

func (c *Client) GetLabelExplodeArray(ctx context.Context, param []int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetLabelExplodeObject

func (c *Client) GetLabelExplodeObject(ctx context.Context, param Object, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetLabelExplodePrimitive

func (c *Client) GetLabelExplodePrimitive(ctx context.Context, param int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetLabelNoExplodeArray

func (c *Client) GetLabelNoExplodeArray(ctx context.Context, param []int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetLabelNoExplodeObject

func (c *Client) GetLabelNoExplodeObject(ctx context.Context, param Object, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetLabelPrimitive

func (c *Client) GetLabelPrimitive(ctx context.Context, param int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetMatrixExplodeArray

func (c *Client) GetMatrixExplodeArray(ctx context.Context, id []int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetMatrixExplodeObject

func (c *Client) GetMatrixExplodeObject(ctx context.Context, id Object, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetMatrixExplodePrimitive

func (c *Client) GetMatrixExplodePrimitive(ctx context.Context, id int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetMatrixNoExplodeArray

func (c *Client) GetMatrixNoExplodeArray(ctx context.Context, id []int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetMatrixNoExplodeObject

func (c *Client) GetMatrixNoExplodeObject(ctx context.Context, id Object, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetMatrixPrimitive

func (c *Client) GetMatrixPrimitive(ctx context.Context, id int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetPassThrough

func (c *Client) GetPassThrough(ctx context.Context, param string, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetQueryForm

func (c *Client) GetQueryForm(ctx context.Context, params *GetQueryFormParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetSimpleExplodeArray

func (c *Client) GetSimpleExplodeArray(ctx context.Context, param []int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetSimpleExplodeObject

func (c *Client) GetSimpleExplodeObject(ctx context.Context, param Object, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetSimpleExplodePrimitive

func (c *Client) GetSimpleExplodePrimitive(ctx context.Context, param int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetSimpleNoExplodeArray

func (c *Client) GetSimpleNoExplodeArray(ctx context.Context, param []int32, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetSimpleNoExplodeObject

func (c *Client) GetSimpleNoExplodeObject(ctx context.Context, param Object, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetSimplePrimitive

func (c *Client) GetSimplePrimitive(ctx context.Context, param int32, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// GetContentObject makes a GET request to /contentObject/{param}
	GetContentObject(ctx context.Context, param string, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetCookie makes a GET request to /cookie
	GetCookie(ctx context.Context, params *GetCookieParams, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetHeader makes a GET request to /header
	GetHeader(ctx context.Context, params *GetHeaderParams, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetLabelExplodeArray makes a GET request to /labelExplodeArray/{.param*}
	GetLabelExplodeArray(ctx context.Context, param []int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetLabelExplodeObject makes a GET request to /labelExplodeObject/{.param*}
	GetLabelExplodeObject(ctx context.Context, param Object, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetLabelExplodePrimitive makes a GET request to /labelExplodePrimitive/{.param*}
	GetLabelExplodePrimitive(ctx context.Context, param int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetLabelNoExplodeArray makes a GET request to /labelNoExplodeArray/{.param}
	GetLabelNoExplodeArray(ctx context.Context, param []int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetLabelNoExplodeObject makes a GET request to /labelNoExplodeObject/{.param}
	GetLabelNoExplodeObject(ctx context.Context, param Object, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetLabelPrimitive makes a GET request to /labelPrimitive/{.param}
	GetLabelPrimitive(ctx context.Context, param int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetMatrixExplodeArray makes a GET request to /matrixExplodeArray/{.id*}
	GetMatrixExplodeArray(ctx context.Context, id []int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetMatrixExplodeObject makes a GET request to /matrixExplodeObject/{.id*}
	GetMatrixExplodeObject(ctx context.Context, id Object, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetMatrixExplodePrimitive makes a GET request to /matrixExplodePrimitive/{;id*}
	GetMatrixExplodePrimitive(ctx context.Context, id int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetMatrixNoExplodeArray makes a GET request to /matrixNoExplodeArray/{.id}
	GetMatrixNoExplodeArray(ctx context.Context, id []int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetMatrixNoExplodeObject makes a GET request to /matrixNoExplodeObject/{.id}
	GetMatrixNoExplodeObject(ctx context.Context, id Object, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetMatrixPrimitive makes a GET request to /matrixPrimitive/{;id}
	GetMatrixPrimitive(ctx context.Context, id int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetPassThrough makes a GET request to /passThrough/{param}
	GetPassThrough(ctx context.Context, param string, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetDeepObject makes a GET request to /queryDeepObject
	GetDeepObject(ctx context.Context, params *GetDeepObjectParams, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetQueryForm makes a GET request to /queryForm
	GetQueryForm(ctx context.Context, params *GetQueryFormParams, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetSimpleExplodeArray makes a GET request to /simpleExplodeArray/{param*}
	GetSimpleExplodeArray(ctx context.Context, param []int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetSimpleExplodeObject makes a GET request to /simpleExplodeObject/{param*}
	GetSimpleExplodeObject(ctx context.Context, param Object, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetSimpleExplodePrimitive makes a GET request to /simpleExplodePrimitive/{param}
	GetSimpleExplodePrimitive(ctx context.Context, param int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetSimpleNoExplodeArray makes a GET request to /simpleNoExplodeArray/{param}
	GetSimpleNoExplodeArray(ctx context.Context, param []int32, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetSimpleNoExplodeObject makes a GET request to /simpleNoExplodeObject/{param}
	GetSimpleNoExplodeObject(ctx context.Context, param Object, reqEditors ...RequestEditorFn) (*http.Response, error)
	// GetSimplePrimitive makes a GET request to /simplePrimitive/{param}
	GetSimplePrimitive(ctx context.Context, param int32, reqEditors ...RequestEditorFn) (*http.Response, error)
}

ClientInterface is the interface specification for the client.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction.

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ComplexObject

type ComplexObject struct {
	Object  Object `form:"Object" json:"Object"`
	ID      int    `form:"Id" json:"Id"`
	IsAdmin bool   `form:"IsAdmin" json:"IsAdmin"`
}

#/components/schemas/ComplexObject

func (*ComplexObject) ApplyDefaults

func (s *ComplexObject) ApplyDefaults()

ApplyDefaults sets default values for fields that are nil.

type Date

type Date struct {
	time.Time
}

func (Date) Format

func (d Date) Format(layout string) string

Format returns the date formatted according to layout.

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (Date) MarshalText

func (d Date) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler for Date.

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

func (*Date) UnmarshalText

func (d *Date) UnmarshalText(data []byte) error

type GetCookieParams

type GetCookieParams struct {
	// p (cookie)
	P *int32
	// ep (cookie)
	Ep *int32
	// ea (cookie)
	Ea *[]int32
	// a (cookie)
	A *[]int32
	// eo (cookie)
	Eo *Object
	// o (cookie)
	O *Object
	// co (cookie)
	Co *string
}

GetCookieParams defines parameters for GetCookie.

type GetDeepObjectParams

type GetDeepObjectParams struct {
	// deepObj (required)
	DeepObj ComplexObject `form:"deepObj" json:"deepObj"`
}

GetDeepObjectParams defines parameters for GetDeepObject.

type GetHeaderParams

type GetHeaderParams struct {
	// X-Primitive (header)
	XPrimitive *int32
	// X-Primitive-Exploded (header)
	XPrimitiveExploded *int32
	// X-Array-Exploded (header)
	XArrayExploded *[]int32
	// X-Array (header)
	XArray *[]int32
	// X-Object-Exploded (header)
	XObjectExploded *Object
	// X-Object (header)
	XObject *Object
	// X-Complex-Object (header)
	XComplexObject *string
}

GetHeaderParams defines parameters for GetHeader.

type GetQueryFormParams

type GetQueryFormParams struct {
	// ea (optional)
	Ea *[]int32 `form:"ea" json:"ea"`
	// a (optional)
	A *[]int32 `form:"a" json:"a"`
	// eo (optional)
	Eo *Object `form:"eo" json:"eo"`
	// o (optional)
	O *Object `form:"o" json:"o"`
	// ep (optional)
	Ep *int32 `form:"ep" json:"ep"`
	// p (optional)
	P *int32 `form:"p" json:"p"`
	// ps (optional)
	Ps *string `form:"ps" json:"ps"`
	// co (optional)
	Co *string `form:"co" json:"co"`
}

GetQueryFormParams defines parameters for GetQueryForm.

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpRequestDoer performs HTTP requests. The standard http.Client implements this interface.

type Object

type Object struct {
	Role      string `form:"role" json:"role"`
	FirstName string `form:"firstName" json:"firstName"`
}

#/components/schemas/Object

func (*Object) ApplyDefaults

func (s *Object) ApplyDefaults()

ApplyDefaults sets default values for fields that are nil.

type ParamLocation

type ParamLocation int

ParamLocation indicates where a parameter is located in an HTTP request.

const (
	ParamLocationUndefined ParamLocation = iota
	ParamLocationQuery
	ParamLocationPath
	ParamLocationHeader
	ParamLocationCookie
)

type ParameterOptions

type ParameterOptions struct {
	Style         string        // OpenAPI style: "simple", "form", "label", "matrix", "deepObject", "pipeDelimited", "spaceDelimited"
	ParamLocation ParamLocation // Where the parameter appears: query, path, header, cookie
	Explode       bool
	Required      bool
	Type          string // OpenAPI type: "string", "integer", "array", "object"
	Format        string // OpenAPI format: "int32", "date-time", etc.
	AllowReserved bool   // When true, reserved characters in query values are not percent-encoded
}

ParameterOptions carries OpenAPI parameter metadata to bind and style functions so they can handle style dispatch, explode, required, type-aware coercions, and location-aware escaping from a single uniform call site. All fields have sensible zero-value defaults.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function.

type UUID

type UUID = uuid.UUID

Jump to

Keyboard shortcuts

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