oas

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Code generated by ogen, DO NOT EDIT.

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) CreateTask added in v0.2.0

func (c *Client) CreateTask(ctx context.Context, request *CreateTaskRequest) (*Task, error)

CreateTask invokes createTask operation.

Create a new task with the provided title.

POST /tasks

func (*Client) DeleteTask added in v0.2.0

func (c *Client) DeleteTask(ctx context.Context, params DeleteTaskParams) (DeleteTaskRes, error)

DeleteTask invokes deleteTask operation.

Delete a task by its unique identifier.

DELETE /tasks/{id}

func (*Client) GenerateError added in v0.2.0

func (c *Client) GenerateError(ctx context.Context) (*Error, error)

GenerateError invokes generateError operation.

Utility endpoint for testing error handling - always returns an error response.

POST /tasks/error

func (*Client) GetHealth

func (c *Client) GetHealth(ctx context.Context) (*Health, error)

GetHealth invokes getHealth operation.

Get health.

GET /health

func (*Client) ListTasks added in v0.2.0

func (c *Client) ListTasks(ctx context.Context) (*TaskList, error)

ListTasks invokes listTasks operation.

Retrieve a list of all tasks in the system.

GET /tasks

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 CreateTaskRequest added in v0.2.0

type CreateTaskRequest struct {
	// Title or description of the task to create.
	Title string `json:"title"`
}

Request payload for creating a new task. Ref: #/components/schemas/CreateTaskRequest

func (*CreateTaskRequest) Decode added in v0.2.0

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

Decode decodes CreateTaskRequest from json.

func (*CreateTaskRequest) Encode added in v0.2.0

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

Encode implements json.Marshaler.

func (*CreateTaskRequest) GetTitle added in v0.2.0

func (s *CreateTaskRequest) GetTitle() string

GetTitle returns the value of Title.

func (*CreateTaskRequest) MarshalJSON added in v0.2.0

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

MarshalJSON implements stdjson.Marshaler.

func (*CreateTaskRequest) SetFake added in v0.2.0

func (s *CreateTaskRequest) SetFake()

SetFake set fake values.

func (*CreateTaskRequest) SetTitle added in v0.2.0

func (s *CreateTaskRequest) SetTitle(val string)

SetTitle sets the value of Title.

func (*CreateTaskRequest) UnmarshalJSON added in v0.2.0

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*CreateTaskRequest) Validate added in v0.2.0

func (s *CreateTaskRequest) Validate() error

type DeleteTaskNoContent added in v0.2.0

type DeleteTaskNoContent struct{}

DeleteTaskNoContent is response for DeleteTask operation.

type DeleteTaskParams added in v0.2.0

type DeleteTaskParams struct {
	// Unique identifier of the task to delete.
	ID int64
}

DeleteTaskParams is parameters of deleteTask operation.

type DeleteTaskRes added in v0.2.0

type DeleteTaskRes interface {
	// contains filtered or unexported methods
}

type Error

type Error struct {
	// Human-readable error message.
	ErrorMessage string     `json:"errorMessage"`
	TraceID      OptTraceID `json:"traceID"`
	SpanID       OptSpanID  `json:"spanID"`
}

Error occurred while processing request. Ref: #/components/schemas/Error

func (*Error) Decode

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

Decode decodes Error from json.

func (*Error) Encode

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

Encode implements json.Marshaler.

func (*Error) GetErrorMessage

func (s *Error) GetErrorMessage() string

GetErrorMessage returns the value of ErrorMessage.

func (*Error) GetSpanID

func (s *Error) GetSpanID() OptSpanID

GetSpanID returns the value of SpanID.

func (*Error) GetTraceID

func (s *Error) GetTraceID() OptTraceID

GetTraceID returns the value of TraceID.

func (*Error) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Error) SetErrorMessage

func (s *Error) SetErrorMessage(val string)

SetErrorMessage sets the value of ErrorMessage.

func (*Error) SetFake

func (s *Error) SetFake()

SetFake set fake values.

func (*Error) SetSpanID

func (s *Error) SetSpanID(val OptSpanID)

