parameters

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

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

Code generated by github.com/discord-gophers/goapi-gen version (devel) 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, opts ...ServerOption) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

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 ComplexObject

type ComplexObject struct {
	ID      int    `json:"Id"`
	IsAdmin bool   `json:"IsAdmin"`
	Object  Object `json:"Object"`
}

ComplexObject defines model for ComplexObject.

type GetCookieParams

type GetCookieParams struct {
	// primitive
	P *int32 `json:"p,omitempty"`

	// primitive
	Ep *int32 `json:"ep,omitempty"`

	// exploded array
	Ea []int32 `json:"ea,omitempty"`

	// array
	A []int32 `json:"a,omitempty"`

	// exploded object
	Eo *Object `json:"eo,omitempty"`

	// object
	O *Object `json:"o,omitempty"`

	// complex object
	Co *ComplexObject `json:"co,omitempty"`

	// name starting with number
	N1s *string `json:"1s,omitempty"`
}

GetCookieParams defines parameters for GetCookie.

type GetDeepObjectParams

type GetDeepObjectParams struct {
	// deep object
	DeepObj ComplexObject `json:"deepObj"`
}

GetDeepObjectParams defines parameters for GetDeepObject.

type GetHeaderParams

type GetHeaderParams struct {
	// primitive
	XPrimitive *int32 `json:"X-Primitive,omitempty"`

	// primitive
	XPrimitiveExploded *int32 `json:"X-Primitive-Exploded,omitempty"`

	// exploded array
	XArrayExploded []int32 `json:"X-Array-Exploded,omitempty"`

	// array
	XArray []int32 `json:"X-Array,omitempty"`

	// exploded object
	XObjectExploded *Object `json:"X-Object-Exploded,omitempty"`

	// object
	XObject *Object `json:"X-Object,omitempty"`

	// complex object
	XComplexObject *ComplexObject `json:"X-Complex-Object,omitempty"`

	// name starting with number
	N1StartingWithNumber *string `json:"1-Starting-With-Number,omitempty"`
}

GetHeaderParams defines parameters for GetHeader.

type GetQueryFormParams

type GetQueryFormParams struct {
	// exploded array
	Ea []int32 `json:"ea,omitempty"`

	// array
	A []int32 `json:"a,omitempty"`

	// exploded object
	Eo *Object `json:"eo,omitempty"`

	// object
	O *Object `json:"o,omitempty"`

	// exploded primitive
	Ep *int32 `json:"ep,omitempty"`

	// primitive
	P *int32 `json:"p,omitempty"`

	// primitive string
	Ps *string `json:"ps,omitempty"`

	// complex object
	Co *ComplexObject `json:"co,omitempty"`

	// name starting with number
	N1s *string `json:"1s,omitempty"`
}

GetQueryFormParams defines parameters for GetQueryForm.

type InvalidParamFormatError

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

func (InvalidParamFormatError) Error added in v0.2.0

func (err InvalidParamFormatError) Error() string

Error implements error.

func (InvalidParamFormatError) ParamName added in v0.2.0

func (err InvalidParamFormatError) ParamName() string

func (InvalidParamFormatError) Unwrap added in v0.2.0

func (err InvalidParamFormatError) Unwrap() error

type Object

type Object struct {
	FirstName string `json:"firstName"`
	Role      string `json:"role"`
}

Object defines model for Object.

type ParameterError added in v0.2.0

type ParameterError interface {
	error
	// ParamName is the name of the parameter that the error is referring to.
	ParamName() string
}

ParameterName is an interface that is implemented by error types that are relevant to a specific parameter.

type RequiredHeaderError

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

func (RequiredHeaderError) Error added in v0.2.0

func (err RequiredHeaderError) Error() string

Error implements error.

func (RequiredHeaderError) ParamName added in v0.2.0

func (err RequiredHeaderError) ParamName() string

type RequiredParamError

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

func (RequiredParamError) Error added in v0.2.0

