Documentation
¶
Index ¶
- Constants
- func MarshalDeepObject(i any, paramName string) (string, error)
- func NewAddPetRequest(server string, body addPetJSONRequestBody) (*http.Request, error)
- func NewAddPetRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
- func NewDeletePetRequest(server string, id int64) (*http.Request, error)
- func NewFindPetByIDRequest(server string, id int64) (*http.Request, error)
- func NewFindPetsRequest(server string, params *FindPetsParams) (*http.Request, error)
- func StyleParameter(paramName string, value any, opts ParameterOptions) (string, error)
- type Client
- func (c *Client) AddPet(ctx context.Context, body addPetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
- func (c *Client) AddPetWithBody(ctx context.Context, contentType string, body io.Reader, ...) (*http.Response, error)
- func (c *Client) DeletePet(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*http.Response, error)
- func (c *Client) FindPetByID(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*http.Response, error)
- func (c *Client) FindPets(ctx context.Context, params *FindPetsParams, reqEditors ...RequestEditorFn) (*http.Response, error)
- type ClientHttpError
- type ClientInterface
- type ClientOption
- type Date
- type FindPetsParams
- type HttpRequestDoer
- type ParamLocation
- type ParameterOptions
- type RequestEditorFn
- type SimpleClient
- func (c *SimpleClient) AddPet(ctx context.Context, body addPetJSONRequestBody, reqEditors ...RequestEditorFn) (petstore.Pet, error)
- func (c *SimpleClient) FindPetByID(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (petstore.Pet, error)
- func (c *SimpleClient) FindPets(ctx context.Context, params *FindPetsParams, reqEditors ...RequestEditorFn) ([]petstore.Pet, error)
- type UUID
Constants ¶
const DateFormat = "2006-01-02"
Variables ¶
This section is empty.
Functions ¶
func MarshalDeepObject ¶
MarshalDeepObject marshals an object to deepObject style query parameters.
func NewAddPetRequest ¶
NewAddPetRequest creates a POST request for /pets with application/json body
func NewAddPetRequestWithBody ¶
func NewAddPetRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
NewAddPetRequestWithBody creates a POST request for /pets with any body
func NewDeletePetRequest ¶
NewDeletePetRequest creates a DELETE request for /pets/{id}
func NewFindPetByIDRequest ¶
NewFindPetByIDRequest creates a GET request for /pets/{id}
func NewFindPetsRequest ¶
func NewFindPetsRequest(server string, params *FindPetsParams) (*http.Request, error)
NewFindPetsRequest creates a GET request for /pets
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) AddPet ¶
func (c *Client) AddPet(ctx context.Context, body addPetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
AddPet makes a POST request to /pets with application/json body
func (*Client) AddPetWithBody ¶
func (c *Client) AddPetWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
AddPetWithBody makes a POST request to /pets Creates a new pet
func (*Client) DeletePet ¶
func (c *Client) DeletePet(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*http.Response, error)
DeletePet makes a DELETE request to /pets/{id} Deletes a pet by ID
func (*Client) FindPetByID ¶
func (c *Client) FindPetByID(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*http.Response, error)
FindPetByID makes a GET request to /pets/{id} Returns a pet by ID
func (*Client) FindPets ¶
func (c *Client) FindPets(ctx context.Context, params *FindPetsParams, reqEditors ...RequestEditorFn) (*http.Response, error)
FindPets makes a GET request to /pets Returns all pets
type ClientHttpError ¶
ClientHttpError represents an HTTP error response. The type parameter E is the type of the parsed error body.
func (*ClientHttpError[E]) Error ¶
func (e *ClientHttpError[E]) Error() string
type ClientInterface ¶
type ClientInterface interface {
// FindPets makes a GET request to /pets
FindPets(ctx context.Context, params *FindPetsParams, reqEditors ...RequestEditorFn) (*http.Response, error)
// AddPetWithBody makes a POST request to /pets
AddPetWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
AddPet(ctx context.Context, body addPetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// DeletePet makes a DELETE request to /pets/{id}
DeletePet(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*http.Response, error)
// FindPetByID makes a GET request to /pets/{id}
FindPetByID(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*http.Response, error)
}
ClientInterface is the interface specification for the client.
type ClientOption ¶
ClientOption allows setting custom parameters during construction.
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 Date ¶
func (Date) MarshalJSON ¶
func (Date) MarshalText ¶
MarshalText implements encoding.TextMarshaler for Date.
func (*Date) UnmarshalJSON ¶
func (*Date) UnmarshalText ¶
type FindPetsParams ¶
type FindPetsParams struct {
// tags (optional)
Tags *[]string `form:"tags" json:"tags"`
// limit (optional)
Limit *int32 `form:"limit" json:"limit"`
}
FindPetsParams defines parameters for FindPets.
type HttpRequestDoer ¶
HttpRequestDoer performs HTTP requests. The standard http.Client implements this interface.
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 ¶
RequestEditorFn is the function signature for the RequestEditor callback function.
type SimpleClient ¶
type SimpleClient struct {
*Client
}
SimpleClient wraps Client with typed responses for operations that have unambiguous response types. Methods return the success type directly, and HTTP errors are returned as *ClientHttpError[E] where E is the error type.
func NewSimpleClient ¶
func NewSimpleClient(server string, opts ...ClientOption) (*SimpleClient, error)
NewSimpleClient creates a new SimpleClient which wraps a Client.
func (*SimpleClient) AddPet ¶
func (c *SimpleClient) AddPet(ctx context.Context, body addPetJSONRequestBody, reqEditors ...RequestEditorFn) (petstore.Pet, error)
AddPet makes a POST request to /pets and returns the parsed response. Creates a new pet On success, returns the response body. On HTTP error, returns *ClientHttpError[petstore.Error].
func (*SimpleClient) FindPetByID ¶
func (c *SimpleClient) FindPetByID(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (petstore.Pet, error)
FindPetByID makes a GET request to /pets/{id} and returns the parsed response. Returns a pet by ID On success, returns the response body. On HTTP error, returns *ClientHttpError[petstore.Error].
func (*SimpleClient) FindPets ¶
func (c *SimpleClient) FindPets(ctx context.Context, params *FindPetsParams, reqEditors ...RequestEditorFn) ([]petstore.Pet, error)
FindPets makes a GET request to /pets and returns the parsed response. Returns all pets On success, returns the response body. On HTTP error, returns *ClientHttpError[petstore.Error].