SetSpanID sets the value of SpanID.

func (*Error) SetTraceID

func (s *Error) SetTraceID(val OptTraceID)

SetTraceID sets the value of TraceID.

func (*Error) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Error) Validate

func (s *Error) Validate() error

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type ErrorStatusCode

type ErrorStatusCode struct {
	StatusCode int
	Response   Error
}

ErrorStatusCode wraps Error with StatusCode.

func (*ErrorStatusCode) Error

func (s *ErrorStatusCode) Error() string

func (*ErrorStatusCode) GetResponse

func (s *ErrorStatusCode) GetResponse() Error

GetResponse returns the value of Response.

func (*ErrorStatusCode) GetStatusCode

func (s *ErrorStatusCode) GetStatusCode() int

GetStatusCode returns the value of StatusCode.

func (*ErrorStatusCode) SetResponse

func (s *ErrorStatusCode) SetResponse(val Error)

SetResponse sets the value of Response.

func (*ErrorStatusCode) SetStatusCode

func (s *ErrorStatusCode) SetStatusCode(val int)

SetStatusCode sets the value of StatusCode.

func (*ErrorStatusCode) Validate

func (s *ErrorStatusCode) Validate() error

type Handler

type Handler interface {
	// CreateTask implements createTask operation.
	//
	// Create a new task with the provided title.
	//
	// POST /tasks
	CreateTask(ctx context.Context, req *CreateTaskRequest) (*Task, error)
	// DeleteTask implements deleteTask operation.
	//
	// Delete a task by its unique identifier.
	//
	// DELETE /tasks/{id}
	DeleteTask(ctx context.Context, params DeleteTaskParams) (DeleteTaskRes, error)
	// GenerateError implements generateError operation.
	//
	// Utility endpoint for testing error handling - always returns an error response.
	//
	// POST /tasks/error
	GenerateError(ctx context.Context) (*Error, error)
	// GetHealth implements getHealth operation.
	//
	// Get health.
	//
	// GET /health
	GetHealth(ctx context.Context) (*Health, error)
	// ListTasks implements listTasks operation.
	//
	// Retrieve a list of all tasks in the system.
	//
	// GET /tasks
	ListTasks(ctx context.Context) (*TaskList, error)
	// NewError creates *ErrorStatusCode from error returned by handler.
	//
	// Used for common default response.
	NewError(ctx context.Context, err error) *ErrorStatusCode
}

Handler handles operations described by OpenAPI v3 specification.

type Health

type Health struct {
	// Health status string.
	Status string `json:"status"`
	// Service version.
	Version string `json:"version"`
	// Service commit.
	Commit string `json:"commit"`
	// Service build date.
	BuildDate time.Time `json:"buildDate"`
}

Health status. Ref: #/components/schemas/Health

func (*Health) Decode

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

Decode decodes Health from json.

func (*Health) Encode

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

Encode implements json.Marshaler.

func (*Health) GetBuildDate

func (s *Health) GetBuildDate() time.Time

GetBuildDate returns the value of BuildDate.

func (*Health) GetCommit

func (s *Health) GetCommit() string

GetCommit returns the value of Commit.

func (*Health) GetStatus

func (s *Health) GetStatus() string

GetStatus returns the value of Status.

func (*Health) GetVersion

func (s *Health) GetVersion() string

GetVersion returns the value of Version.

func (*Health) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Health) SetBuildDate

func (s *Health) SetBuildDate(val time.Time)

SetBuildDate sets the value of BuildDate.

func (*Health) SetCommit

func (s *Health) SetCommit(val string)

SetCommit sets the value of Commit.

func (*Health) SetFake

func (s *Health) SetFake()

SetFake set fake values.

func (*Health) SetStatus

func (s *Health) SetStatus(val string)

SetStatus sets the value of Status.

func (*Health) SetVersion

func (s *Health) SetVersion(val string)

SetVersion sets the value of Version.

func (*Health) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Invoker

