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: 25 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) PostEnums

func (c *Client) PostEnums(ctx context.Context, request *Enums, params PostEnumsParams) (*Enums, error)

PostEnums invokes postEnums operation.

POST /enums/{id}

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 Enums

type Enums struct {
	UUID UUIDEnum     `json:"uuid"`
	IP   OptEnumsIP   `json:"ip"`
	URI  OptEnumsURI  `json:"uri"`
	Byte OptEnumsByte `json:"byte"`
}

Ref: #/components/schemas/Enums

func (*Enums) Decode

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

Decode decodes Enums from json.

func (*Enums) Encode

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

Encode implements json.Marshaler.

func (*Enums) GetByte

func (s *Enums) GetByte() OptEnumsByte

GetByte returns the value of Byte.

func (*Enums) GetIP

func (s *Enums) GetIP() OptEnumsIP

GetIP returns the value of IP.

func (*Enums) GetURI

func (s *Enums) GetURI() OptEnumsURI

GetURI returns the value of URI.

func (*Enums) GetUUID

func (s *Enums) GetUUID() UUIDEnum

GetUUID returns the value of UUID.

func (*Enums) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Enums) SetByte

func (s *Enums) SetByte(val OptEnumsByte)

SetByte sets the value of Byte.

func (*Enums) SetIP

func (s *Enums) SetIP(val OptEnumsIP)

SetIP sets the value of IP.

func (*Enums) SetURI

func (s *Enums) SetURI(val OptEnumsURI)

SetURI sets the value of URI.

func (*Enums) SetUUID

func (s *Enums) SetUUID(val UUIDEnum)

SetUUID sets the value of UUID.

func (*Enums) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Enums) Validate

func (s *Enums) Validate() error

type EnumsByte

type EnumsByte string
const (
	EnumsByteAGVsbG8 EnumsByte = "aGVsbG8="
)

func (EnumsByte) AllValues

func (EnumsByte) AllValues() []EnumsByte

AllValues returns all EnumsByte values.

func (*EnumsByte) Decode

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

Decode decodes EnumsByte from json.

func (EnumsByte) Encode

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

Encode encodes EnumsByte as json.

func (EnumsByte) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (EnumsByte) MarshalText

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

MarshalText implements encoding.TextMarshaler.

func (*EnumsByte) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*EnumsByte) UnmarshalText

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

UnmarshalText implements encoding.TextUnmarshaler.

func (EnumsByte) Validate

func (s EnumsByte) Validate() error

type EnumsIP

type EnumsIP string
const (
	EnumsIP127001 EnumsIP = "127.0.0.1"
	EnumsIP1      EnumsIP = "::1"
)

func (EnumsIP) AllValues

func (EnumsIP) AllValues() []EnumsIP

AllValues returns all EnumsIP values.

func (*EnumsIP) Decode

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

Decode decodes EnumsIP from json.

func (EnumsIP) Encode

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

Encode encodes EnumsIP as json.

func (EnumsIP) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (EnumsIP) MarshalText

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

MarshalText implements encoding.TextMarshaler.

func (*EnumsIP) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*EnumsIP) UnmarshalText

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

UnmarshalText implements encoding.TextUnmarshaler.

func (EnumsIP) Validate

func (s EnumsIP) Validate() error

type EnumsURI

type EnumsURI string
const (
	EnumsURIHTTPSExampleCom EnumsURI = "https://example.com/"
)

func (EnumsURI) AllValues

func (EnumsURI) AllValues() []EnumsURI

AllValues returns all EnumsURI values.

func (*EnumsURI) Decode

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

Decode decodes EnumsURI from json.

func (EnumsURI) Encode

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

Encode encodes EnumsURI as json.

func (EnumsURI) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (EnumsURI) MarshalText

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

MarshalText implements encoding.TextMarshaler.

func (*EnumsURI) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*EnumsURI) UnmarshalText

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

UnmarshalText implements encoding.TextUnmarshaler.

func (EnumsURI) Validate

func (s EnumsURI) Validate() error

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type Handler

type Handler interface {
	// PostEnums implements postEnums operation.
	//
	// POST /enums/{id}
	PostEnums(ctx context.Context, req *Enums, params PostEnumsParams) (*Enums, error)
}

Handler handles operations described by OpenAPI v3 specification.

type Int32Enum

type Int32Enum string

Ref: #/components/schemas/Int32Enum

const (
	Int32Enum1 Int32Enum = "1"
	Int32Enum2 Int32Enum = "2"
)

func (Int32Enum) AllValues

func (Int32Enum) AllValues() []Int32Enum

AllValues returns all Int32Enum values.

func (Int32Enum) MarshalText

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

MarshalText implements encoding.TextMarshaler.

func (*Int32Enum) UnmarshalText

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

UnmarshalText implements encoding.TextUnmarshaler.

func (Int32Enum) Validate

func (s Int32Enum) Validate() error

type Invoker

