Documentation
¶
Index ¶
- Constants
- func WithServerURL(ctx context.Context, u *url.URL) context.Context
- type Client
- type ClientOption
- type ErrResp
- type ErrRespStatusCode
- type ErrorHandler
- type GetItemByIdID
- type GetItemByIdIDType
- type GetItemByIdOK
- func (s *GetItemByIdOK) Decode(d *jx.Decoder) error
- func (s *GetItemByIdOK) Encode(e *jx.Encoder)
- func (s *GetItemByIdOK) GetID() OptString
- func (s *GetItemByIdOK) GetMessage() OptString
- func (s *GetItemByIdOK) MarshalJSON() ([]byte, error)
- func (s *GetItemByIdOK) SetID(val OptString)
- func (s *GetItemByIdOK) SetMessage(val OptString)
- func (s *GetItemByIdOK) UnmarshalJSON(data []byte) error
- type GetItemByIdParams
- type Handler
- type Invoker
- type Labeler
- type Middleware
- type OperationName
- type OptSearchItemsFilter
- type OptString
- func (o *OptString) Decode(d *jx.Decoder) error
- func (o OptString) Encode(e *jx.Encoder)
- func (o OptString) Get() (v string, ok bool)
- func (o OptString) IsSet() bool
- func (s OptString) MarshalJSON() ([]byte, error)
- func (o OptString) Or(d string) string
- func (o *OptString) Reset()
- func (o *OptString) SetTo(v string)
- func (s *OptString) UnmarshalJSON(data []byte) error
- type Option
- type Route
- type SearchItemsFilter
- type SearchItemsFilterType
- type SearchItemsOK
- func (s *SearchItemsOK) Decode(d *jx.Decoder) error
- func (s *SearchItemsOK) Encode(e *jx.Encoder)
- func (s *SearchItemsOK) GetResults() []string
- func (s *SearchItemsOK) MarshalJSON() ([]byte, error)
- func (s *SearchItemsOK) SetResults(val []string)
- func (s *SearchItemsOK) UnmarshalJSON(data []byte) error
- type SearchItemsParams
- type Server
- type ServerOption
- func WithErrorHandler(h ErrorHandler) ServerOption
- func WithMaxMultipartMemory(max int64) ServerOption
- func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption
- func WithMiddleware(m ...Middleware) ServerOption
- func WithNotFound(notFound http.HandlerFunc) ServerOption
- func WithPathPrefix(prefix string) ServerOption
- type UnimplementedHandler
- func (UnimplementedHandler) GetItemById(ctx context.Context, params GetItemByIdParams) (r *GetItemByIdOK, _ error)
- func (UnimplementedHandler) NewError(ctx context.Context, err error) (r *ErrRespStatusCode)
- func (UnimplementedHandler) SearchItems(ctx context.Context, params SearchItemsParams) (r *SearchItemsOK, _ error)
Constants ¶
const (
MediaTypeApplicationJSON string = "application/json"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements OAS client.
func NewClient ¶
func NewClient(serverURL string, opts ...ClientOption) (*Client, error)
NewClient initializes new Client defined by OAS.
func (*Client) GetItemById ¶
func (c *Client) GetItemById(ctx context.Context, params GetItemByIdParams) (*GetItemByIdOK, error)
GetItemById invokes getItemById operation.
GET /items/{id}
func (*Client) SearchItems ¶
func (c *Client) SearchItems(ctx context.Context, params SearchItemsParams) (*SearchItemsOK, error)
SearchItems invokes searchItems operation.
GET /search
type ClientOption ¶
type ClientOption interface {
// contains filtered or unexported methods
}
ClientOption is client config option.
func WithClient ¶
func WithClient(client ht.Client) ClientOption
WithClient specifies http client to use.
type ErrResp ¶
type ErrResp struct {
Error OptString `json:"error"`
}
func (*ErrResp) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*ErrResp) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type ErrRespStatusCode ¶
ErrRespStatusCode wraps ErrResp with StatusCode.
func (*ErrRespStatusCode) Error ¶
func (s *ErrRespStatusCode) Error() string
func (*ErrRespStatusCode) GetResponse ¶
func (s *ErrRespStatusCode) GetResponse() ErrResp
GetResponse returns the value of Response.
func (*ErrRespStatusCode) GetStatusCode ¶
func (s *ErrRespStatusCode) GetStatusCode() int
GetStatusCode returns the value of StatusCode.
func (*ErrRespStatusCode) SetResponse ¶
func (s *ErrRespStatusCode) SetResponse(val ErrResp)
SetResponse sets the value of Response.
func (*ErrRespStatusCode) SetStatusCode ¶
func (s *ErrRespStatusCode) SetStatusCode(val int)
SetStatusCode sets the value of StatusCode.
type GetItemByIdID ¶
type GetItemByIdID struct {
// Type selects the active sum variant, switch on this field.
Type GetItemByIdIDType
UUID uuid.UUID
Int int
}
GetItemByIdID represents sum type.
func NewIntGetItemByIdID ¶
func NewIntGetItemByIdID(v int) GetItemByIdID
NewIntGetItemByIdID returns new GetItemByIdID from int.
func NewUUIDGetItemByIdID ¶
func NewUUIDGetItemByIdID(v uuid.UUID) GetItemByIdID
NewUUIDGetItemByIdID returns new GetItemByIdID from uuid.UUID.
func (GetItemByIdID) GetInt ¶
func (s GetItemByIdID) GetInt() (v int, ok bool)
GetInt returns int and true boolean if GetItemByIdID is int.
func (GetItemByIdID) GetUUID ¶
func (s GetItemByIdID) GetUUID() (v uuid.UUID, ok bool)
GetUUID returns uuid.UUID and true boolean if GetItemByIdID is uuid.UUID.
func (GetItemByIdID) IsInt ¶
func (s GetItemByIdID) IsInt() bool
IsInt reports whether GetItemByIdID is int.
func (GetItemByIdID) IsUUID ¶
func (s GetItemByIdID) IsUUID() bool
IsUUID reports whether GetItemByIdID is uuid.UUID.
func (*GetItemByIdID) SetInt ¶
func (s *GetItemByIdID) SetInt(v int)
SetInt sets GetItemByIdID to int.
func (*GetItemByIdID) SetUUID ¶
func (s *GetItemByIdID) SetUUID(v uuid.UUID)
SetUUID sets GetItemByIdID to uuid.UUID.
type GetItemByIdIDType ¶
type GetItemByIdIDType string
GetItemByIdIDType is oneOf type of GetItemByIdID.
const ( UUIDGetItemByIdID GetItemByIdIDType = "uuid.UUID" IntGetItemByIdID GetItemByIdIDType = "int" )
Possible values for GetItemByIdIDType.
type GetItemByIdOK ¶
func (*GetItemByIdOK) Decode ¶
func (s *GetItemByIdOK) Decode(d *jx.Decoder) error
Decode decodes GetItemByIdOK from json.
func (*GetItemByIdOK) Encode ¶
func (s *GetItemByIdOK) Encode(e *jx.Encoder)
Encode implements json.Marshaler.
func (*GetItemByIdOK) GetID ¶
func (s *GetItemByIdOK) GetID() OptString
GetID returns the value of ID.
func (*GetItemByIdOK) GetMessage ¶
func (s *GetItemByIdOK) GetMessage() OptString
GetMessage returns the value of Message.
func (*GetItemByIdOK) MarshalJSON ¶
func (s *GetItemByIdOK) MarshalJSON() ([]byte, error)
MarshalJSON implements stdjson.Marshaler.
func (*GetItemByIdOK) SetID ¶
func (s *GetItemByIdOK) SetID(val OptString)
SetID sets the value of ID.
func (*GetItemByIdOK) SetMessage ¶
func (s *GetItemByIdOK) SetMessage(val OptString)
SetMessage sets the value of Message.
func (*GetItemByIdOK) UnmarshalJSON ¶
func (s *GetItemByIdOK) UnmarshalJSON(data []byte) error
UnmarshalJSON implements stdjson.Unmarshaler.
type GetItemByIdParams ¶
type GetItemByIdParams struct {
// Item ID - can be UUID or integer.
ID GetItemByIdID
}
GetItemByIdParams is parameters of getItemById operation.
type Handler ¶
type Handler interface {
// GetItemById implements getItemById operation.
//
// GET /items/{id}
GetItemById(ctx context.Context, params GetItemByIdParams) (*GetItemByIdOK, error)
// SearchItems implements searchItems operation.
//
// GET /search
SearchItems(ctx context.Context, params SearchItemsParams) (*SearchItemsOK, error)
// NewError creates *ErrRespStatusCode from error returned by handler.
//
// Used for common default response.
NewError(ctx context.Context, err error) *ErrRespStatusCode
}
Handler handles operations described by OpenAPI v3 specification.
type Invoker ¶
type Invoker interface {
// GetItemById invokes getItemById operation.
//
// GET /items/{id}
GetItemById(ctx context.Context, params GetItemByIdParams) (*GetItemByIdOK, error)
// SearchItems invokes searchItems operation.
//
// GET /search
SearchItems(ctx context.Context, params SearchItemsParams) (*SearchItemsOK, error)
}
Invoker invokes operations described by OpenAPI v3 specification.
type Labeler ¶
type Labeler struct {
// contains filtered or unexported fields
}
Labeler is used to allow adding custom attributes to the server request metrics.
func LabelerFromContext ¶
LabelerFromContext retrieves the Labeler from the provided context, if present.
If no Labeler was found in the provided context a new, empty Labeler is returned and the second return value is false. In this case it is safe to use the Labeler but any attributes added to it will not be used.
func (*Labeler) AttributeSet ¶
AttributeSet returns the attributes added to the Labeler as an attribute.Set.
type OperationName ¶
type OperationName = string
OperationName is the ogen operation name
const ( GetItemByIdOperation OperationName = "GetItemById" SearchItemsOperation OperationName = "SearchItems" )
type OptSearchItemsFilter ¶
type OptSearchItemsFilter struct {
Value SearchItemsFilter
Set bool
}
OptSearchItemsFilter is optional SearchItemsFilter.
func NewOptSearchItemsFilter ¶
func NewOptSearchItemsFilter(v SearchItemsFilter) OptSearchItemsFilter
NewOptSearchItemsFilter returns new OptSearchItemsFilter with value set to v.
func (OptSearchItemsFilter) Get ¶
func (o OptSearchItemsFilter) Get() (v SearchItemsFilter, ok bool)
Get returns value and boolean that denotes whether value was set.
func (OptSearchItemsFilter) IsSet ¶
func (o OptSearchItemsFilter) IsSet() bool
IsSet returns true if OptSearchItemsFilter was set.
func (OptSearchItemsFilter) Or ¶
func (o OptSearchItemsFilter) Or(d SearchItemsFilter) SearchItemsFilter
Or returns value if set, or given parameter if does not.
func (*OptSearchItemsFilter) SetTo ¶
func (o *OptSearchItemsFilter) SetTo(v SearchItemsFilter)
SetTo sets value to v.
type OptString ¶
OptString is optional string.
func NewOptString ¶
NewOptString returns new OptString with value set to v.
func (OptString) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*OptString) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type Option ¶
type Option interface {
ServerOption
ClientOption
}
Option is config option.
func WithAttributes ¶
WithAttributes specifies default otel attributes.
func WithMeterProvider ¶
func WithMeterProvider(provider metric.MeterProvider) Option
WithMeterProvider specifies a meter provider to use for creating a meter.
If none is specified, the otel.GetMeterProvider() is used.
func WithTracerProvider ¶
func WithTracerProvider(provider trace.TracerProvider) Option
WithTracerProvider specifies a tracer provider to use for creating a tracer.
If none is specified, the global provider is used.
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route is route object.
func (Route) OperationGroup ¶
OperationGroup returns the x-ogen-operation-group value.
func (Route) OperationID ¶
OperationID returns OpenAPI operationId.
type SearchItemsFilter ¶
type SearchItemsFilter struct {
// Type selects the active sum variant, switch on this field.
Type SearchItemsFilterType
String string
Int int
}
SearchItemsFilter represents sum type.
func NewIntSearchItemsFilter ¶
func NewIntSearchItemsFilter(v int) SearchItemsFilter
NewIntSearchItemsFilter returns new SearchItemsFilter from int.
func NewStringSearchItemsFilter ¶
func NewStringSearchItemsFilter(v string) SearchItemsFilter
NewStringSearchItemsFilter returns new SearchItemsFilter from string.
func (SearchItemsFilter) GetInt ¶
func (s SearchItemsFilter) GetInt() (v int, ok bool)
GetInt returns int and true boolean if SearchItemsFilter is int.
func (SearchItemsFilter) GetString ¶
func (s SearchItemsFilter) GetString() (v string, ok bool)
GetString returns string and true boolean if SearchItemsFilter is string.
func (SearchItemsFilter) IsInt ¶
func (s SearchItemsFilter) IsInt() bool
IsInt reports whether SearchItemsFilter is int.
func (SearchItemsFilter) IsString ¶
func (s SearchItemsFilter) IsString() bool
IsString reports whether SearchItemsFilter is string.
func (*SearchItemsFilter) SetInt ¶
func (s *SearchItemsFilter) SetInt(v int)
SetInt sets SearchItemsFilter to int.
func (*SearchItemsFilter) SetString ¶
func (s *SearchItemsFilter) SetString(v string)
SetString sets SearchItemsFilter to string.
type SearchItemsFilterType ¶
type SearchItemsFilterType string
SearchItemsFilterType is oneOf type of SearchItemsFilter.
const ( StringSearchItemsFilter SearchItemsFilterType = "string" IntSearchItemsFilter SearchItemsFilterType = "int" )
Possible values for SearchItemsFilterType.
type SearchItemsOK ¶
type SearchItemsOK struct {
Results []string `json:"results"`
}
func (*SearchItemsOK) Decode ¶
func (s *SearchItemsOK) Decode(d *jx.Decoder) error
Decode decodes SearchItemsOK from json.
func (*SearchItemsOK) Encode ¶
func (s *SearchItemsOK) Encode(e *jx.Encoder)
Encode implements json.Marshaler.
func (*SearchItemsOK) GetResults ¶
func (s *SearchItemsOK) GetResults() []string
GetResults returns the value of Results.
func (*SearchItemsOK) MarshalJSON ¶
func (s *SearchItemsOK) MarshalJSON() ([]byte, error)
MarshalJSON implements stdjson.Marshaler.
func (*SearchItemsOK) SetResults ¶
func (s *SearchItemsOK) SetResults(val []string)
SetResults sets the value of Results.
func (*SearchItemsOK) UnmarshalJSON ¶
func (s *SearchItemsOK) UnmarshalJSON(data []byte) error
UnmarshalJSON implements stdjson.Unmarshaler.
type SearchItemsParams ¶
type SearchItemsParams struct {
// Filter value - can be string or number.
Filter OptSearchItemsFilter `json:",omitempty,omitzero"`
}
SearchItemsParams is parameters of searchItems operation.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements http server based on OpenAPI v3 specification and calls Handler to handle requests.
func NewServer ¶
func NewServer(h Handler, opts ...ServerOption) (*Server, error)
NewServer creates new Server.
type ServerOption ¶
type ServerOption interface {
// contains filtered or unexported methods
}
ServerOption is server config option.
func WithErrorHandler ¶
func WithErrorHandler(h ErrorHandler) ServerOption
WithErrorHandler specifies error handler to use.
func WithMaxMultipartMemory ¶
func WithMaxMultipartMemory(max int64) ServerOption
WithMaxMultipartMemory specifies limit of memory for storing file parts. File parts which can't be stored in memory will be stored on disk in temporary files.
func WithMethodNotAllowed ¶
func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption
WithMethodNotAllowed specifies Method Not Allowed handler to use.
func WithMiddleware ¶
func WithMiddleware(m ...Middleware) ServerOption
WithMiddleware specifies middlewares to use.
func WithNotFound ¶
func WithNotFound(notFound http.HandlerFunc) ServerOption
WithNotFound specifies Not Found handler to use.
func WithPathPrefix ¶
func WithPathPrefix(prefix string) ServerOption
WithPathPrefix specifies server path prefix.
type UnimplementedHandler ¶
type UnimplementedHandler struct{}
UnimplementedHandler is no-op Handler which returns http.ErrNotImplemented.
func (UnimplementedHandler) GetItemById ¶
func (UnimplementedHandler) GetItemById(ctx context.Context, params GetItemByIdParams) (r *GetItemByIdOK, _ error)
GetItemById implements getItemById operation.
GET /items/{id}
func (UnimplementedHandler) NewError ¶
func (UnimplementedHandler) NewError(ctx context.Context, err error) (r *ErrRespStatusCode)
NewError creates *ErrRespStatusCode from error returned by handler.
Used for common default response.
func (UnimplementedHandler) SearchItems ¶
func (UnimplementedHandler) SearchItems(ctx context.Context, params SearchItemsParams) (r *SearchItemsOK, _ error)
SearchItems implements searchItems operation.
GET /search
Source Files
¶
- oas_cfg_gen.go
- oas_client_gen.go
- oas_handlers_gen.go
- oas_json_gen.go
- oas_labeler_gen.go
- oas_mediatypes_gen.go
- oas_middleware_gen.go
- oas_operations_gen.go
- oas_parameters_gen.go
- oas_request_decoders_gen.go
- oas_request_encoders_gen.go
- oas_response_decoders_gen.go
- oas_response_encoders_gen.go
- oas_router_gen.go
- oas_schemas_gen.go
- oas_server_gen.go
- oas_unimplemented_gen.go