Documentation
¶
Index ¶
- Constants
- func BindFormExplodeParam(paramName string, required bool, queryParams url.Values, dest interface{}) error
- func BindSimpleParam(paramName string, paramLocation ParamLocation, value string, dest interface{}) error
- func BindStringToObject(src string, dst interface{}) 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 StyleFormExplodeParam(paramName string, paramLocation ParamLocation, value interface{}) (string, error)
- func StyleSimpleParam(paramName string, paramLocation ParamLocation, value interface{}) (string, error)
- type Binder
- 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 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)
Constants ¶
const DateFormat = "2006-01-02"
DateFormat is the format used for date (without time) parameters.
Variables ¶
This section is empty.
Functions ¶
func BindFormExplodeParam ¶
func BindFormExplodeParam(paramName string, required bool, queryParams url.Values, dest interface{}) error
BindFormExplodeParam binds a form-style parameter with explode to a destination. Form style is the default for query and cookie parameters. This handles the exploded case where arrays come as multiple query params. Arrays: ?param=a¶m=b -> []string{"a", "b"} (values passed as slice) Objects: ?key1=value1&key2=value2 -> struct{Key1, Key2} (queryParams passed)
func BindSimpleParam ¶
func BindSimpleParam(paramName string, paramLocation ParamLocation, value string, dest interface{}) error
BindSimpleParam binds a simple-style parameter without explode to a destination. Simple style is the default for path and header parameters. Arrays: a,b,c -> []string{"a", "b", "c"} Objects: key1,value1,key2,value2 -> struct{Key1, Key2}
func BindStringToObject ¶
BindStringToObject binds a string value to a destination object. It handles primitives, encoding.TextUnmarshaler, and the Binder interface.
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 StyleFormExplodeParam ¶
func StyleFormExplodeParam(paramName string, paramLocation ParamLocation, value interface{}) (string, error)
StyleFormExplodeParam serializes a value using form style (RFC 6570) with exploding. Form style is the default for query and cookie parameters. Primitives: paramName=value Arrays: paramName=a¶mName=b¶mName=c Objects: key1=value1&key2=value2
func StyleSimpleParam ¶
func StyleSimpleParam(paramName string, paramLocation ParamLocation, value interface{}) (string, error)
StyleSimpleParam serializes a value using simple style (RFC 6570) without exploding. Simple style is the default for path and header parameters. Arrays are comma-separated: a,b,c Objects are key,value pairs: key1,value1,key2,value2
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 swagger 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 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 from the server. 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 ¶
Date represents a date (without time) for OpenAPI date format.
func (Date) MarshalText ¶
MarshalText implements encoding.TextMarshaler for Date.
func (*Date) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler for Date.
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 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].