type Invoker interface {
	// PostEnums invokes postEnums operation.
	//
	// POST /enums/{id}
	PostEnums(ctx context.Context, request *Enums, params PostEnumsParams) (*Enums, 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

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 MACEnum

type MACEnum string

Ref: #/components/schemas/MACEnum

const (
	MACEnum112233445566 MACEnum = "11:22:33:44:55:66"
)

func (MACEnum) AllValues

func (MACEnum) AllValues() []MACEnum

AllValues returns all MACEnum values.

func (MACEnum) MarshalText

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

MarshalText implements encoding.TextMarshaler.

func (*MACEnum) UnmarshalText

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

UnmarshalText implements encoding.TextUnmarshaler.

func (MACEnum) Validate

func (s MACEnum) Validate() error

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OperationName

type OperationName = string

OperationName is the ogen operation name

const (
	PostEnumsOperation OperationName = "PostEnums"
)

type OptEnumsByte

type OptEnumsByte struct {
	Value EnumsByte
	Set   bool
}

OptEnumsByte is optional EnumsByte.

func NewOptEnumsByte

func NewOptEnumsByte(v EnumsByte) OptEnumsByte

NewOptEnumsByte returns new OptEnumsByte with value set to v.

func (*OptEnumsByte) Decode

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

Decode decodes EnumsByte from json.

func (OptEnumsByte) Encode

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

Encode encodes EnumsByte as json.

func (OptEnumsByte) Get

func (o OptEnumsByte) Get() (v EnumsByte, ok bool)

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

func (OptEnumsByte) IsSet

func (o OptEnumsByte) IsSet() bool

IsSet returns true if OptEnumsByte was set.

func (OptEnumsByte) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptEnumsByte) Or

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

func (*OptEnumsByte) Reset

func (o *OptEnumsByte) Reset()

Reset unsets value.

func (*OptEnumsByte) SetTo

func (o *OptEnumsByte) SetTo(v EnumsByte)

SetTo sets value to v.

func (*OptEnumsByte) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptEnumsIP

type OptEnumsIP struct {
	Value EnumsIP
	Set   bool
}

OptEnumsIP is optional EnumsIP.

func NewOptEnumsIP

func NewOptEnumsIP(v EnumsIP) OptEnumsIP

NewOptEnumsIP returns new OptEnumsIP with value set to v.

func (*OptEnumsIP) Decode

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

Decode decodes EnumsIP from json.

func (OptEnumsIP) Encode

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

Encode encodes EnumsIP as json.

func (OptEnumsIP) Get

func (o OptEnumsIP) Get() (v EnumsIP, ok bool)

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

func (OptEnumsIP) IsSet

func (o OptEnumsIP) IsSet() bool

IsSet returns true if OptEnumsIP was set.

func (OptEnumsIP) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptEnumsIP) Or

func (o OptEnumsIP) Or(d EnumsIP) EnumsIP

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

func (*OptEnumsIP) Reset

func (o *OptEnumsIP) Reset()

Reset unsets value.

func (*OptEnumsIP) SetTo

func (o *OptEnumsIP) SetTo(v EnumsIP)

SetTo sets value to v.

func (*OptEnumsIP) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptEnumsURI

type OptEnumsURI struct {
	Value EnumsURI
	Set   bool
}

OptEnumsURI is optional EnumsURI.

func NewOptEnumsURI

func NewOptEnumsURI(v EnumsURI) OptEnumsURI

NewOptEnumsURI returns new OptEnumsURI with value set to v.

func (*OptEnumsURI) Decode

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

Decode decodes EnumsURI from json.

func (OptEnumsURI) Encode

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

Encode encodes EnumsURI as json.

func (OptEnumsURI) Get

func (o OptEnumsURI) Get() (v EnumsURI, ok bool)

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

func (OptEnumsURI) IsSet

func (o OptEnumsURI) IsSet() bool

IsSet returns true if OptEnumsURI was set.

func (OptEnumsURI) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptEnumsURI) Or

func (o OptEnumsURI) Or(d EnumsURI) EnumsURI

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

func (*OptEnumsURI) Reset

func (o *OptEnumsURI) Reset()

Reset unsets value.

func (*OptEnumsURI) SetTo

func (o *OptEnumsURI) SetTo(v EnumsURI)

SetTo sets value to v.

func (*OptEnumsURI) UnmarshalJSON

func (s *OptEnumsURI) 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 PostEnumsParams

type PostEnumsParams struct {
	ID  UUIDEnum
	MAC MACEnum
	Num Int32Enum
}

PostEnumsParams is parameters of postEnums operation.

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 UUIDEnum

type UUIDEnum string

Ref: #/components/schemas/UUIDEnum

const (
	UUIDEnum0b8e3c4e7f0a4a8e9a2b3c1d2e4f5a6b UUIDEnum = "0b8e3c4e-7f0a-4a8e-9a2b-3c1d2e4f5a6b"
	UUIDEnum6ba7b8109dad11d180b400c04fd430c8 UUIDEnum = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
)

func (UUIDEnum) AllValues

func (UUIDEnum) AllValues() []UUIDEnum

AllValues returns all UUIDEnum values.

func (*UUIDEnum) Decode

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

Decode decodes UUIDEnum from json.

func (UUIDEnum) Encode

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

Encode encodes UUIDEnum as json.

func (UUIDEnum) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (UUIDEnum) MarshalText

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

MarshalText implements encoding.TextMarshaler.

func (*UUIDEnum) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*UUIDEnum) UnmarshalText

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

UnmarshalText implements encoding.TextUnmarshaler.

func (UUIDEnum) Validate

func (s UUIDEnum) Validate() error

type UnimplementedHandler

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) PostEnums

func (UnimplementedHandler) PostEnums(ctx context.Context, req *Enums, params PostEnumsParams) (r *Enums, _ error)

PostEnums implements postEnums operation.

POST /enums/{id}

Jump to

Keyboard shortcuts

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