api

package
v0.0.0-...-7b47575 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 16 Imported by: 0

README

oapi-codegen -config cfg.yaml ../schema-validation.yaml

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.3.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 *mux.Router) http.Handler

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

func HandlerFromMuxWithBaseURL

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

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options GorillaServerOptions) 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 CustomServer

type CustomServer struct {
	Lock sync.Mutex
}

func NewCustomServer

func NewCustomServer() *CustomServer

func (*CustomServer) GetAnythingBooleans

GET /anything/booleans

func (*CustomServer) GetAnythingJsonschemaFormats

GET /anything/jsonschema-formats

func (*CustomServer) GetAnythingNumbers

GET /anything/numbers

func (*CustomServer) GetAnythingOasFormats

GET /anything/oas-formats

func (*CustomServer) GetAnythingStrings

GET /anything/strings

type GetAnythingBooleans200Response

type GetAnythingBooleans200Response struct {
}

func (GetAnythingBooleans200Response) VisitGetAnythingBooleansResponse

func (response GetAnythingBooleans200Response) VisitGetAnythingBooleansResponse(w http.ResponseWriter) error

type GetAnythingBooleansParams

type GetAnythingBooleansParams struct {
	// TfRequired Required parameter boolean true/false
	TfRequired bool `form:"tf-required" json:"tf-required"`

	// TfOptional Optional boolean
	TfOptional *bool `form:"tf-optional,omitempty" json:"tf-optional,omitempty"`
}

GetAnythingBooleansParams defines parameters for GetAnythingBooleans.

type GetAnythingBooleansRequestObject

type GetAnythingBooleansRequestObject struct {
	Params GetAnythingBooleansParams
}

type GetAnythingBooleansResponseObject

type GetAnythingBooleansResponseObject interface {
	VisitGetAnythingBooleansResponse(w http.ResponseWriter) error
}

type GetAnythingJsonschemaFormats200Response

type GetAnythingJsonschemaFormats200Response struct {
}

func (GetAnythingJsonschemaFormats200Response) VisitGetAnythingJsonschemaFormatsResponse

func (response GetAnythingJsonschemaFormats200Response) VisitGetAnythingJsonschemaFormatsResponse(w http.ResponseWriter) error

type GetAnythingJsonschemaFormatsParams

type GetAnythingJsonschemaFormatsParams struct {
	// DateTime Optional parameter date-time as string
	DateTime time.Time `form:"date-time" json:"date-time"`

	// Date Optional parameter date as string
	Date *openapi_types.Date `form:"date,omitempty" json:"date,omitempty"`

	// Time Optional parameter time as string
	Time *string `form:"time,omitempty" json:"time,omitempty"`

	// Duration Optional parameter duration as string
	Duration *string `form:"duration,omitempty" json:"duration,omitempty"`

	// Email Optional parameter email as string
	Email *openapi_types.Email `form:"email,omitempty" json:"email,omitempty"`

	// IdnEmail Optional parameter idn-email as string
	IdnEmail *string `form:"idn-email,omitempty" json:"idn-email,omitempty"`

	// Hostname Optional parameter hostname as string
	Hostname *string `form:"hostname,omitempty" json:"hostname,omitempty"`

	// IdnHostname Optional parameter idn-hostname as string
	IdnHostname *string `form:"idn-hostname,omitempty" json:"idn-hostname,omitempty"`

	// Ipv4 Optional parameter ipv4 as string
	Ipv4 *string `form:"ipv4,omitempty" json:"ipv4,omitempty"`

	// Ipv6 Optional parameter ipv6 as string
	Ipv6 *string `form:"ipv6,omitempty" json:"ipv6,omitempty"`

	// Uri Optional parameter uri as string
	Uri *string `form:"uri,omitempty" json:"uri,omitempty"`

	// UriReference Optional parameter uri-reference as string
	UriReference *string `form:"uri-reference,omitempty" json:"uri-reference,omitempty"`

	// Iri Optional parameter iri as string
	Iri *string `form:"iri,omitempty" json:"iri,omitempty"`

	// IriReference Optional parameter iri-reference as string
	IriReference *string `form:"iri-reference,omitempty" json:"iri-reference,omitempty"`

	// Uuid Optional parameter uuid as string
	Uuid *openapi_types.UUID `form:"uuid,omitempty" json:"uuid,omitempty"`

	// UriTemplate Optional parameter uri-template as string
	UriTemplate *string `form:"uri-template,omitempty" json:"uri-template,omitempty"`

	// JsonPointer Optional parameter json-pointer as string
	JsonPointer *string `form:"json-pointer,omitempty" json:"json-pointer,omitempty"`

	// RelativeJsonPointer Optional parameter relative-json-pointer as string
	RelativeJsonPointer *string `form:"relative-json-pointer,omitempty" json:"relative-json-pointer,omitempty"`

	// Regex Optional parameter regex as string
	Regex *string `form:"regex,omitempty" json:"regex,omitempty"`
}

