Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateSchema(model any, nameTag string) *base.Schema
- func GetInput[T any](c *http.Request) *T
- func NewAPIKeySecurityScheme(in string, name string, description ...string) *v3.SecurityScheme
- func NewGenerator() *generator
- func NewJWTSecurityScheme(description ...string) *v3.SecurityScheme
- type Engine
- func (r Engine) AddJSONResponse(code int, model any, description ...string) Router
- func (r Engine) AddSecurity(securityName string, scheme *v3.SecurityScheme) Router
- func (r Engine) AddTags(tags ...string) Router
- func (r Engine) Delete(pattern string, handler http.HandlerFunc) *OperationBuilder
- func (r Engine) Get(pattern string, handler http.HandlerFunc) *OperationBuilder
- func (r Engine) Group(fn func(Router)) Router
- func (r Engine) Head(pattern string, handler http.HandlerFunc) *OperationBuilder
- func (r Engine) HttpHandler() chi.Router
- func (r Engine) Method(method string, pattern string, handler http.HandlerFunc) *OperationBuilder
- func (r Engine) Mount(pattern string, sub *Engine)
- func (r Engine) OnAfterBind(hook HookAfterBind) Router
- func (r Engine) OnBeforeBind(hook HookBeforeBind) Router
- func (e *Engine) OpenAPI() *v3.Document
- func (r Engine) Options(pattern string, handler http.HandlerFunc) *OperationBuilder
- func (r Engine) Patch(pattern string, handler http.HandlerFunc) *OperationBuilder
- func (r Engine) Post(pattern string, handler http.HandlerFunc) *OperationBuilder
- func (r Engine) Put(pattern string, handler http.HandlerFunc) *OperationBuilder
- func (r Engine) Route(pattern string, fn func(sub Router)) Router
- func (e *Engine) ServeDocUI(pattern string, ui UIRender) *Engine
- func (e *Engine) ServeSpecJSON(pattern string) *Engine
- func (e *Engine) ServeSpecYAML(pattern string) *Engine
- func (r Engine) SetDeprecated(deprecated bool) Router
- func (r Engine) SetIgnoreAPIDoc(ignore bool) Router
- func (r Engine) Trace(pattern string, handler http.HandlerFunc) *OperationBuilder
- func (r Engine) Use(middlewares ...func(http.Handler) http.Handler)
- func (r Engine) With(middlewares ...func(http.Handler) http.Handler) Router
- type HookAfterBind
- type HookBeforeBind
- type OperationBuilder
- func (op *OperationBuilder) AddJSONResponse(code int, model any, description ...string) *OperationBuilder
- func (op *OperationBuilder) AddSecurity(securityName string, scheme *v3.SecurityScheme) *OperationBuilder
- func (op *OperationBuilder) AddTags(tags ...string) *OperationBuilder
- func (op *OperationBuilder) OK()
- func (op *OperationBuilder) OnAfterBind(hook HookAfterBind) *OperationBuilder
- func (op *OperationBuilder) OnBeforeBind(hook HookBeforeBind) *OperationBuilder
- func (op *OperationBuilder) SetDeprecated(deprecated *bool) *OperationBuilder
- func (op *OperationBuilder) SetDescription(desc string) *OperationBuilder
- func (op *OperationBuilder) SetIgnoreAPIDoc(ignore bool) *OperationBuilder
- func (op *OperationBuilder) SetInput(input any) *OperationBuilder
- func (op *OperationBuilder) SetOperationID(id string) *OperationBuilder
- func (op *OperationBuilder) SetSummary(summary string) *OperationBuilder
- type Router
- type UIRender
Constants ¶
const (
KeyInput ck = "soda::input"
)
Variables ¶
var ( OpenAPITag = "oai" SeparatorProp = ";" SeparatorPropItem = "," )
var ( UISwaggerUI = builtinUIRender{/* contains filtered or unexported fields */} UIRapiDoc = builtinUIRender{/* contains filtered or unexported fields */} UIStoplightElement = builtinUIRender{/* contains filtered or unexported fields */} UIRedoc = builtinUIRender{/* contains filtered or unexported fields */} )
Functions ¶
func GenerateSchema ¶
GenerateSchema generates an OpenAPI schema for a given model using the given name tag. It takes in the model to generate a schema for and a name tag to use for naming properties. It returns a *spec.Schema that represents the generated schema.
func NewAPIKeySecurityScheme ¶
func NewAPIKeySecurityScheme(in string, name string, description ...string) *v3.SecurityScheme
func NewJWTSecurityScheme ¶
func NewJWTSecurityScheme(description ...string) *v3.SecurityScheme
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (Engine) AddJSONResponse ¶
func (Engine) AddSecurity ¶
func (r Engine) AddSecurity(securityName string, scheme *v3.SecurityScheme) Router
func (Engine) Delete ¶
func (r Engine) Delete(pattern string, handler http.HandlerFunc) *OperationBuilder
func (Engine) Get ¶
func (r Engine) Get(pattern string, handler http.HandlerFunc) *OperationBuilder
func (Engine) Head ¶
func (r Engine) Head(pattern string, handler http.HandlerFunc) *OperationBuilder
func (Engine) HttpHandler ¶
func (r Engine) HttpHandler() chi.Router
func (Engine) Method ¶
func (r Engine) Method(method string, pattern string, handler http.HandlerFunc) *OperationBuilder
func (Engine) OnAfterBind ¶
func (r Engine) OnAfterBind(hook HookAfterBind) Router
func (Engine) OnBeforeBind ¶
func (r Engine) OnBeforeBind(hook HookBeforeBind) Router
func (Engine) Options ¶
func (r Engine) Options(pattern string, handler http.HandlerFunc) *OperationBuilder
func (Engine) Patch ¶
func (r Engine) Patch(pattern string, handler http.HandlerFunc) *OperationBuilder
func (Engine) Post ¶
func (r Engine) Post(pattern string, handler http.HandlerFunc) *OperationBuilder
func (Engine) Put ¶
func (r Engine) Put(pattern string, handler http.HandlerFunc) *OperationBuilder
func (*Engine) ServeDocUI ¶ added in v2.0.5
func (*Engine) ServeSpecJSON ¶ added in v2.0.5
func (*Engine) ServeSpecYAML ¶ added in v2.0.5
func (Engine) SetDeprecated ¶
func (Engine) SetIgnoreAPIDoc ¶
SetIgnoreAPIDoc implements Router.
func (Engine) Trace ¶
func (r Engine) Trace(pattern string, handler http.HandlerFunc) *OperationBuilder
type HookAfterBind ¶
HookAfterBind is a function type that is called after binding the request. It returns a boolean indicating whether to continue the process.
type HookBeforeBind ¶
type HookBeforeBind func(w http.ResponseWriter, r *http.Request) (doNext bool)
HookBeforeBind is a function type that is called before binding the request. It returns a boolean indicating whether to continue the process.
type OperationBuilder ¶
type OperationBuilder struct {
// contains filtered or unexported fields
}
OperationBuilder is a struct that helps in building an operation.
func (*OperationBuilder) AddJSONResponse ¶
func (op *OperationBuilder) AddJSONResponse(code int, model any, description ...string) *OperationBuilder
AddJSONResponse adds a JSON response to the operation.
func (*OperationBuilder) AddSecurity ¶
func (op *OperationBuilder) AddSecurity(securityName string, scheme *v3.SecurityScheme) *OperationBuilder
AddSecurity adds a security scheme to the operation.
func (*OperationBuilder) AddTags ¶
func (op *OperationBuilder) AddTags(tags ...string) *OperationBuilder
AddTags adds tags to the operation.
func (*OperationBuilder) OK ¶
func (op *OperationBuilder) OK()
OK finalizes the operation building process.
func (*OperationBuilder) OnAfterBind ¶
func (op *OperationBuilder) OnAfterBind(hook HookAfterBind) *OperationBuilder
OnAfterBind adds a hook that is called after binding the request.
func (*OperationBuilder) OnBeforeBind ¶
func (op *OperationBuilder) OnBeforeBind(hook HookBeforeBind) *OperationBuilder
OnBeforeBind adds a hook that is called before binding the request.
func (*OperationBuilder) SetDeprecated ¶
func (op *OperationBuilder) SetDeprecated(deprecated *bool) *OperationBuilder
SetDeprecated marks the operation as deprecated or not.
func (*OperationBuilder) SetDescription ¶
func (op *OperationBuilder) SetDescription(desc string) *OperationBuilder
SetDescription sets the description of the operation.
func (*OperationBuilder) SetIgnoreAPIDoc ¶
func (op *OperationBuilder) SetIgnoreAPIDoc(ignore bool) *OperationBuilder
SetIgnoreAPIDoc sets whether to ignore the operation when generating the API doc.
func (*OperationBuilder) SetInput ¶
func (op *OperationBuilder) SetInput(input any) *OperationBuilder
SetInput sets the input type for the operation.
func (*OperationBuilder) SetOperationID ¶
func (op *OperationBuilder) SetOperationID(id string) *OperationBuilder
SetOperationID sets the operation ID of the operation.
func (*OperationBuilder) SetSummary ¶
func (op *OperationBuilder) SetSummary(summary string) *OperationBuilder
SetSummary sets the summary of the operation.
type Router ¶
type Router interface { // HttpHandler returns the underlying chi.Router. HttpHandler() chi.Router // Method registers a handler function for the specified HTTP method and pattern. Method(method string, pattern string, handler http.HandlerFunc) *OperationBuilder // Delete registers a handler function for the DELETE HTTP method and pattern. Delete(pattern string, handler http.HandlerFunc) *OperationBuilder // Get registers a handler function for the GET HTTP method and pattern. Get(pattern string, handler http.HandlerFunc) *OperationBuilder // Head registers a handler function for the HEAD HTTP method and pattern. Head(pattern string, handler http.HandlerFunc) *OperationBuilder // Options registers a handler function for the OPTIONS HTTP method and pattern. Options(pattern string, handler http.HandlerFunc) *OperationBuilder // Patch registers a handler function for the PATCH HTTP method and pattern. Patch(pattern string, handler http.HandlerFunc) *OperationBuilder // Post registers a handler function for the POST HTTP method and pattern. Post(pattern string, handler http.HandlerFunc) *OperationBuilder // Put registers a handler function for the PUT HTTP method and pattern. Put(pattern string, handler http.HandlerFunc) *OperationBuilder // Trace registers a handler function for the TRACE HTTP method and pattern. Trace(pattern string, handler http.HandlerFunc) *OperationBuilder // Mount mounts a sub-router under the specified pattern. Mount(pattern string, sub *Engine) // Group creates a new sub-router and applies the provided function to it. Group(fn func(Router)) Router // With adds the specified middlewares to the router. With(middlewares ...func(http.Handler) http.Handler) Router // Route creates a new sub-router under the specified pattern and applies the provided function to it. Route(pattern string, fn func(sub Router)) Router // Use adds the specified middlewares to the router. Use(middlewares ...func(http.Handler) http.Handler) // AddTags adds the specified tags to the router. AddTags(tags ...string) Router // AddSecurity adds the specified security scheme to the router. AddSecurity(securityName string, scheme *v3.SecurityScheme) Router // AddJSONResponse adds a JSON response definition to the router. AddJSONResponse(code int, model any, description ...string) Router // SetDeprecated sets whether the router is deprecated or not. SetDeprecated(deprecated bool) Router // SetIgnoreAPIDoc sets whether the router should be ignored in the API documentation. SetIgnoreAPIDoc(ignore bool) Router // OnAfterBind sets a hook function to be called after binding the request. OnAfterBind(hook HookAfterBind) Router // OnBeforeBind sets a hook function to be called before binding the request. OnBeforeBind(hook HookBeforeBind) Router }
Router is an interface that represents a HTTP router.