type Invoker interface {
	// CreateTask invokes createTask operation.
	//
	// Create a new task with the provided title.
	//
	// POST /tasks
	CreateTask(ctx context.Context, request *CreateTaskRequest) (*Task, error)
	// DeleteTask invokes deleteTask operation.
	//
	// Delete a task by its unique identifier.
	//
	// DELETE /tasks/{id}
	DeleteTask(ctx context.Context, params DeleteTaskParams) (DeleteTaskRes, error)
	// GenerateError invokes generateError operation.
	//
	// Utility endpoint for testing error handling - always returns an error response.
	//
	// POST /tasks/error
	GenerateError(ctx context.Context) (*Error, error)
	// GetHealth invokes getHealth operation.
	//
	// Get health.
	//
	// GET /health
	GetHealth(ctx context.Context) (*Health, error)
	// ListTasks invokes listTasks operation.
	//
	// Retrieve a list of all tasks in the system.
	//
	// GET /tasks
	ListTasks(ctx context.Context) (*TaskList, 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 Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OperationName

type OperationName = string

OperationName is the ogen operation name

const (
	CreateTaskOperation    OperationName = "CreateTask"
	DeleteTaskOperation    OperationName = "DeleteTask"
	GenerateErrorOperation OperationName = "GenerateError"
	GetHealthOperation     OperationName = "GetHealth"
	ListTasksOperation     OperationName = "ListTasks"
)

type OptSpanID

type OptSpanID struct {
	Value SpanID
	Set   bool
}

OptSpanID is optional SpanID.

func NewOptSpanID

func NewOptSpanID(v SpanID) OptSpanID

NewOptSpanID returns new OptSpanID with value set to v.

func (*OptSpanID) Decode

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

Decode decodes SpanID from json.

func (OptSpanID) Encode

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

Encode encodes SpanID as json.

func (OptSpanID) Get

func (o OptSpanID) Get() (v SpanID, ok bool)

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

func (OptSpanID) IsSet

func (o OptSpanID) IsSet() bool

IsSet returns true if OptSpanID was set.

func (OptSpanID) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptSpanID) Or

func (o OptSpanID) Or(d SpanID) SpanID

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

func (*OptSpanID) Reset

func (o *OptSpanID) Reset()

Reset unsets value.

func (*OptSpanID) SetFake

func (s *OptSpanID) SetFake()

SetFake set fake values.

func (*OptSpanID) SetTo

func (o *OptSpanID) SetTo(v SpanID)

SetTo sets value to v.

func (*OptSpanID) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptTraceID

type OptTraceID struct {
	Value TraceID
	Set   bool
}

OptTraceID is optional TraceID.

func NewOptTraceID

func NewOptTraceID(v TraceID) OptTraceID

NewOptTraceID returns new OptTraceID with value set to v.

func (*OptTraceID) Decode

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

Decode decodes TraceID from json.

func (OptTraceID) Encode

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

Encode encodes TraceID as json.

func (OptTraceID) Get

func (o OptTraceID) Get() (v TraceID, ok bool)

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

func (OptTraceID) IsSet

func (o OptTraceID) IsSet() bool

IsSet returns true if OptTraceID was set.

func (OptTraceID) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptTraceID) Or

func (o OptTraceID) Or(d TraceID) TraceID

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

func (*OptTraceID) Reset

func (o *OptTraceID) Reset()

Reset unsets value.

func (*OptTraceID) SetFake

func (s *OptTraceID) SetFake()

SetFake set fake values.

func (*OptTraceID) SetTo

func (o *OptTraceID) SetTo(v TraceID)

SetTo sets value to v.

func (*OptTraceID) UnmarshalJSON

func (s *OptTraceID) 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 SpanID

type SpanID string

func (*SpanID) Decode

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

Decode decodes SpanID from json.

func (SpanID) Encode

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

Encode encodes SpanID as json.

func (SpanID) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*SpanID) SetFake

func (s *SpanID) SetFake()

SetFake set fake values.

func (*SpanID) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (SpanID) Validate

func (s SpanID) Validate() error

type Task added in v0.2.0