GetAnythingJsonschemaFormatsParams defines parameters for GetAnythingJsonschemaFormats.

type GetAnythingJsonschemaFormatsRequestObject

type GetAnythingJsonschemaFormatsRequestObject struct {
	Params GetAnythingJsonschemaFormatsParams
}

type GetAnythingJsonschemaFormatsResponseObject

type GetAnythingJsonschemaFormatsResponseObject interface {
	VisitGetAnythingJsonschemaFormatsResponse(w http.ResponseWriter) error
}

type GetAnythingNumbers200Response

type GetAnythingNumbers200Response struct {
}

func (GetAnythingNumbers200Response) VisitGetAnythingNumbersResponse

func (response GetAnythingNumbers200Response) VisitGetAnythingNumbersResponse(w http.ResponseWriter) error

type GetAnythingNumbersParams

type GetAnythingNumbersParams struct {
	// IdRequired Required parameter id-required
	IdRequired float32 `form:"id-required" json:"id-required"`

	// IdOptional Optional parameter id-optional
	IdOptional *float32 `form:"id-optional,omitempty" json:"id-optional,omitempty"`

	// IdExclusiveRequired Required parameter id-exclusive-required
	IdExclusiveRequired float32 `form:"id-exclusive-required" json:"id-exclusive-required"`

	// IdExclusiveOptional Optional parameter id-exclusive-optional
	IdExclusiveOptional *float32 `form:"id-exclusive-optional,omitempty" json:"id-exclusive-optional,omitempty"`
}

GetAnythingNumbersParams defines parameters for GetAnythingNumbers.

type GetAnythingNumbersRequestObject

type GetAnythingNumbersRequestObject struct {
	Params GetAnythingNumbersParams
}

type GetAnythingNumbersResponseObject

type GetAnythingNumbersResponseObject interface {
	VisitGetAnythingNumbersResponse(w http.ResponseWriter) error
}

type GetAnythingOasFormats200Response

type GetAnythingOasFormats200Response struct {
}

func (GetAnythingOasFormats200Response) VisitGetAnythingOasFormatsResponse

func (response GetAnythingOasFormats200Response) VisitGetAnythingOasFormatsResponse(w http.ResponseWriter) error

type GetAnythingOasFormatsParams

type GetAnythingOasFormatsParams struct {
	// Int32 Optional parameter int32 as integer
	Int32 int32 `form:"int32" json:"int32"`

	// Int64 Optional parameter int64 as integer
	Int64 *int64 `form:"int64,omitempty" json:"int64,omitempty"`

	// Float Optional parameter float as number
	Float *float32 `form:"float,omitempty" json:"float,omitempty"`

	// Double Optional parameter double as number
	Double *float64 `form:"double,omitempty" json:"double,omitempty"`

	// Byte Optional parameter byte as string
	Byte *[]byte `form:"byte,omitempty" json:"byte,omitempty"`

	// Binary Optional parameter binary as string
	Binary *openapi_types.File `form:"binary,omitempty" json:"binary,omitempty"`

	// Password Optional parameter password
	Password *string `form:"password,omitempty" json:"password,omitempty"`
}

GetAnythingOasFormatsParams defines parameters for GetAnythingOasFormats.

type GetAnythingOasFormatsRequestObject

type GetAnythingOasFormatsRequestObject struct {
	Params GetAnythingOasFormatsParams
}

type GetAnythingOasFormatsResponseObject

type GetAnythingOasFormatsResponseObject interface {
	VisitGetAnythingOasFormatsResponse(w http.ResponseWriter) error
}

type GetAnythingStrings200Response

type GetAnythingStrings200Response struct {
}

func (GetAnythingStrings200Response) VisitGetAnythingStringsResponse

func (response GetAnythingStrings200Response) VisitGetAnythingStringsResponse(w http.ResponseWriter) error

type GetAnythingStringsParams

