testapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package testapi contains an oapi-codegen Echo 5 strict-server fixture.

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

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

Index

Constants

This section is empty.

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 PathToRawSpec

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

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

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

RegisterHandlersWithBaseURL registers handlers and prepends BaseURL to the paths so the API can be served under a prefix.

func RegisterHandlersWithOptions

func RegisterHandlersWithOptions(router EchoRouter, si ServerInterface, options RegisterHandlersOptions)

RegisterHandlersWithOptions registers handlers using the supplied options, including any per-operation middleware.

Types

type EchoRouter

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type GetFixture204Response

type GetFixture204Response struct {
}

func (GetFixture204Response) VisitGetFixtureResponse

func (response GetFixture204Response) VisitGetFixtureResponse(w http.ResponseWriter) error

type GetFixtureParamsId

type GetFixtureParamsId string

GetFixtureParamsId defines parameters for GetFixture.

const (
	Fixture1 GetFixtureParamsId = "fixture-1"
)

Defines values for GetFixtureParamsId.

func (GetFixtureParamsId) Valid

func (e GetFixtureParamsId) Valid() bool

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

type GetFixtureRequestObject

type GetFixtureRequestObject struct {
	Id GetFixtureParamsId `json:"id"`
}

type GetFixtureResponseObject

type GetFixtureResponseObject interface {
	VisitGetFixtureResponse(w http.ResponseWriter) error
}

type RegisterHandlersOptions

type RegisterHandlersOptions struct {
	// BaseURL is prepended to every registered path so the API can be served
	// under a prefix.
	BaseURL string
	// OperationMiddlewares lets the caller attach per-operation middleware at
	// registration time. The map key is the OpenAPI `operationId` value as it
	// appears in the spec (the raw, un-normalized form). Operations that have
	// no entry are registered with no extra middleware. A nil map disables
	// per-operation middleware entirely.
	OperationMiddlewares map[string][]echo.MiddlewareFunc
}

RegisterHandlersOptions configures RegisterHandlersWithOptions.

type ServerInterface

type ServerInterface interface {

	// (GET /fixture/{id})
	GetFixture(ctx *echo.Context, id GetFixtureParamsId) error
}

ServerInterface represents all server handlers.

func NewStrictHandler

func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) GetFixture

func (w *ServerInterfaceWrapper) GetFixture(ctx *echo.Context) error

GetFixture converts echo context to params.

type StrictHandlerFunc

type StrictHandlerFunc func(ctx *echo.Context, request any) (any, error)

type StrictMiddlewareFunc

type StrictMiddlewareFunc func(f StrictHandlerFunc, operationID string) StrictHandlerFunc

type StrictServerInterface

type StrictServerInterface interface {

	// (GET /fixture/{id})
	GetFixture(ctx context.Context, request GetFixtureRequestObject) (GetFixtureResponseObject, error)
}

StrictServerInterface represents all server handlers.

Jump to

Keyboard shortcuts

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