type Task struct {
	// Unique identifier for the task.
	ID int64 `json:"id"`
	// Title or description of the task.
	Title string `json:"title"`
}

A task entity with unique identifier and title. Ref: #/components/schemas/Task

func (*Task) Decode added in v0.2.0

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

Decode decodes Task from json.

func (*Task) Encode added in v0.2.0

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

Encode implements json.Marshaler.

func (*Task) GetID added in v0.2.0

func (s *Task) GetID() int64

GetID returns the value of ID.

func (*Task) GetTitle added in v0.2.0

func (s *Task) GetTitle() string

GetTitle returns the value of Title.

func (*Task) MarshalJSON added in v0.2.0

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

MarshalJSON implements stdjson.Marshaler.

func (*Task) SetFake added in v0.2.0

func (s *Task) SetFake()

SetFake set fake values.

func (*Task) SetID added in v0.2.0

func (s *Task) SetID(val int64)

SetID sets the value of ID.

func (*Task) SetTitle added in v0.2.0

func (s *Task) SetTitle(val string)

SetTitle sets the value of Title.

func (*Task) UnmarshalJSON added in v0.2.0

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Task) Validate added in v0.2.0

func (s *Task) Validate() error

type TaskList added in v0.2.0

type TaskList struct {
	// Array of tasks.
	Tasks []Task `json:"tasks"`
}

Response containing a list of tasks. Ref: #/components/schemas/TaskList

func (*TaskList) Decode added in v0.2.0

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

Decode decodes TaskList from json.

func (*TaskList) Encode added in v0.2.0

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

Encode implements json.Marshaler.

func (*TaskList) GetTasks added in v0.2.0

func (s *TaskList) GetTasks() []Task

GetTasks returns the value of Tasks.

func (*TaskList) MarshalJSON added in v0.2.0

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

MarshalJSON implements stdjson.Marshaler.

func (*TaskList) SetFake added in v0.2.0

func (s *TaskList) SetFake()

SetFake set fake values.

func (*TaskList) SetTasks added in v0.2.0

func (s *TaskList) SetTasks(val []Task)

SetTasks sets the value of Tasks.

func (*TaskList) UnmarshalJSON added in v0.2.0

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*TaskList) Validate added in v0.2.0

func (s *TaskList) Validate() error

type TraceID

type TraceID string

func (*TraceID) Decode

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

Decode decodes TraceID from json.

func (TraceID) Encode

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

Encode encodes TraceID as json.

func (TraceID) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*TraceID) SetFake

func (s *TraceID) SetFake()

SetFake set fake values.

func (*TraceID) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (TraceID) Validate

func (s TraceID) Validate() error

type UnimplementedHandler

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) CreateTask added in v0.2.0

func (UnimplementedHandler) CreateTask(ctx context.Context, req *CreateTaskRequest) (r *Task, _ error)

CreateTask implements createTask operation.

Create a new task with the provided title.

POST /tasks

func (UnimplementedHandler) DeleteTask added in v0.2.0

DeleteTask implements deleteTask operation.

Delete a task by its unique identifier.

DELETE /tasks/{id}

func (UnimplementedHandler) GenerateError added in v0.2.0

func (UnimplementedHandler) GenerateError(ctx context.Context) (r *Error, _ error)

GenerateError implements generateError operation.

Utility endpoint for testing error handling - always returns an error response.

POST /tasks/error

func (UnimplementedHandler) GetHealth

func (UnimplementedHandler) GetHealth(ctx context.Context) (r *Health, _ error)

GetHealth implements getHealth operation.

Get health.

GET /health

func (UnimplementedHandler) ListTasks added in v0.2.0

func (UnimplementedHandler) ListTasks(ctx context.Context) (r *TaskList, _ error)

ListTasks implements listTasks operation.

Retrieve a list of all tasks in the system.

GET /tasks

func (UnimplementedHandler) NewError

func (UnimplementedHandler) NewError(ctx context.Context, err error) (r *ErrorStatusCode)

NewError creates *ErrorStatusCode from error returned by handler.

Used for common default response.

Jump to

Keyboard shortcuts

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