api

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MediaTypeApplicationJSON string = "application/json"
)

Variables

This section is empty.

Functions

func WithServerURL

func WithServerURL(ctx context.Context, u *url.URL) context.Context

WithServerURL sets context key to override server URL.

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) CreateItems

func (c *Client) CreateItems(ctx context.Context, request *CreateItemsRequest) (*CreateItemsRequest, error)

CreateItems invokes createItems operation.

POST /items

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 Color

type Color string

Ref: #/components/schemas/Color

const (
	ColorRed  Color = "red"
	ColorBlue Color = "blue"
)

func (Color) AllValues

func (Color) AllValues() []Color

AllValues returns all Color values.

func (*Color) Decode

func (s *Color) Decode(d *jx.Decoder) error

Decode decodes Color from json.

func (Color) Encode

func (s Color) Encode(e *jx.Encoder)

Encode encodes Color as json.

func (Color) MarshalJSON

func (s Color) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (Color) MarshalText

func (s Color) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Color) UnmarshalJSON

func (s *Color) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Color) UnmarshalText

func (s *Color) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (Color) Validate

func (s Color) Validate() error

type ColorList

type ColorList []Color

func (*ColorList) Decode

func (s *ColorList) Decode(d *jx.Decoder) error

Decode decodes ColorList from json.

func (ColorList) Encode

func (s ColorList) Encode(e *jx.Encoder)

Encode encodes ColorList as json.

func (ColorList) MarshalJSON

func (s ColorList) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*ColorList) UnmarshalJSON

func (s *ColorList) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (ColorList) Validate

func (s ColorList) Validate() error

type CreateItemsRequest

type CreateItemsRequest struct {
	Tags         TagList       `json:"tags"`
	NullableTags OptNilTagList `json:"nullableTags"`
	Colors       ColorList     `json:"colors"`
	Items        ItemList      `json:"items"`
	TagLists     []TagList     `json:"tagLists"`
}

Ref: #/components/schemas/CreateItemsRequest

func (*CreateItemsRequest) Decode

func (s *CreateItemsRequest) Decode(d *jx.Decoder) error

Decode decodes CreateItemsRequest from json.

func (*CreateItemsRequest) Encode

func (s *CreateItemsRequest) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*CreateItemsRequest) GetColors

func (s *CreateItemsRequest) GetColors() ColorList

GetColors returns the value of Colors.

func (*CreateItemsRequest) GetItems

func (s *CreateItemsRequest) GetItems() ItemList

GetItems returns the value of Items.

func (*CreateItemsRequest) GetNullableTags

func (s *CreateItemsRequest) GetNullableTags() OptNilTagList

GetNullableTags returns the value of NullableTags.

func (*CreateItemsRequest) GetTagLists

func (s *CreateItemsRequest) GetTagLists() []TagList

GetTagLists returns the value of TagLists.

func (*CreateItemsRequest) GetTags

func (s *CreateItemsRequest) GetTags() TagList

GetTags returns the value of Tags.

func (*CreateItemsRequest) MarshalJSON

func (s *CreateItemsRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*CreateItemsRequest) SetColors

func (s *CreateItemsRequest) SetColors(val ColorList)

SetColors sets the value of Colors.

func (*CreateItemsRequest) SetItems

func (s *CreateItemsRequest) SetItems(val ItemList)

SetItems sets the value of Items.

func (*CreateItemsRequest) SetNullableTags

func (s *CreateItemsRequest) SetNullableTags(val OptNilTagList)

SetNullableTags sets the value of NullableTags.

func (*CreateItemsRequest) SetTagLists

func (s *CreateItemsRequest) SetTagLists(val []TagList)

SetTagLists sets the value of TagLists.

func (*CreateItemsRequest) SetTags

func (s *CreateItemsRequest) SetTags(val TagList)

SetTags sets the value of Tags.

func (*CreateItemsRequest) UnmarshalJSON

func (s *CreateItemsRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*CreateItemsRequest) Validate

func (s *CreateItemsRequest) Validate() error

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type Handler

type Handler interface {
	// CreateItems implements createItems operation.
	//
	// POST /items
	CreateItems(ctx context.Context, req *CreateItemsRequest) (*CreateItemsRequest, error)
}

Handler handles operations described by OpenAPI v3 specification.

type Invoker

type Invoker interface {
	// CreateItems invokes createItems operation.
	//
	// POST /items
	CreateItems(ctx context.Context, request *CreateItemsRequest) (*CreateItemsRequest, error)
}

Invoker invokes operations described by OpenAPI v3 specification.

type Item

type Item struct {
	Name OptString `json:"name"`
}

Ref: #/components/schemas/Item

func (*Item) Decode

func (s *Item) Decode(d *jx.Decoder) error

Decode decodes Item from json.

func (*Item) Encode

func (s *Item) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Item) GetName

func (s *Item) GetName() OptString

GetName returns the value of Name.

func (*Item) MarshalJSON

func (s *Item) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Item) SetName

func (s *Item) SetName(val OptString)

SetName sets the value of Name.

func (*Item) UnmarshalJSON

func (s *Item) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type ItemList

type ItemList []Item

func (*ItemList) Decode

func (s *ItemList) Decode(d *jx.Decoder) error

Decode decodes ItemList from json.

func (ItemList) Encode

