api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.7.1 DO NOT EDIT.

Index

Constants

View Source
const (
	BearerAuthScopes bearerAuthContextKey = "bearerAuth.Scopes"
)

Variables

This section is empty.

Functions

func GetSpec

func GetSpec() (swagger *openapi3.T, err error)

GetSpec returns the OpenAPI specification corresponding to the generated code in this file. External references in the spec are resolved through PathToRawSpec; externally-referenced files must be embedded in their corresponding Go packages (via the import-mapping feature). URL-based external refs are not supported.

func GetSpecJSON

func GetSpecJSON() ([]byte, error)

GetSpecJSON returns the raw JSON bytes of the embedded OpenAPI specification: decompressed but not unmarshaled. External references are not resolved here; the bytes are the spec exactly as embedded by codegen. The result is cached at package init time, so repeated calls are cheap.

func GetSwagger deprecated

func GetSwagger() (*openapi3.T, error)

GetSwagger returns the OpenAPI specification corresponding to the generated code in this file.

Deprecated: GetSwagger predates kin-openapi renaming openapi3.Swagger to openapi3.T. Use GetSpec instead. This wrapper is retained for backwards compatibility.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type CreateWidgetJSONRequestBody

type CreateWidgetJSONRequestBody = WidgetInput

CreateWidgetJSONRequestBody defines body for CreateWidget for application/json ContentType.

type CreateWidgetParams

type CreateWidgetParams struct {
	// IdempotencyKey Opaque key that makes a create request safe to retry.
	IdempotencyKey *IdempotencyKey `json:"Idempotency-Key,omitempty"`
}

CreateWidgetParams defines parameters for CreateWidget.

type FieldError

type FieldError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

FieldError defines model for FieldError.

type IdempotencyKey

type IdempotencyKey = string

IdempotencyKey defines model for IdempotencyKey.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type Limit

type Limit = int32

Limit defines model for Limit.

type ListWidgetsParams

type ListWidgetsParams struct {
	// Limit Maximum number of items to return.
	Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`

	// Offset Number of items to skip.
	Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"`
}

ListWidgetsParams defines parameters for ListWidgets.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type Offset

type Offset = int32

Offset defines model for Offset.

type Pagination

type Pagination struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
	Total  int64 `json:"total"`
}

Pagination defines model for Pagination.

type Problem

type Problem struct {
	Detail *string `json:"detail,omitempty"`

	// Errors Field-level validation failures.
	Errors   *[]FieldError `json:"errors,omitempty"`
	Instance *string       `json:"instance,omitempty"`
	Status   int32         `json:"status"`
	Title    string        `json:"title"`

	// TraceId Correlates this response with a distributed trace.
	TraceId *string `json:"traceId,omitempty"`
	Type    string  `json:"type"`
}

Problem Problem details as defined by RFC 9457.

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type ServerInterface

type ServerInterface interface {
	// List widgets
	// (GET /v1/widgets)
	ListWidgets(w http.ResponseWriter, r *http.Request, params ListWidgetsParams)
	// Create a widget
	// (POST /v1/widgets)
	CreateWidget(w http.ResponseWriter, r *http.Request, params CreateWidgetParams)
	// Delete a widget
	// (DELETE /v1/widgets/{id})
	DeleteWidget(w http.ResponseWriter, r *http.Request, id WidgetID)
	// Get a widget by ID
	// (GET /v1/widgets/{id})
	GetWidget(w http.ResponseWriter, r *http.Request, id WidgetID)
	// Replace a widget
	// (PUT /v1/widgets/{id})
	UpdateWidget(w http.ResponseWriter, r *http.Request, id WidgetID)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CreateWidget

func (siw *ServerInterfaceWrapper) CreateWidget(w http.ResponseWriter, r *http.Request)

CreateWidget operation middleware

func (*ServerInterfaceWrapper) DeleteWidget

func (siw *ServerInterfaceWrapper) DeleteWidget(w http.ResponseWriter, r *http.Request)

DeleteWidget operation middleware

func (*ServerInterfaceWrapper) GetWidget

func (siw *ServerInterfaceWrapper) GetWidget(w http.ResponseWriter, r *http.Request)

GetWidget operation middleware

func (*ServerInterfaceWrapper) ListWidgets

func (siw *ServerInterfaceWrapper) ListWidgets(w http.ResponseWriter, r *http.Request)

ListWidgets operation middleware

func (*ServerInterfaceWrapper) UpdateWidget

func (siw *ServerInterfaceWrapper) UpdateWidget(w http.ResponseWriter, r *http.Request)

UpdateWidget operation middleware

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type Unimplemented

type Unimplemented struct{}

func (Unimplemented) CreateWidget

func (_ Unimplemented) CreateWidget(w http.ResponseWriter, r *http.Request, params CreateWidgetParams)

Create a widget (POST /v1/widgets)

func (Unimplemented) DeleteWidget

func (_ Unimplemented) DeleteWidget(w http.ResponseWriter, r *http.Request, id WidgetID)

Delete a widget (DELETE /v1/widgets/{id})

func (Unimplemented) GetWidget

func (_ Unimplemented) GetWidget(w http.ResponseWriter, r *http.Request, id WidgetID)

Get a widget by ID (GET /v1/widgets/{id})

func (Unimplemented) ListWidgets

func (_ Unimplemented) ListWidgets(w http.ResponseWriter, r *http.Request, params ListWidgetsParams)

List widgets (GET /v1/widgets)

func (Unimplemented) UpdateWidget

func (_ Unimplemented) UpdateWidget(w http.ResponseWriter, r *http.Request, id WidgetID)

Replace a widget (PUT /v1/widgets/{id})

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

type UpdateWidgetJSONRequestBody

type UpdateWidgetJSONRequestBody = WidgetInput

UpdateWidgetJSONRequestBody defines body for UpdateWidget for application/json ContentType.

type Widget

type Widget struct {
	CreatedAt   time.Time          `json:"createdAt"`
	Description string             `json:"description"`
	Id          openapi_types.UUID `json:"id"`
	Name        string             `json:"name"`
	Status      WidgetStatus       `json:"status"`
	UpdatedAt   time.Time          `json:"updatedAt"`
}

Widget defines model for Widget.

type WidgetID

type WidgetID = openapi_types.UUID

WidgetID defines model for WidgetID.

type WidgetInput

type WidgetInput struct {
	Description *string       `json:"description,omitempty"`
	Name        string        `json:"name"`
	Status      *WidgetStatus `json:"status,omitempty"`
}

WidgetInput defines model for WidgetInput.

type WidgetList

type WidgetList struct {
	Items      []Widget   `json:"items"`
	Pagination Pagination `json:"pagination"`
}

WidgetList defines model for WidgetList.

type WidgetStatus

type WidgetStatus string

WidgetStatus defines model for WidgetStatus.

const (
	Active   WidgetStatus = "active"
	Archived WidgetStatus = "archived"
)

Defines values for WidgetStatus.

func (WidgetStatus) Valid

func (e WidgetStatus) Valid() bool

Valid indicates whether the value is a known member of the WidgetStatus enum.

Jump to

Keyboard shortcuts

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