Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateSchema(model interface{}, nameTag string) *spec.Schema
- func GetInput[T any](c *fiber.Ctx) *T
- func NewGenerator() *generator
- type Group
- func (g *Group) AddJSONResponse(status int, model interface{}, description ...string) *Group
- func (g *Group) AddSecurity(name string, scheme *spec.SecurityScheme) *Group
- func (g *Group) AddTags(tags ...string) *Group
- func (g *Group) Delete(path string, handlers ...fiber.Handler) *OperationBuilder
- func (g *Group) Fiber() *fiber.App
- func (g *Group) Get(path string, handlers ...fiber.Handler) *OperationBuilder
- func (g *Group) Group(prefix string, handlers ...fiber.Handler) *Group
- func (g *Group) Head(path string, handlers ...fiber.Handler) *OperationBuilder
- func (g *Group) OnAfterBind(hook HookAfterBind) *Group
- func (g *Group) OnBeforeBind(hook HookBeforeBind) *Group
- func (g *Group) Operation(path, method string, handlers ...fiber.Handler) *OperationBuilder
- func (g *Group) Options(path string, handlers ...fiber.Handler) *OperationBuilder
- func (g *Group) Patch(path string, handlers ...fiber.Handler) *OperationBuilder
- func (g *Group) Post(path string, handlers ...fiber.Handler) *OperationBuilder
- func (g *Group) Put(path string, handlers ...fiber.Handler) *OperationBuilder
- func (g *Group) SetDeprecated(deprecated bool) *Group
- func (g *Group) Trace(path string, handlers ...fiber.Handler) *OperationBuilder
- type HookAfterBind
- type HookBeforeBind
- type OperationBuilder
- func (op *OperationBuilder) AddJSONResponse(code int, model any, description ...string) *OperationBuilder
- func (op *OperationBuilder) AddSecurity(name string, scheme *spec.SecurityScheme) *OperationBuilder
- func (op *OperationBuilder) AddTags(tags ...string) *OperationBuilder
- func (op *OperationBuilder) OK() *OperationBuilder
- 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 interface{}) *OperationBuilder
- func (op *OperationBuilder) SetOperationID(id string) *OperationBuilder
- func (op *OperationBuilder) SetSummary(summary string) *OperationBuilder
- type Soda
- func (s *Soda) AddJSONSpec(path string) *Soda
- func (s *Soda) AddUI(path string, ui UIRender) *Soda
- func (s *Soda) AddYAMLSpec(path string) *Soda
- func (s *Soda) Delete(path string, handlers ...fiber.Handler) *OperationBuilder
- func (s *Soda) Get(path string, handlers ...fiber.Handler) *OperationBuilder
- func (s *Soda) Group(prefix string, handlers ...fiber.Handler) *Group
- func (s *Soda) Head(path string, handlers ...fiber.Handler) *OperationBuilder
- func (s *Soda) OpenAPI() *spec.OpenAPI
- func (s *Soda) Operation(path, method string, handlers ...fiber.Handler) *OperationBuilder
- func (s *Soda) Options(path string, handlers ...fiber.Handler) *OperationBuilder
- func (s *Soda) Patch(path string, handlers ...fiber.Handler) *OperationBuilder
- func (s *Soda) Post(path string, handlers ...fiber.Handler) *OperationBuilder
- func (s *Soda) Put(path string, handlers ...fiber.Handler) *OperationBuilder
- func (s *Soda) Trace(path string, handlers ...fiber.Handler) *OperationBuilder
- type UIRender
Constants ¶
const (
KeyInput = "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.
Types ¶
type Group ¶ added in v1.5.0
type Group struct {
// contains filtered or unexported fields
}
func (*Group) AddJSONResponse ¶ added in v1.6.0
AddJSONResponse adds a JSON response to the groups.
func (*Group) AddSecurity ¶ added in v1.5.0
func (g *Group) AddSecurity(name string, scheme *spec.SecurityScheme) *Group
AddSecurity adds a security scheme to the group.
func (*Group) Delete ¶ added in v1.5.0
func (g *Group) Delete(path string, handlers ...fiber.Handler) *OperationBuilder
Delete adds a DELETE operation.
func (*Group) Fiber ¶ added in v1.5.0
func (g *Group) Fiber() *fiber.App
Fiber returns the underlying fiber app.
func (*Group) Get ¶ added in v1.5.0
func (g *Group) Get(path string, handlers ...fiber.Handler) *OperationBuilder
Get adds a GET operation.
func (*Group) Group ¶ added in v1.5.0
Group creates a new sub-group with optional prefix and middleware.
func (*Group) Head ¶ added in v1.5.0
func (g *Group) Head(path string, handlers ...fiber.Handler) *OperationBuilder
Head adds a HEAD operation.
func (*Group) OnAfterBind ¶ added in v1.5.0
func (g *Group) OnAfterBind(hook HookAfterBind) *Group
OnAfterBind adds a hook to be executed after the operation is bound.
func (*Group) OnBeforeBind ¶ added in v1.6.0
func (g *Group) OnBeforeBind(hook HookBeforeBind) *Group
OnBeforeBind adds a hook to be executed after the operation is bound.
func (*Group) Operation ¶ added in v1.5.0
func (g *Group) Operation(path, method string, handlers ...fiber.Handler) *OperationBuilder
Operation adds an operation.
func (*Group) Options ¶ added in v1.5.0
func (g *Group) Options(path string, handlers ...fiber.Handler) *OperationBuilder
Options adds an OPTIONS operation.
func (*Group) Patch ¶ added in v1.5.0
func (g *Group) Patch(path string, handlers ...fiber.Handler) *OperationBuilder
Patch adds a PATCH operation.
func (*Group) Post ¶ added in v1.5.0
func (g *Group) Post(path string, handlers ...fiber.Handler) *OperationBuilder
Post adds a POST operation.
func (*Group) Put ¶ added in v1.5.0
func (g *Group) Put(path string, handlers ...fiber.Handler) *OperationBuilder
Put adds a PUT operation.
func (*Group) SetDeprecated ¶ added in v1.5.0
SetDeprecated sets the deprecated flag for the group.
func (*Group) Trace ¶ added in v1.5.0
func (g *Group) Trace(path string, handlers ...fiber.Handler) *OperationBuilder
Trace adds a TRACE operation.
type HookAfterBind ¶ added in v1.5.0
type HookAfterBind func(c *fiber.Ctx, input interface{}) error
type HookBeforeBind ¶ added in v1.6.0
type HookBeforeBind func(c *fiber.Ctx) error
type OperationBuilder ¶
type OperationBuilder struct {
// contains filtered or unexported fields
}
OperationBuilder is a builder for a single operation.
func (*OperationBuilder) AddJSONResponse ¶
func (op *OperationBuilder) AddJSONResponse(code int, model any, description ...string) *OperationBuilder
AddJSONResponse adds a JSON response to the operation's responses. If model is not nil, a JSON response is generated for the model type. If model is nil, a JSON response is generated with no schema.
func (*OperationBuilder) AddSecurity ¶
func (op *OperationBuilder) AddSecurity(name string, scheme *spec.SecurityScheme) *OperationBuilder
AddJWTSecurity adds JWT authentication to this operation with the given validators.
func (*OperationBuilder) AddTags ¶
func (op *OperationBuilder) AddTags(tags ...string) *OperationBuilder
AddTags add tags to the operation.
func (*OperationBuilder) OK ¶
func (op *OperationBuilder) OK() *OperationBuilder
func (*OperationBuilder) OnAfterBind ¶ added in v1.5.0
func (op *OperationBuilder) OnAfterBind(hook HookAfterBind) *OperationBuilder
func (*OperationBuilder) OnBeforeBind ¶ added in v1.6.0
func (op *OperationBuilder) OnBeforeBind(hook HookBeforeBind) *OperationBuilder
func (*OperationBuilder) SetDeprecated ¶
func (op *OperationBuilder) SetDeprecated(deprecated bool) *OperationBuilder
SetDeprecated marks the operation as deprecated.
func (*OperationBuilder) SetDescription ¶
func (op *OperationBuilder) SetDescription(desc string) *OperationBuilder
SetDescription sets the operation description.
func (*OperationBuilder) SetInput ¶
func (op *OperationBuilder) SetInput(input interface{}) *OperationBuilder
SetInput sets the input for this operation. The input must be a pointer to a struct. If the struct has a field with the `body:"<media type>"` tag, that field is used for the request body. Otherwise, the struct is used for parameters.
func (*OperationBuilder) SetOperationID ¶
func (op *OperationBuilder) SetOperationID(id string) *OperationBuilder
SetSummary sets the operation-id.
func (*OperationBuilder) SetSummary ¶
func (op *OperationBuilder) SetSummary(summary string) *OperationBuilder
SetSummary sets the operation summary.
type Soda ¶
type Soda struct { Fiber *fiber.App // contains filtered or unexported fields }
Soda is the main class of the package. It contains the spec and the fiber app.
func (*Soda) AddJSONSpec ¶
AddJSONSpec adds the OpenAPI spec at the given path in JSON format.
func (*Soda) AddYAMLSpec ¶
AddYAMLSpec adds the OpenAPI spec at the given path in YAML format.
func (*Soda) Delete ¶
func (s *Soda) Delete(path string, handlers ...fiber.Handler) *OperationBuilder
Delete adds a DELETE operation.
func (*Soda) Get ¶
func (s *Soda) Get(path string, handlers ...fiber.Handler) *OperationBuilder
Get adds a GET operation.
func (*Soda) Head ¶ added in v1.5.0
func (s *Soda) Head(path string, handlers ...fiber.Handler) *OperationBuilder
Head adds a HEAD operation.
func (*Soda) Operation ¶
func (s *Soda) Operation(path, method string, handlers ...fiber.Handler) *OperationBuilder
Operation adds an operation.
func (*Soda) Options ¶ added in v1.5.0
func (s *Soda) Options(path string, handlers ...fiber.Handler) *OperationBuilder
Options adds an OPTIONS operation.
func (*Soda) Patch ¶
func (s *Soda) Patch(path string, handlers ...fiber.Handler) *OperationBuilder
Patch adds a PATCH operation.
func (*Soda) Post ¶
func (s *Soda) Post(path string, handlers ...fiber.Handler) *OperationBuilder
Post adds a POST operation.
func (*Soda) Put ¶
func (s *Soda) Put(path string, handlers ...fiber.Handler) *OperationBuilder
Put adds a PUT operation.
func (*Soda) Trace ¶ added in v1.5.0
func (s *Soda) Trace(path string, handlers ...fiber.Handler) *OperationBuilder
Trace adds a TRACE operation.