api

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

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

func (c *Client) CreateGoldenItems(ctx context.Context, request *CreateGoldenItemsReq) (*CreateGoldenItemsOK, error)

CreateGoldenItems invokes createGoldenItems operation.

Create items for golden file testing.

POST /golden/test

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 CreateGoldenItemsOK

type CreateGoldenItemsOK struct {
	Created OptInt `json:"created"`
}

func (*CreateGoldenItemsOK) Decode

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

Decode decodes CreateGoldenItemsOK from json.

func (*CreateGoldenItemsOK) Encode

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

Encode implements json.Marshaler.

func (*CreateGoldenItemsOK) GetCreated

func (s *CreateGoldenItemsOK) GetCreated() OptInt

GetCreated returns the value of Created.

func (*CreateGoldenItemsOK) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*CreateGoldenItemsOK) SetCreated

func (s *CreateGoldenItemsOK) SetCreated(val OptInt)

SetCreated sets the value of Created.

func (*CreateGoldenItemsOK) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type CreateGoldenItemsReq

type CreateGoldenItemsReq struct {
	Items []GoldenItem `json:"items"`
}

func (*CreateGoldenItemsReq) Decode

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

Decode decodes CreateGoldenItemsReq from json.

func (*CreateGoldenItemsReq) Encode

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

Encode implements json.Marshaler.

func (*CreateGoldenItemsReq) GetItems

func (s *CreateGoldenItemsReq) GetItems() []GoldenItem

GetItems returns the value of Items.

func (*CreateGoldenItemsReq) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*CreateGoldenItemsReq) SetItems

func (s *CreateGoldenItemsReq) SetItems(val []GoldenItem)

SetItems sets the value of Items.

func (*CreateGoldenItemsReq) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*CreateGoldenItemsReq) Validate

func (s *CreateGoldenItemsReq) Validate() error

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type GoldenItem

type GoldenItem struct {
	ID          string                  `json:"id"`
	Name        string                  `json:"name"`
	Description OptString               `json:"description"`
	ExternalRef OptNilString            `json:"externalRef"`
	Tags        []string                `json:"tags"`
	Attributes  OptGoldenItemAttributes `json:"attributes"`
	Metadata    OptMetadata             `json:"metadata"`
}

Reference item with diverse field types. Ref: #/components/schemas/GoldenItem

func (*GoldenItem) Decode

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

Decode decodes GoldenItem from json.

func (*GoldenItem) Encode

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

Encode implements json.Marshaler.

func (GoldenItem) Equal

func (a GoldenItem) Equal(b GoldenItem, depth int) bool

Equal compares two GoldenItem instances for equality. The depth parameter prevents infinite recursion on nested objects.

func (*GoldenItem) GetAttributes

func (s *GoldenItem) GetAttributes() OptGoldenItemAttributes

GetAttributes returns the value of Attributes.

func (*GoldenItem) GetDescription

func (s *GoldenItem) GetDescription() OptString

GetDescription returns the value of Description.

func (*GoldenItem) GetExternalRef

func (s *GoldenItem) GetExternalRef() OptNilString

GetExternalRef returns the value of ExternalRef.

func (*GoldenItem) GetID

func (s *GoldenItem) GetID() string

GetID returns the value of ID.

func (*GoldenItem) GetMetadata

func (s *GoldenItem) GetMetadata() OptMetadata

GetMetadata returns the value of Metadata.

func (*GoldenItem) GetName

func (s *GoldenItem) GetName() string

GetName returns the value of Name.

func (*GoldenItem) GetTags

func (s *GoldenItem) GetTags() []string

GetTags returns the value of Tags.

func (GoldenItem) Hash

func (a GoldenItem) Hash() uint64

Hash computes a hash value for GoldenItem using FNV-1a. Equal objects must produce equal hashes.

func (*GoldenItem) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*GoldenItem) SetAttributes

func (s *GoldenItem) SetAttributes(val OptGoldenItemAttributes)

SetAttributes sets the value of Attributes.

func (*GoldenItem) SetDescription

func (s *GoldenItem) SetDescription(val OptString)

SetDescription sets the value of Description.

func (*GoldenItem) SetExternalRef

func (s *GoldenItem) SetExternalRef(val OptNilString)

SetExternalRef sets the value of ExternalRef.

func (*GoldenItem) SetID

func (s *GoldenItem) SetID(val string)

SetID sets the value of ID.

func (*GoldenItem) SetMetadata

