Documentation ¶
Index ¶
- Variables
- func DefaultErrorHandler(err error, c echo.Context)
- func ExtractJSONTags(field reflect.StructField) (string, bool)
- func ExtractValidationRules(field reflect.StructField, schema *v310.Schema)
- func PtrTo[T any](v T) *T
- type APIWrapper
- func (w *APIWrapper) Add(method string, path string, handler echo.HandlerFunc, ...) *RouteWrapper
- func (w *APIWrapper) DELETE(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (w *APIWrapper) GET(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (w *APIWrapper) Group(prefix string, config ...GroupConfigFunc) *GroupWrapper
- func (w *APIWrapper) HEAD(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (w *APIWrapper) OPTIONS(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (w *APIWrapper) PATCH(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (w *APIWrapper) POST(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (w *APIWrapper) PUT(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (w *APIWrapper) ServeJSONSpec(path string, filters ...SpecFilterFunc) *echo.Route
- func (w *APIWrapper) ServeRapidoc(path string, schemaPath string) *echo.Route
- func (w *APIWrapper) ServeSwaggerUI(path string, schemaPath string, version string) *echo.Route
- func (w *APIWrapper) ServeYAMLSpec(path string, filters ...SpecFilterFunc) *echo.Route
- func (a *APIWrapper) SetBaseURL(baseURL string)
- func (a *APIWrapper) SetErrorHandler(h echo.HTTPErrorHandler)
- func (a *APIWrapper) SetSpecContact(c *v310.Contact)
- func (a *APIWrapper) SetSpecDescription(desc string)
- func (a *APIWrapper) SetSpecExternalDocs(d *v310.ExternalDocs)
- func (a *APIWrapper) SetSpecLicense(l *v310.License)
- func (a *APIWrapper) SetTermsOfService(tos string)
- func (w *APIWrapper) Start(addr string) error
- func (w *APIWrapper) StructFieldToSchemaRef(f reflect.StructField) *v310.Ref[v310.Schema]
- func (w *APIWrapper) StructTypeToSchema(target reflect.Type, nameTag string) *v310.Schema
- func (w *APIWrapper) TRACE(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (w *APIWrapper) ToSchemaRef(target interface{}) *v310.Ref[v310.Schema]
- func (w *APIWrapper) TypeToSchema(typ reflect.Type) *v310.Schema
- func (w *APIWrapper) TypeToSchemaRef(typ reflect.Type) *v310.Ref[v310.Schema]
- func (w *APIWrapper) WriteYAMLSpec(path string) error
- type Config
- type CookieParameterConfig
- type GroupConfigFunc
- type GroupWrapper
- func (g *GroupWrapper) Add(method string, path string, handler echo.HandlerFunc, ...) *RouteWrapper
- func (g *GroupWrapper) DELETE(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (g *GroupWrapper) GET(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (g *GroupWrapper) Group(prefix string, config ...GroupConfigFunc) *GroupWrapper
- func (g *GroupWrapper) HEAD(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (g *GroupWrapper) OPTIONS(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (g *GroupWrapper) PATCH(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (g *GroupWrapper) POST(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (g *GroupWrapper) PUT(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- func (g *GroupWrapper) TRACE(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
- type HeaderParameterConfig
- type PathParameterConfig
- type ResponseStructConfig
- type RouteConfigFunc
- func WithCookieParameter(name string, description string, example interface{}) RouteConfigFunc
- func WithCookieParameterConfig(c *CookieParameterConfig) RouteConfigFunc
- func WithDeprecated() RouteConfigFunc
- func WithDescription(desc string) RouteConfigFunc
- func WithFormStruct(target interface{}) RouteConfigFunc
- func WithHeaderParameter(name string, description string, example interface{}) RouteConfigFunc
- func WithHeaderParameterConfig(c *HeaderParameterConfig) RouteConfigFunc
- func WithMiddlewares(m ...echo.MiddlewareFunc) RouteConfigFunc
- func WithOperationID(id string) RouteConfigFunc
- func WithOptionalSecurity() RouteConfigFunc
- func WithParameter(param *v310.Parameter) RouteConfigFunc
- func WithPathParameter(name string, description string, example interface{}) RouteConfigFunc
- func WithPathParameterConfig(c *PathParameterConfig) RouteConfigFunc
- func WithQueryStruct(target interface{}) RouteConfigFunc
- func WithRequestBody(rb *v310.RequestBody) RouteConfigFunc
- func WithRequestBodyRef(name string) RouteConfigFunc
- func WithRequestBodySchema(mime string, s *v310.Schema) RouteConfigFunc
- func WithRequestBodyStruct(mime string, description string, target interface{}) RouteConfigFunc
- func WithResponse(code string, resp *v310.Response) RouteConfigFunc
- func WithResponseDescription(code string, description string) RouteConfigFunc
- func WithResponseFile(code string, description string, mime string) RouteConfigFunc
- func WithResponseRef(code string, name string) RouteConfigFunc
- func WithResponseStruct(code string, description string, target interface{}) RouteConfigFunc
- func WithResponseStructConfig(code string, config *ResponseStructConfig) RouteConfigFunc
- func WithResponseType(code string, description string, example interface{}) RouteConfigFunc
- func WithSecurityRequirement(name string, scopes []string) RouteConfigFunc
- func WithSummary(sum string) RouteConfigFunc
- func WithTags(tags ...string) RouteConfigFunc
- type RouteWrapper
- type SpecFilterFunc
- type WrapperConfigFunc
- func WithBaseURL(baseURL string) WrapperConfigFunc
- func WithSpecContact(c *v310.Contact) WrapperConfigFunc
- func WithSpecDescription(desc string) WrapperConfigFunc
- func WithSpecExternalDocs(d *v310.ExternalDocs) WrapperConfigFunc
- func WithSpecLicense(l *v310.License) WrapperConfigFunc
- func WithSpecServer(s *v310.Server) WrapperConfigFunc
- func WithSpecTag(t *v310.Tag) WrapperConfigFunc
- func WithSpecTermsOfService(tos string) WrapperConfigFunc
Constants ¶
This section is empty.
Variables ¶
var ( ErrRequiredParameterMissing = fmt.Errorf("echopen: required parameter missing") ErrSecurityRequirementsNotMet = fmt.Errorf("echopen: at least one required security scheme must be provided") ErrContentTypeNotSupported = fmt.Errorf("echopen: request did not match defined content types") )
Functions ¶
func DefaultErrorHandler ¶
func DefaultErrorHandler(err error, c echo.Context)
Extend the default echo handler to cover errors defined by echopen
func ExtractJSONTags ¶
func ExtractJSONTags(field reflect.StructField) (string, bool)
func ExtractValidationRules ¶
func ExtractValidationRules(field reflect.StructField, schema *v310.Schema)
ExtractValidationRules extracts known rules from the "validate" tag. Assumes use of github.com/go-playground/validator/v10
Types ¶
type APIWrapper ¶
type APIWrapper struct { Spec *v310.Specification Engine *echo.Echo Config *Config // contains filtered or unexported fields }
func New ¶
func New(title string, apiVersion string, config ...WrapperConfigFunc) *APIWrapper
func (*APIWrapper) Add ¶
func (w *APIWrapper) Add(method string, path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
Register a new route with the given method and path
func (*APIWrapper) DELETE ¶
func (w *APIWrapper) DELETE(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*APIWrapper) GET ¶
func (w *APIWrapper) GET(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*APIWrapper) Group ¶
func (w *APIWrapper) Group(prefix string, config ...GroupConfigFunc) *GroupWrapper
Create a new group with prefix and optional group-specific configuration
func (*APIWrapper) HEAD ¶
func (w *APIWrapper) HEAD(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*APIWrapper) OPTIONS ¶
func (w *APIWrapper) OPTIONS(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*APIWrapper) PATCH ¶
func (w *APIWrapper) PATCH(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*APIWrapper) POST ¶
func (w *APIWrapper) POST(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*APIWrapper) PUT ¶
func (w *APIWrapper) PUT(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*APIWrapper) ServeJSONSpec ¶
func (w *APIWrapper) ServeJSONSpec(path string, filters ...SpecFilterFunc) *echo.Route
func (*APIWrapper) ServeRapidoc ¶
func (w *APIWrapper) ServeRapidoc(path string, schemaPath string) *echo.Route
func (*APIWrapper) ServeSwaggerUI ¶
func (w *APIWrapper) ServeSwaggerUI(path string, schemaPath string, version string) *echo.Route
func (*APIWrapper) ServeYAMLSpec ¶
func (w *APIWrapper) ServeYAMLSpec(path string, filters ...SpecFilterFunc) *echo.Route
func (*APIWrapper) SetBaseURL ¶
func (a *APIWrapper) SetBaseURL(baseURL string)
func (*APIWrapper) SetErrorHandler ¶
func (a *APIWrapper) SetErrorHandler(h echo.HTTPErrorHandler)
func (*APIWrapper) SetSpecContact ¶
func (a *APIWrapper) SetSpecContact(c *v310.Contact)
func (*APIWrapper) SetSpecDescription ¶
func (a *APIWrapper) SetSpecDescription(desc string)
func (*APIWrapper) SetSpecExternalDocs ¶
func (a *APIWrapper) SetSpecExternalDocs(d *v310.ExternalDocs)
func (*APIWrapper) SetSpecLicense ¶
func (a *APIWrapper) SetSpecLicense(l *v310.License)
func (*APIWrapper) SetTermsOfService ¶
func (a *APIWrapper) SetTermsOfService(tos string)
func (*APIWrapper) Start ¶
func (w *APIWrapper) Start(addr string) error
Start starts an HTTP server
func (*APIWrapper) StructFieldToSchemaRef ¶
func (w *APIWrapper) StructFieldToSchemaRef(f reflect.StructField) *v310.Ref[v310.Schema]
func (*APIWrapper) StructTypeToSchema ¶
StructTypeToSchema iterates over struct fields to build a schema. Assumes JSON content type.
func (*APIWrapper) TRACE ¶
func (w *APIWrapper) TRACE(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*APIWrapper) ToSchemaRef ¶
func (w *APIWrapper) ToSchemaRef(target interface{}) *v310.Ref[v310.Schema]
ToSchemaRef takes a target value, extracts the type information, and returns a SchemaRef for that type
func (*APIWrapper) TypeToSchema ¶
func (w *APIWrapper) TypeToSchema(typ reflect.Type) *v310.Schema
TypeToSchema looks up the schema type for a given reflected type
func (*APIWrapper) TypeToSchemaRef ¶
TypeToSchemaRef takes a reflected type and returns a SchemaRef. Where possible a Ref will be returned instead of a Value. Struct names are assumed to be unique and thus conform to the same schema
func (*APIWrapper) WriteYAMLSpec ¶
func (w *APIWrapper) WriteYAMLSpec(path string) error
type CookieParameterConfig ¶
type GroupConfigFunc ¶
type GroupConfigFunc func(*GroupWrapper) *GroupWrapper
func WithGroupMiddlewares ¶
func WithGroupMiddlewares(m ...echo.MiddlewareFunc) GroupConfigFunc
func WithGroupSecurityRequirement ¶
func WithGroupSecurityRequirement(req *v310.SecurityRequirement) GroupConfigFunc
func WithGroupTags ¶
func WithGroupTags(tags ...string) GroupConfigFunc
type GroupWrapper ¶
type GroupWrapper struct { API *APIWrapper GroupWrapper *GroupWrapper Prefix string Middlewares []echo.MiddlewareFunc Tags []string SecurityRequirements []*v310.SecurityRequirement RouterGroup *echo.Group }
func (*GroupWrapper) Add ¶
func (g *GroupWrapper) Add(method string, path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
Add a route to the group
func (*GroupWrapper) DELETE ¶
func (g *GroupWrapper) DELETE(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*GroupWrapper) GET ¶
func (g *GroupWrapper) GET(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*GroupWrapper) Group ¶
func (g *GroupWrapper) Group(prefix string, config ...GroupConfigFunc) *GroupWrapper
Create a new sub-group with prefix and optional group-specific configuration
func (*GroupWrapper) HEAD ¶
func (g *GroupWrapper) HEAD(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*GroupWrapper) OPTIONS ¶
func (g *GroupWrapper) OPTIONS(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*GroupWrapper) PATCH ¶
func (g *GroupWrapper) PATCH(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*GroupWrapper) POST ¶
func (g *GroupWrapper) POST(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*GroupWrapper) PUT ¶
func (g *GroupWrapper) PUT(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
func (*GroupWrapper) TRACE ¶
func (g *GroupWrapper) TRACE(path string, handler echo.HandlerFunc, config ...RouteConfigFunc) *RouteWrapper
type HeaderParameterConfig ¶
type PathParameterConfig ¶
type ResponseStructConfig ¶
type RouteConfigFunc ¶
type RouteConfigFunc func(*RouteWrapper) *RouteWrapper
func WithCookieParameter ¶
func WithCookieParameter(name string, description string, example interface{}) RouteConfigFunc
func WithCookieParameterConfig ¶
func WithCookieParameterConfig(c *CookieParameterConfig) RouteConfigFunc
func WithDeprecated ¶
func WithDeprecated() RouteConfigFunc
func WithDescription ¶
func WithDescription(desc string) RouteConfigFunc
func WithFormStruct ¶
func WithFormStruct(target interface{}) RouteConfigFunc
WithFormStruct extracts type information from a provided struct to populate the OpenAPI operation parameters. A bound struct of the same type is added to the context under the key "form" during each request Binding will use either request body or query params (GET/DELETE only)
func WithHeaderParameter ¶
func WithHeaderParameter(name string, description string, example interface{}) RouteConfigFunc
func WithHeaderParameterConfig ¶
func WithHeaderParameterConfig(c *HeaderParameterConfig) RouteConfigFunc
func WithMiddlewares ¶
func WithMiddlewares(m ...echo.MiddlewareFunc) RouteConfigFunc
func WithOperationID ¶
func WithOperationID(id string) RouteConfigFunc
func WithOptionalSecurity ¶
func WithOptionalSecurity() RouteConfigFunc
func WithParameter ¶
func WithParameter(param *v310.Parameter) RouteConfigFunc
func WithPathParameter ¶
func WithPathParameter(name string, description string, example interface{}) RouteConfigFunc
func WithPathParameterConfig ¶
func WithPathParameterConfig(c *PathParameterConfig) RouteConfigFunc
func WithQueryStruct ¶
func WithQueryStruct(target interface{}) RouteConfigFunc
WithQueryStruct extracts type information from a provided struct to populate the OpenAPI operation parameters. A bound struct of the same type is added to the context under the key "query" during each request
func WithRequestBody ¶
func WithRequestBody(rb *v310.RequestBody) RouteConfigFunc
func WithRequestBodyRef ¶
func WithRequestBodyRef(name string) RouteConfigFunc
func WithRequestBodySchema ¶
func WithRequestBodySchema(mime string, s *v310.Schema) RouteConfigFunc
func WithRequestBodyStruct ¶
func WithRequestBodyStruct(mime string, description string, target interface{}) RouteConfigFunc
WithRequestBodyStruct extracts type information from a provided struct to populate the OpenAPI requestBody. A bound struct of the same type is added to the context under the key "body" during each request.
func WithResponse ¶
func WithResponse(code string, resp *v310.Response) RouteConfigFunc
func WithResponseDescription ¶
func WithResponseDescription(code string, description string) RouteConfigFunc
func WithResponseFile ¶
func WithResponseFile(code string, description string, mime string) RouteConfigFunc
func WithResponseRef ¶
func WithResponseRef(code string, name string) RouteConfigFunc
func WithResponseStruct ¶
func WithResponseStruct(code string, description string, target interface{}) RouteConfigFunc
func WithResponseStructConfig ¶
func WithResponseStructConfig(code string, config *ResponseStructConfig) RouteConfigFunc
func WithResponseType ¶
func WithResponseType(code string, description string, example interface{}) RouteConfigFunc
func WithSecurityRequirement ¶
func WithSecurityRequirement(name string, scopes []string) RouteConfigFunc
WithSecurityRequirement attaches a requirement to a route that the matching security scheme is fulfilled. Attaches middleware that adds the security scheme value and scopes to the context at security.<name> and security.<name>.scopes
func WithSummary ¶
func WithSummary(sum string) RouteConfigFunc
func WithTags ¶
func WithTags(tags ...string) RouteConfigFunc
type RouteWrapper ¶
type SpecFilterFunc ¶
type SpecFilterFunc = func(s *v310.Specification) *v310.Specification
func ExcludeTags ¶
func ExcludeTags(tags ...string) SpecFilterFunc
func IncludeTags ¶
func IncludeTags(tags ...string) SpecFilterFunc
type WrapperConfigFunc ¶
type WrapperConfigFunc func(*APIWrapper) *APIWrapper
func WithBaseURL ¶
func WithBaseURL(baseURL string) WrapperConfigFunc
func WithSpecContact ¶
func WithSpecContact(c *v310.Contact) WrapperConfigFunc
func WithSpecDescription ¶
func WithSpecDescription(desc string) WrapperConfigFunc
func WithSpecExternalDocs ¶
func WithSpecExternalDocs(d *v310.ExternalDocs) WrapperConfigFunc
func WithSpecLicense ¶
func WithSpecLicense(l *v310.License) WrapperConfigFunc
func WithSpecServer ¶
func WithSpecServer(s *v310.Server) WrapperConfigFunc
func WithSpecTag ¶
func WithSpecTag(t *v310.Tag) WrapperConfigFunc
func WithSpecTermsOfService ¶
func WithSpecTermsOfService(tos string) WrapperConfigFunc