Documentation
¶
Index ¶
- Variables
- func Deprecated(deprecated bool) func(*openapi.OperationInfo)
- func Description(desc string) func(*openapi.OperationInfo)
- func Descriptionf(format string, a ...interface{}) func(*openapi.OperationInfo)
- func Header(name, desc string, model interface{}) func(*openapi.OperationInfo)
- func ID(id string) func(*openapi.OperationInfo)
- func InputModel(model interface{}) func(*openapi.OperationInfo)
- func OperationFromContext(ctx context.Context) (*openapi.Operation, error)
- func Response(statusCode, desc string, model interface{}, headers []*openapi.ResponseHeader, ...) func(*openapi.OperationInfo)
- func ResponseWithExamples(statusCode, desc string, model interface{}, headers []*openapi.ResponseHeader, ...) func(*openapi.OperationInfo)
- func Security(security *openapi.SecurityRequirement) func(*openapi.OperationInfo)
- func StatusDescription(desc string) func(*openapi.OperationInfo)
- func Summary(summary string) func(*openapi.OperationInfo)
- func Summaryf(format string, a ...interface{}) func(*openapi.OperationInfo)
- func WithOptionalSecurity() func(*openapi.OperationInfo)
- func WithoutSecurity() func(*openapi.OperationInfo)
- func XCodeSample(cs *openapi.XCodeSample) func(*openapi.OperationInfo)
- func XInternal() func(*openapi.OperationInfo)
- type Fizz
- type OperationOption
- type RouterGroup
- func (g *RouterGroup) DELETE(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
- func (g *RouterGroup) GET(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
- func (g *RouterGroup) GinRouterGroup() *gin.RouterGroup
- func (g *RouterGroup) Group(path, name, description string, handlers ...gin.HandlerFunc) *RouterGroup
- func (g *RouterGroup) HEAD(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
- func (g *RouterGroup) Handle(path, method string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
- func (g *RouterGroup) OPTIONS(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
- func (g *RouterGroup) PATCH(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
- func (g *RouterGroup) POST(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
- func (g *RouterGroup) PUT(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
- func (g *RouterGroup) TRACE(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
- func (g *RouterGroup) Use(handlers ...gin.HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
var ( Integer int32 Long int64 Float float32 Double float64 String string Byte []byte Binary []byte Boolean bool DateTime time.Time )
Primitive type helpers.
Functions ¶
func Deprecated ¶
func Deprecated(deprecated bool) func(*openapi.OperationInfo)
Deprecated marks the operation as deprecated.
func Description ¶
func Description(desc string) func(*openapi.OperationInfo)
Description adds a description to an operation.
func Descriptionf ¶
func Descriptionf(format string, a ...interface{}) func(*openapi.OperationInfo)
Descriptionf adds a description to an operation according to a format specifier.
func Header ¶
func Header(name, desc string, model interface{}) func(*openapi.OperationInfo)
Header adds a header to the operation.
func InputModel ¶
func InputModel(model interface{}) func(*openapi.OperationInfo)
InputModel overrides the binding model of the operation.
func OperationFromContext ¶
OperationFromContext returns the OpenAPI operation from the given Gin context or an error if none is found.
func Response ¶
func Response(statusCode, desc string, model interface{}, headers []*openapi.ResponseHeader, example interface{}) func(*openapi.OperationInfo)
Response adds an additional response to the operation.
func ResponseWithExamples ¶ added in v0.15.0
func ResponseWithExamples(statusCode, desc string, model interface{}, headers []*openapi.ResponseHeader, examples map[string]interface{}) func(*openapi.OperationInfo)
ResponseWithExamples is a variant of Response that accept many examples.
func Security ¶ added in v0.18.0
func Security(security *openapi.SecurityRequirement) func(*openapi.OperationInfo)
Overrides top-level security requirement for this operation. Note that this function can be used more than once to add several requirements.
func StatusDescription ¶
func StatusDescription(desc string) func(*openapi.OperationInfo)
StatusDescription sets the default status description of the operation.
func Summary ¶
func Summary(summary string) func(*openapi.OperationInfo)
Summary adds a summary to an operation.
func Summaryf ¶
func Summaryf(format string, a ...interface{}) func(*openapi.OperationInfo)
Summaryf adds a summary to an operation according to a format specifier.
func WithOptionalSecurity ¶ added in v0.18.0
func WithOptionalSecurity() func(*openapi.OperationInfo)
Add an empty security requirement to this operation to make other security requirements optional.
func WithoutSecurity ¶ added in v0.18.0
func WithoutSecurity() func(*openapi.OperationInfo)
Remove any top-level security requirements for this operation.
func XCodeSample ¶ added in v0.16.0
func XCodeSample(cs *openapi.XCodeSample) func(*openapi.OperationInfo)
XCodeSample adds a code sample to the operation.
func XInternal ¶ added in v0.18.0
func XInternal() func(*openapi.OperationInfo)
XInternal marks the operation as internal.
Types ¶
type Fizz ¶
type Fizz struct { *RouterGroup // contains filtered or unexported fields }
Fizz is an abstraction of a Gin engine that wraps the routes handlers with Tonic and generates an OpenAPI 3.0 specification from it.
func NewFromEngine ¶
NewFromEngine creates a new Fizz wrapper from an existing Gin engine.
func (*Fizz) GinRouterGroup ¶ added in v0.22.0
func (f *Fizz) GinRouterGroup() *gin.RouterGroup
GinRouterGroup returns the underlying Gin router group.
type OperationOption ¶
type OperationOption func(*openapi.OperationInfo)
OperationOption represents an option-pattern function used to add informations to an operation.
type RouterGroup ¶
type RouterGroup struct { Name string Description string // contains filtered or unexported fields }
RouterGroup is an abstraction of a Gin router group.
func (*RouterGroup) DELETE ¶
func (g *RouterGroup) DELETE(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
DELETE is a shortcut to register a new handler with the DELETE method.
func (*RouterGroup) GET ¶
func (g *RouterGroup) GET(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
GET is a shortcut to register a new handler with the GET method.
func (*RouterGroup) GinRouterGroup ¶ added in v0.22.0
func (g *RouterGroup) GinRouterGroup() *gin.RouterGroup
GinRouterGroup returns the underlying Gin router group.
func (*RouterGroup) Group ¶
func (g *RouterGroup) Group(path, name, description string, handlers ...gin.HandlerFunc) *RouterGroup
Group creates a new group of routes.
func (*RouterGroup) HEAD ¶
func (g *RouterGroup) HEAD(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
HEAD is a shortcut to register a new handler with the HEAD method.
func (*RouterGroup) Handle ¶
func (g *RouterGroup) Handle(path, method string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
Handle registers a new request handler that is wrapped with Tonic and documented in the OpenAPI specification.
func (*RouterGroup) OPTIONS ¶
func (g *RouterGroup) OPTIONS(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
OPTIONS is a shortcut to register a new handler with the OPTIONS method.
func (*RouterGroup) PATCH ¶
func (g *RouterGroup) PATCH(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
PATCH is a shortcut to register a new handler with the PATCH method.
func (*RouterGroup) POST ¶
func (g *RouterGroup) POST(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
POST is a shortcut to register a new handler with the POST method.
func (*RouterGroup) PUT ¶
func (g *RouterGroup) PUT(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
PUT is a shortcut to register a new handler with the PUT method.
func (*RouterGroup) TRACE ¶
func (g *RouterGroup) TRACE(path string, infos []OperationOption, handlers ...gin.HandlerFunc) *RouterGroup
TRACE is a shortcut to register a new handler with the TRACE method.
func (*RouterGroup) Use ¶
func (g *RouterGroup) Use(handlers ...gin.HandlerFunc)
Use adds middleware to the group.