Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateSchemaRef(model any, nameTag string, name ...string) *openapi3.SchemaRef
- func GetInput[T any](c *fiber.Ctx) *T
- func NewAPIKeySecurityScheme(in string, name string, description ...string) *openapi3.SecurityScheme
- func NewJWTSecurityScheme(description ...string) *openapi3.SecurityScheme
- type Engine
- type Generator
- type HookAfterBind
- type HookBeforeBind
- type OperationBuilder
- func (op *OperationBuilder) AddJSONResponse(code int, model any, description ...string) *OperationBuilder
- func (op *OperationBuilder) AddSecurity(securityName string, scheme *openapi3.SecurityScheme) *OperationBuilder
- func (op *OperationBuilder) AddTags(tags ...string) *OperationBuilder
- func (op *OperationBuilder) IgnoreAPIDoc(ignore bool) *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) SetInput(input any) *OperationBuilder
- func (op *OperationBuilder) SetOperationID(id string) *OperationBuilder
- func (op *OperationBuilder) SetSummary(summary string) *OperationBuilder
- type Router
- func (r *Router) Add(method string, pattern string, handlers ...fiber.Handler) *OperationBuilder
- func (r *Router) AddJSONResponse(code int, model any, description ...string) *Router
- func (r *Router) AddSecurity(securityName string, scheme *openapi3.SecurityScheme) *Router
- func (r *Router) AddTags(tags ...string) *Router
- func (r *Router) Delete(pattern string, handlers ...fiber.Handler) *OperationBuilder
- func (r *Router) Get(pattern string, handlers ...fiber.Handler) *OperationBuilder
- func (r *Router) Group(prefix string, handlers ...fiber.Handler) *Router
- func (r *Router) Head(pattern string, handlers ...fiber.Handler) *OperationBuilder
- func (r *Router) OnAfterBind(hook HookAfterBind) *Router
- func (r *Router) OnBeforeBind(hook HookBeforeBind) *Router
- func (r *Router) Options(pattern string, handlers ...fiber.Handler) *OperationBuilder
- func (r *Router) Patch(pattern string, handlers ...fiber.Handler) *OperationBuilder
- func (r *Router) Post(pattern string, handlers ...fiber.Handler) *OperationBuilder
- func (r *Router) Put(pattern string, handlers ...fiber.Handler) *OperationBuilder
- func (r *Router) SetDeprecated(deprecated bool) *Router
- func (r *Router) SetIgnoreAPIDoc(ignore bool) *Router
- func (r *Router) Trace(pattern string, handlers ...fiber.Handler) *OperationBuilder
- type UIRender
Constants ¶
const (
KeyInput ck = "soda::input"
)
Variables ¶
var ( OpenAPITag = "oai" SeparatorProp = ";" SeparatorPropItem = "," HeaderTag = openapi3.ParameterInHeader QueryTag = openapi3.ParameterInQuery CookieTag = openapi3.ParameterInCookie PathTag = openapi3.ParameterInPath )
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 GenerateSchemaRef ¶
GenerateSchemaRef 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 GetInput ¶
func GetInput[T any](c *fiber.Ctx) *T
GetInput gets the input value from the http request.
func NewAPIKeySecurityScheme ¶
func NewAPIKeySecurityScheme(in string, name string, description ...string) *openapi3.SecurityScheme
func NewJWTSecurityScheme ¶
func NewJWTSecurityScheme(description ...string) *openapi3.SecurityScheme
Types ¶
type Engine ¶
type Engine struct { *Router // contains filtered or unexported fields }
func (*Engine) ServeSpecJSON ¶
func (*Engine) ServeSpecYAML ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator Define the Generator struct.
func (*Generator) GenerateParameters ¶
func (g *Generator) GenerateParameters(model reflect.Type) openapi3.Parameters
GenerateParameters generates OpenAPI TestCase for a given model.
func (*Generator) GenerateRequestBody ¶
func (g *Generator) GenerateRequestBody(operationID, nameTag string, model reflect.Type) *openapi3.RequestBody
GenerateRequestBody generates an OpenAPI request body for a given model using the given operation ID and name tag. It takes in the operation ID to use for naming the request body, the name tag to use for naming properties, and the model to generate a request body for. It returns a *spec.RequestBody that represents the generated request body.
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(ctx *fiber.Ctx) error
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 *openapi3.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) IgnoreAPIDoc ¶
func (op *OperationBuilder) IgnoreAPIDoc(ignore bool) *OperationBuilder
SetIgnoreAPIDoc sets whether to ignore the operation when generating the API doc.
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) 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 struct { Raw fiber.Router // contains filtered or unexported fields }
func (*Router) Add ¶
func (r *Router) Add(method string, pattern string, handlers ...fiber.Handler) *OperationBuilder
func (*Router) AddJSONResponse ¶
func (*Router) AddSecurity ¶
func (r *Router) AddSecurity(securityName string, scheme *openapi3.SecurityScheme) *Router
func (*Router) Delete ¶
func (r *Router) Delete(pattern string, handlers ...fiber.Handler) *OperationBuilder
func (*Router) Get ¶
func (r *Router) Get(pattern string, handlers ...fiber.Handler) *OperationBuilder
func (*Router) Head ¶
func (r *Router) Head(pattern string, handlers ...fiber.Handler) *OperationBuilder
func (*Router) OnAfterBind ¶
func (r *Router) OnAfterBind(hook HookAfterBind) *Router
func (*Router) OnBeforeBind ¶
func (r *Router) OnBeforeBind(hook HookBeforeBind) *Router
func (*Router) Options ¶
func (r *Router) Options(pattern string, handlers ...fiber.Handler) *OperationBuilder
func (*Router) Patch ¶
func (r *Router) Patch(pattern string, handlers ...fiber.Handler) *OperationBuilder
func (*Router) Post ¶
func (r *Router) Post(pattern string, handlers ...fiber.Handler) *OperationBuilder
func (*Router) Put ¶
func (r *Router) Put(pattern string, handlers ...fiber.Handler) *OperationBuilder
func (*Router) SetDeprecated ¶
func (*Router) SetIgnoreAPIDoc ¶
SetIgnoreAPIDoc implements Router.
func (*Router) Trace ¶
func (r *Router) Trace(pattern string, handlers ...fiber.Handler) *OperationBuilder