func (err RequiredParamError) Error() string

Error implements error.

func (RequiredParamError) ParamName added in v0.2.0

func (err RequiredParamError) ParamName() string

func (RequiredParamError) Unwrap added in v0.2.0

func (err RequiredParamError) Unwrap() error

type Response

type Response struct {
	Code int
	// contains filtered or unexported fields
}

Response is a common response struct for all the API calls. A Response object may be instantiated via functions for specific operation responses. It may also be instantiated directly, for the purpose of responding with a single status code.

func (*Response) ContentType

func (resp *Response) ContentType(contentType string) *Response

ContentType is a builder method to override the default content type for a response.

func (*Response) MarshalJSON

func (resp *Response) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. This is used to only marshal the body of the response.

func (*Response) MarshalXML

func (resp *Response) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements the xml.Marshaler interface. This is used to only marshal the body of the response.

func (*Response) Render

func (resp *Response) Render(w http.ResponseWriter, r *http.Request) error

Render implements the render.Renderer interface. It sets the Content-Type header and status code based on the response definition.

func (*Response) Status

func (resp *Response) Status(code int) *Response

Status is a builder method to override the default status code for a response.

type ServerInterface

type ServerInterface interface {

	// (GET /contentObject/{param})
	GetContentObject(w http.ResponseWriter, r *http.Request, param ComplexObject) *Response

	// (GET /cookie)
	GetCookie(w http.ResponseWriter, r *http.Request, params GetCookieParams) *Response

	// (GET /header)
	GetHeader(w http.ResponseWriter, r *http.Request, params GetHeaderParams) *Response

	// (GET /labelExplodeArray/{.param*})
	GetLabelExplodeArray(w http.ResponseWriter, r *http.Request, param []int32) *Response

	// (GET /labelExplodeObject/{.param*})
	GetLabelExplodeObject(w http.ResponseWriter, r *http.Request, param Object) *Response

	// (GET /labelNoExplodeArray/{.param})
	GetLabelNoExplodeArray(w http.ResponseWriter, r *http.Request, param []int32) *Response

	// (GET /labelNoExplodeObject/{.param})
	GetLabelNoExplodeObject(w http.ResponseWriter, r *http.Request, param Object) *Response

	// (GET /matrixExplodeArray/{.id*})
	GetMatrixExplodeArray(w http.ResponseWriter, r *http.Request, id []int32) *Response

	// (GET /matrixExplodeObject/{.id*})
	GetMatrixExplodeObject(w http.ResponseWriter, r *http.Request, id Object) *Response

	// (GET /matrixNoExplodeArray/{.id})
	GetMatrixNoExplodeArray(w http.ResponseWriter, r *http.Request, id []int32) *Response

	// (GET /matrixNoExplodeObject/{.id})
	GetMatrixNoExplodeObject(w http.ResponseWriter, r *http.Request, id Object) *Response

	// (GET /passThrough/{param})
	GetPassThrough(w http.ResponseWriter, r *http.Request, param string) *Response

	// (GET /queryDeepObject)
	GetDeepObject(w http.ResponseWriter, r *http.Request, params GetDeepObjectParams) *Response

	// (GET /queryForm)
	GetQueryForm(w http.ResponseWriter, r *http.Request, params GetQueryFormParams) *Response

	// (GET /simpleExplodeArray/{param*})
	GetSimpleExplodeArray(w http.ResponseWriter, r *http.Request, param []int32) *Response

	// (GET /simpleExplodeObject/{param*})
	GetSimpleExplodeObject(w http.ResponseWriter, r *http.Request, param Object) *Response

	// (GET /simpleNoExplodeArray/{param})
	GetSimpleNoExplodeArray(w http.ResponseWriter, r *http.Request, param []int32) *Response

	// (GET /simpleNoExplodeObject/{param})
	GetSimpleNoExplodeObject(w http.ResponseWriter, r *http.Request, param Object) *Response

	// (GET /simplePrimitive/{param})
	GetSimplePrimitive(w http.ResponseWriter, r *http.Request, param int32) *Response

	// (GET /startingWithNumber/{1param})
	GetStartingWithNumber(w http.ResponseWriter, r *http.Request, n1param string) *Response
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

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

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) GetContentObject

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