func (s *GoldenItem) SetMetadata(val OptMetadata)

SetMetadata sets the value of Metadata.

func (*GoldenItem) SetName

func (s *GoldenItem) SetName(val string)

SetName sets the value of Name.

func (*GoldenItem) SetTags

func (s *GoldenItem) SetTags(val []string)

SetTags sets the value of Tags.

func (*GoldenItem) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type GoldenItemAttributes

type GoldenItemAttributes map[string]string

func (*GoldenItemAttributes) Decode

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

Decode decodes GoldenItemAttributes from json.

func (GoldenItemAttributes) Encode

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

Encode implements json.Marshaler.

func (GoldenItemAttributes) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*GoldenItemAttributes) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Handler

type Handler interface {
	// CreateGoldenItems implements createGoldenItems operation.
	//
	// Create items for golden file testing.
	//
	// POST /golden/test
	CreateGoldenItems(ctx context.Context, req *CreateGoldenItemsReq) (*CreateGoldenItemsOK, error)
}

Handler handles operations described by OpenAPI v3 specification.

type Invoker

type Invoker interface {
	// CreateGoldenItems invokes createGoldenItems operation.
	//
	// Create items for golden file testing.
	//
	// POST /golden/test
	CreateGoldenItems(ctx context.Context, request *CreateGoldenItemsReq) (*CreateGoldenItemsOK, 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 Metadata

type Metadata struct {
	Version   OptString         `json:"version"`
	Timestamp OptInt            `json:"timestamp"`
	Labels    OptMetadataLabels `json:"labels"`
}

Ref: #/components/schemas/Metadata

func (*Metadata) Decode

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

Decode decodes Metadata from json.

func (*Metadata) Encode

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

Encode implements json.Marshaler.

func (Metadata) Equal

func (a Metadata) Equal(b Metadata, depth int) bool

Equal compares two Metadata instances for equality. The depth parameter prevents infinite recursion on nested objects.

func (*Metadata) GetLabels

func (s *Metadata) GetLabels() OptMetadataLabels

GetLabels returns the value of Labels.

func (*Metadata) GetTimestamp

func (s *Metadata) GetTimestamp() OptInt

GetTimestamp returns the value of Timestamp.

func (*Metadata) GetVersion

func (s *Metadata) GetVersion() OptString

GetVersion returns the value of Version.

func (Metadata) Hash

func (a Metadata) Hash() uint64

Hash computes a hash value for Metadata using FNV-1a. Equal objects must produce equal hashes.

func (*Metadata) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Metadata) SetLabels

func (s *Metadata) SetLabels(val OptMetadataLabels)

SetLabels sets the value of Labels.

func (*Metadata) SetTimestamp

func (s *Metadata) SetTimestamp(val OptInt)

SetTimestamp sets the value of Timestamp.

func (*Metadata) SetVersion

func (s *Metadata) SetVersion(val OptString)

SetVersion sets the value of Version.

func (*Metadata) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type MetadataLabels

type MetadataLabels map[string]string

func (*MetadataLabels) Decode

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

Decode decodes MetadataLabels from json.

func (MetadataLabels) Encode

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

Encode implements json.Marshaler.

func (MetadataLabels) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*MetadataLabels) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OperationName

type OperationName = string

OperationName is the ogen operation name

const (
	CreateGoldenItemsOperation OperationName = "CreateGoldenItems"
)

type OptGoldenItemAttributes

type OptGoldenItemAttributes struct {
	Value GoldenItemAttributes
	Set   bool
}

OptGoldenItemAttributes is optional GoldenItemAttributes.

func NewOptGoldenItemAttributes

func NewOptGoldenItemAttributes(v GoldenItemAttributes) OptGoldenItemAttributes

NewOptGoldenItemAttributes returns new OptGoldenItemAttributes with value set to v.

func (*OptGoldenItemAttributes) Decode

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

Decode decodes GoldenItemAttributes from json.

func (OptGoldenItemAttributes) Encode

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

Encode encodes GoldenItemAttributes as json.

func (OptGoldenItemAttributes) Get

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

func (OptGoldenItemAttributes) IsSet

func (o OptGoldenItemAttributes) IsSet() bool

IsSet returns true if OptGoldenItemAttributes was set.

func (OptGoldenItemAttributes) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptGoldenItemAttributes) Or

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

func (*OptGoldenItemAttributes) Reset

func (o *OptGoldenItemAttributes) Reset()

Reset unsets value.

