api

package
v0.0.0-...-ffaedda Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Overview

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

Code generated by github.com/deepmap/oapi-codegen version v1.11.0 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

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

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

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 New

func New(cfg *config.Config) *http.Server

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 CreateOrder

type CreateOrder struct {
	CustomerId *openapi_types.UUID `json:"customer_id,omitempty"`
}

CreateOrder defines model for CreateOrder.

func (*CreateOrder) Validate

func (r *CreateOrder) Validate() error

type DeleteOrderOrderIDItemJSONBody

type DeleteOrderOrderIDItemJSONBody = Item

DeleteOrderOrderIDItemJSONBody defines parameters for DeleteOrderOrderIDItem.

type DeleteOrderOrderIDItemJSONRequestBody

type DeleteOrderOrderIDItemJSONRequestBody = DeleteOrderOrderIDItemJSONBody

DeleteOrderOrderIDItemJSONRequestBody defines body for DeleteOrderOrderIDItem for application/json ContentType.

type Error

type Error struct {
	Errors *[]string `json:"errors,omitempty"`
}

Error defines model for Error.

type HandlerDecorator

type HandlerDecorator struct {
	// contains filtered or unexported fields
}

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 Item

type Item struct {
	Name *string `json:"name,omitempty"`
}

Item defines model for Item.

func (*Item) Validate

func (r *Item) Validate() error

type MiddlewareFunc

type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc

type Option

type Option func(*HandlerDecorator)

func WithDefaultStatus

func WithDefaultStatus(status int) Option

func WithErrorMapper

func WithErrorMapper(mapper func(error) int) Option

func WithOperation

func WithOperation(op func(context.Context) (any, error)) Option

func WithRequestBody

func WithRequestBody(request Validated) Option

func WithResponseMapper

func WithResponseMapper(mapper func(any) any) Option

type Order

type Order struct {
	CustomerId *openapi_types.UUID `json:"customer_id,omitempty"`
	Id         *openapi_types.UUID `json:"id,omitempty"`
	Items      *[]string           `json:"items,omitempty"`
	PaymentId  *openapi_types.UUID `json:"payment_id,omitempty"`
}

Order defines model for Order.

type PutOrderOrderIDJSONBody

type PutOrderOrderIDJSONBody = Item

PutOrderOrderIDJSONBody defines parameters for PutOrderOrderID.

type PutOrderOrderIDJSONRequestBody

type PutOrderOrderIDJSONRequestBody = PutOrderOrderIDJSONBody

PutOrderOrderIDJSONRequestBody defines body for PutOrderOrderID for application/json ContentType.

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 RestController

type RestController struct{}

func (RestController) DeleteOrderOrderIDItem

func (RestController) DeleteOrderOrderIDItem(w http.ResponseWriter, r *http.Request, orderID openapi_types.UUID, item string)

func (RestController) PostOrder

func (RestController) PostOrder(w http.ResponseWriter, r *http.Request)

func (RestController) PostOrderOrderID

func (RestController) PostOrderOrderID(w http.ResponseWriter, r *http.Request, orderID openapi_types.UUID)

func (RestController) PutOrderOrderID

func (RestController) PutOrderOrderID(w http.ResponseWriter, r *http.Request, orderID openapi_types.UUID)

type ServerInterface

type ServerInterface interface {
	// Create new order
	// (POST /order)
	PostOrder(w http.ResponseWriter, r *http.Request)
	// close order and send to process payments
	// (POST /order/{orderID})
	PostOrderOrderID(w http.ResponseWriter, r *http.Request, orderID openapi_types.UUID)
	// Add item to order
	// (PUT /order/{orderID})
	PutOrderOrderID(w http.ResponseWriter, r *http.Request, orderID openapi_types.UUID)
	// Remove item from order
	// (DELETE /order/{orderID}/{item})
	DeleteOrderOrderIDItem(w http.ResponseWriter, r *http.Request, orderID openapi_types.UUID, item string)
}

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

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

DeleteOrderOrderIDItem operation middleware

func (*ServerInterfaceWrapper) PostOrder

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

PostOrder operation middleware

func (*ServerInterfaceWrapper) PostOrderOrderID

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

PostOrderOrderID operation middleware

func (*ServerInterfaceWrapper) PutOrderOrderID

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

PutOrderOrderID 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 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 Validated

type Validated interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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