type GetAnythingStringsParams struct {
	// NameLengthRequired Required parameter name-length-required
	NameLengthRequired string `form:"name-length-required" json:"name-length-required"`

	// NameLengthOptional Optional parameter name-length-optional
	NameLengthOptional *string `form:"name-length-optional,omitempty" json:"name-length-optional,omitempty"`

	// NamePatternRequired Required parameter name-pattern-required
	NamePatternRequired string `form:"name-pattern-required" json:"name-pattern-required"`

	// ComplexPatternRequired OpenAPI 3.0.3, which defaults to JSON Schema v4, does not provide the unicode flag to the input tooltip regex validation. This means that the following regex should work. It won't work if unicode is enabled because it has unescaped brace literals
	ComplexPatternRequired string `form:"complex-pattern-required" json:"complex-pattern-required"`

	// NamePatternOptional Optional parameter name-pattern-optional as string
	NamePatternOptional *string `form:"name-pattern-optional,omitempty" json:"name-pattern-optional,omitempty"`
}

GetAnythingStringsParams defines parameters for GetAnythingStrings.

type GetAnythingStringsRequestObject

type GetAnythingStringsRequestObject struct {
	Params GetAnythingStringsParams
}

type GetAnythingStringsResponseObject

type GetAnythingStringsResponseObject interface {
	VisitGetAnythingStringsResponse(w http.ResponseWriter) error
}

type GorillaServerOptions

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

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 MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

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 {
	// Booleans
	// (GET /anything/booleans)
	GetAnythingBooleans(w http.ResponseWriter, r *http.Request, params GetAnythingBooleansParams)
	// Formats defined by JSON Schema
	// (GET /anything/jsonschema-formats)
	GetAnythingJsonschemaFormats(w http.ResponseWriter, r *http.Request, params GetAnythingJsonschemaFormatsParams)
	// Number validation
	// (GET /anything/numbers)
	GetAnythingNumbers(w http.ResponseWriter, r *http.Request, params GetAnythingNumbersParams)
	// Formats defined by OpenAPI
	// (GET /anything/oas-formats)
	GetAnythingOasFormats(w http.ResponseWriter, r *http.Request, params GetAnythingOasFormatsParams)
	// String validation
	// (GET /anything/strings)
	GetAnythingStrings(w http.ResponseWriter, r *http.Request, params GetAnythingStringsParams)
}

ServerInterface represents all server handlers.

func NewStrictHandler

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

func NewStrictHandlerWithOptions

func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictHTTPServerOptions) ServerInterface

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

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

GetAnythingBooleans operation middleware

func (*ServerInterfaceWrapper) GetAnythingJsonschemaFormats

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

GetAnythingJsonschemaFormats operation middleware

func (*ServerInterfaceWrapper) GetAnythingNumbers

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

GetAnythingNumbers operation middleware

func (*ServerInterfaceWrapper) GetAnythingOasFormats

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

GetAnythingOasFormats operation middleware

func (*ServerInterfaceWrapper) GetAnythingStrings

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

GetAnythingStrings operation middleware

type StrictHTTPServerOptions

type StrictHTTPServerOptions struct {
	RequestErrorHandlerFunc  func(w http.ResponseWriter, r *http.Request, err error)
	ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StrictServerInterface

type StrictServerInterface interface {
	// Booleans
	// (GET /anything/booleans)
	GetAnythingBooleans(ctx context.Context, request GetAnythingBooleansRequestObject) (GetAnythingBooleansResponseObject, error)
	// Formats defined by JSON Schema
	// (GET /anything/jsonschema-formats)
	GetAnythingJsonschemaFormats(ctx context.Context, request GetAnythingJsonschemaFormatsRequestObject) (GetAnythingJsonschemaFormatsResponseObject, error)
	// Number validation
	// (GET /anything/numbers)
	GetAnythingNumbers(ctx context.Context, request GetAnythingNumbersRequestObject) (GetAnythingNumbersResponseObject, error)
	// Formats defined by OpenAPI
	// (GET /anything/oas-formats)
	GetAnythingOasFormats(ctx context.Context, request GetAnythingOasFormatsRequestObject) (GetAnythingOasFormatsResponseObject, error)
	// String validation
	// (GET /anything/strings)
	GetAnythingStrings(ctx context.Context, request GetAnythingStringsRequestObject) (GetAnythingStringsResponseObject, error)
}

StrictServerInterface represents all server handlers.

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

Jump to

Keyboard shortcuts

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