func (*OptGoldenItemAttributes) SetTo

SetTo sets value to v.

func (*OptGoldenItemAttributes) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptInt

type OptInt struct {
	Value int
	Set   bool
}

OptInt is optional int.

func NewOptInt

func NewOptInt(v int) OptInt

NewOptInt returns new OptInt with value set to v.

func (*OptInt) Decode

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

Decode decodes int from json.

func (OptInt) Encode

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

Encode encodes int as json.

func (OptInt) Get

func (o OptInt) Get() (v int, ok bool)

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

func (OptInt) IsSet

func (o OptInt) IsSet() bool

IsSet returns true if OptInt was set.

func (OptInt) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptInt) Or

func (o OptInt) Or(d int) int

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

func (*OptInt) Reset

func (o *OptInt) Reset()

Reset unsets value.

func (*OptInt) SetTo

func (o *OptInt) SetTo(v int)

SetTo sets value to v.

func (*OptInt) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptMetadata

type OptMetadata struct {
	Value Metadata
	Set   bool
}

OptMetadata is optional Metadata.

func NewOptMetadata

func NewOptMetadata(v Metadata) OptMetadata

NewOptMetadata returns new OptMetadata with value set to v.

func (*OptMetadata) Decode

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

Decode decodes Metadata from json.

func (OptMetadata) Encode

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

Encode encodes Metadata as json.

func (OptMetadata) Get

func (o OptMetadata) Get() (v Metadata, ok bool)

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

func (OptMetadata) IsSet

func (o OptMetadata) IsSet() bool

IsSet returns true if OptMetadata was set.

func (OptMetadata) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptMetadata) Or

func (o OptMetadata) Or(d Metadata) Metadata

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

func (*OptMetadata) Reset

func (o *OptMetadata) Reset()

Reset unsets value.

func (*OptMetadata) SetTo

func (o *OptMetadata) SetTo(v Metadata)

SetTo sets value to v.

func (*OptMetadata) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptMetadataLabels

type OptMetadataLabels struct {
	Value MetadataLabels
	Set   bool
}

OptMetadataLabels is optional MetadataLabels.

func NewOptMetadataLabels

func NewOptMetadataLabels(v MetadataLabels) OptMetadataLabels

NewOptMetadataLabels returns new OptMetadataLabels with value set to v.

func (*OptMetadataLabels) Decode

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

Decode decodes MetadataLabels from json.

func (OptMetadataLabels) Encode

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

Encode encodes MetadataLabels as json.

func (OptMetadataLabels) Get

func (o OptMetadataLabels) Get() (v MetadataLabels, ok bool)

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

func (OptMetadataLabels) IsSet

func (o OptMetadataLabels) IsSet() bool

IsSet returns true if OptMetadataLabels was set.

func (OptMetadataLabels) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptMetadataLabels) Or

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

func (*OptMetadataLabels) Reset

func (o *OptMetadataLabels) Reset()

Reset unsets value.

func (*OptMetadataLabels) SetTo

func (o *OptMetadataLabels) SetTo(v MetadataLabels)

SetTo sets value to v.

func (*OptMetadataLabels) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptNilString

type OptNilString struct {
	Value string
	Set   bool
	Null  bool
}

OptNilString is optional nullable string.

func NewOptNilString

func NewOptNilString(v string) OptNilString

NewOptNilString returns new OptNilString with value set to v.

func (*OptNilString) Decode

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

Decode decodes string from json.

func (OptNilString) Encode

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

Encode encodes string as json.

func (OptNilString) Get

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

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

func (OptNilString) IsNull

func (o OptNilString) IsNull() bool

IsNull returns true if value is Null.

func (OptNilString) IsSet

func (o OptNilString) IsSet() bool

IsSet returns true if OptNilString was set.

func (OptNilString) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptNilString) Or

func (o OptNilString) Or(d string) string

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

func (*OptNilString) Reset

func (o *OptNilString) Reset()

Reset unsets value.

func (*OptNilString) SetTo

func (o *OptNilString) SetTo(v string)

SetTo sets value to v.

func (*OptNilString) SetToNull

func (o *OptNilString) SetToNull()

SetToNull sets value to null.

func (*OptNilString) UnmarshalJSON

func (s *OptNilString) 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) 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 UnimplementedHandler

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) CreateGoldenItems

CreateGoldenItems implements createGoldenItems operation.

Create items for golden file testing.

POST /golden/test

Jump to

Keyboard shortcuts

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