GetContentObject operation middleware

func (*ServerInterfaceWrapper) GetCookie

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

GetCookie operation middleware

func (*ServerInterfaceWrapper) GetDeepObject

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

GetDeepObject operation middleware

func (*ServerInterfaceWrapper) GetHeader

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

GetHeader operation middleware

func (*ServerInterfaceWrapper) GetLabelExplodeArray

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

GetLabelExplodeArray operation middleware

func (*ServerInterfaceWrapper) GetLabelExplodeObject

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

GetLabelExplodeObject operation middleware

func (*ServerInterfaceWrapper) GetLabelNoExplodeArray

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

GetLabelNoExplodeArray operation middleware

func (*ServerInterfaceWrapper) GetLabelNoExplodeObject

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

GetLabelNoExplodeObject operation middleware

func (*ServerInterfaceWrapper) GetMatrixExplodeArray

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

GetMatrixExplodeArray operation middleware

func (*ServerInterfaceWrapper) GetMatrixExplodeObject

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

GetMatrixExplodeObject operation middleware

func (*ServerInterfaceWrapper) GetMatrixNoExplodeArray

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

GetMatrixNoExplodeArray operation middleware

func (*ServerInterfaceWrapper) GetMatrixNoExplodeObject

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

GetMatrixNoExplodeObject operation middleware

func (*ServerInterfaceWrapper) GetPassThrough

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

GetPassThrough operation middleware

func (*ServerInterfaceWrapper) GetQueryForm

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

GetQueryForm operation middleware

func (*ServerInterfaceWrapper) GetSimpleExplodeArray

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

GetSimpleExplodeArray operation middleware

func (*ServerInterfaceWrapper) GetSimpleExplodeObject

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

GetSimpleExplodeObject operation middleware

func (*ServerInterfaceWrapper) GetSimpleNoExplodeArray

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

GetSimpleNoExplodeArray operation middleware

func (*ServerInterfaceWrapper) GetSimpleNoExplodeObject

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

GetSimpleNoExplodeObject operation middleware

func (*ServerInterfaceWrapper) GetSimplePrimitive

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

GetSimplePrimitive operation middleware

func (*ServerInterfaceWrapper) GetStartingWithNumber

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

GetStartingWithNumber operation middleware

type ServerOption

type ServerOption func(*ServerOptions)

func WithErrorHandler

func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err error)) ServerOption

func WithRouter

func WithRouter(r chi.Router) ServerOption

func WithServerBaseURL

func WithServerBaseURL(url string) ServerOption

type ServerOptions

type ServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	NumValues int
	// contains filtered or unexported fields
}

func (TooManyValuesForParamError) Error added in v0.2.0

func (err TooManyValuesForParamError) Error() string

Error implements error.

func (TooManyValuesForParamError) ParamName added in v0.2.0

func (err TooManyValuesForParamError) ParamName() string

type UnescapedCookieParamError

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

func (UnescapedCookieParamError) Error added in v0.2.0

func (err UnescapedCookieParamError) Error() string

Error implements error.

func (UnescapedCookieParamError) ParamName added in v0.2.0

func (err UnescapedCookieParamError) ParamName() string

func (UnescapedCookieParamError) Unwrap added in v0.2.0

func (err UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

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

func (UnmarshalingParamError) Error added in v0.2.0

func (err UnmarshalingParamError) Error() string

Error implements error.

func (UnmarshalingParamError) ParamName added in v0.2.0

func (err UnmarshalingParamError) ParamName() string

func (UnmarshalingParamError) Unwrap added in v0.2.0

func (err UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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