func (s ItemList) Encode(e *jx.Encoder)

Encode encodes ItemList as json.

func (ItemList) MarshalJSON

func (s ItemList) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*ItemList) UnmarshalJSON

func (s *ItemList) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

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

func LabelerFromContext(ctx context.Context) (*Labeler, bool)

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) Add

func (l *Labeler) Add(attrs ...attribute.KeyValue)

Add attributes to the Labeler.

func (*Labeler) AttributeSet

func (l *Labeler) AttributeSet() attribute.Set

AttributeSet returns the attributes added to the Labeler as an attribute.Set.

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OperationName

type OperationName = string

OperationName is the ogen operation name

const (
	CreateItemsOperation OperationName = "CreateItems"
)

type OptNilTagList

type OptNilTagList struct {
	Value TagList
	Set   bool
	Null  bool
}

OptNilTagList is optional nullable TagList.

func NewOptNilTagList

func NewOptNilTagList(v TagList) OptNilTagList

NewOptNilTagList returns new OptNilTagList with value set to v.

func (*OptNilTagList) Decode

func (o *OptNilTagList) Decode(d *jx.Decoder) error

Decode decodes TagList from json.

func (OptNilTagList) Encode

func (o OptNilTagList) Encode(e *jx.Encoder)

Encode encodes TagList as json.

func (OptNilTagList) Get

func (o OptNilTagList) Get() (v TagList, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptNilTagList) IsEmpty

func (o OptNilTagList) IsEmpty() bool

IsEmpty returns true if the field was omitted from the payload (not Set and not Null).

func (OptNilTagList) IsNull

func (o OptNilTagList) IsNull() bool

IsNull returns true if value is Null.

func (OptNilTagList) IsSet

func (o OptNilTagList) IsSet() bool

IsSet returns true if OptNilTagList was set.

func (OptNilTagList) MarshalJSON

func (s OptNilTagList) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptNilTagList) Or

func (o OptNilTagList) Or(d TagList) TagList

Or returns value if set, or given parameter if does not.

func (*OptNilTagList) Reset

func (o *OptNilTagList) Reset()

Reset unsets value.

func (*OptNilTagList) SetTo

func (o *OptNilTagList) SetTo(v TagList)

SetTo sets value to v.

func (*OptNilTagList) SetToNull

func (o *OptNilTagList) SetToNull()

SetToNull sets value to null.

func (*OptNilTagList) UnmarshalJSON

func (s *OptNilTagList) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptString

type OptString struct {
	Value string
	Set   bool
}

OptString is optional string.

func NewOptString

func NewOptString(v string) OptString

NewOptString returns new OptString with value set to v.

func (*OptString) Decode

func (o *OptString) Decode(d *jx.Decoder) error

Decode decodes string from json.

func (OptString) Encode

func (o OptString) Encode(e *jx.Encoder)

Encode encodes string as json.

func (OptString) Get

func (o OptString) Get() (v string, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptString) IsSet

func (o OptString) IsSet() bool

IsSet returns true if OptString was set.

func (OptString) MarshalJSON

func (s OptString) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptString) Or

func (o OptString) Or(d string) string

Or returns value if set, or given parameter if does not.

func (*OptString) Reset

func (o *OptString) Reset()

Reset unsets value.

func (*OptString) SetTo

func (o *OptString) SetTo(v string)

SetTo sets value to v.

func (*OptString) UnmarshalJSON

func (s *OptString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Option

type Option interface {
	ServerOption
	ClientOption
}

Option is config option.

func WithAttributes

func WithAttributes(attributes ...attribute.KeyValue) Option

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) Args

func (r Route) Args() []string

Args returns parsed arguments.

func (Route) Name

func (r Route) Name() string

Name returns ogen operation name.

It is guaranteed to be unique and not empty.

func (Route) OperationGroup

func (r Route) OperationGroup() string

OperationGroup returns the x-ogen-operation-group value.

func (Route) OperationID

func (r Route) OperationID() string

OperationID returns OpenAPI operationId.

func (Route) PathPattern

func (r Route) PathPattern() string

PathPattern returns OpenAPI path.

func (Route) Summary

func (r Route) Summary() string

Summary returns OpenAPI summary.

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.

func (*Server) FindPath

func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool)

FindPath finds Route for given method and URL.

func (*Server) FindRoute

func (s *Server) FindRoute(method, path string) (Route, bool)

FindRoute finds Route for given method and path.

Note: this method does not unescape path or handle reserved characters in path properly. Use FindPath instead.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves http request as defined by OpenAPI v3 specification, calling handler that matches the path or returning not found error.

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 TagList

type TagList []string

func (*TagList) Decode

func (s *TagList) Decode(d *jx.Decoder) error

Decode decodes TagList from json.

func (TagList) Encode

func (s TagList) Encode(e *jx.Encoder)

Encode encodes TagList as json.

func (TagList) MarshalJSON

func (s TagList) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*TagList) UnmarshalJSON

func (s *TagList) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type UnimplementedHandler

type UnimplementedHandler struct{}

UnimplementedHandler is no-op Handler which returns http.ErrNotImplemented.

func (UnimplementedHandler) CreateItems

CreateItems implements createItems operation.

POST /items

Jump to

Keyboard shortcuts

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