optizz

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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(name, desc string, model interface{}) func(*openapi.OperationInfo)

Header adds a header to the operation.

func ID

func ID(id string) func(*openapi.OperationInfo)

ID overrides the operation ID.

func InputModel

func InputModel(model interface{}) func(*openapi.OperationInfo)

InputModel overrides the binding model of the operation.

func OperationFromContext

func OperationFromContext(c *fiber.Ctx) (*openapi.Operation, error)

OperationFromContext returns the OpenAPI operation from the given Fiber 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

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 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.

Types

type OperationOption

type OperationOption func(*openapi.OperationInfo)

OperationOption represents an option-pattern function used to add informations to an operation.

type Optizz

type Optizz struct {
	*RouterGroup
	// contains filtered or unexported fields
}

Fizz is an abstraction of a Fiber engine that wraps the routes handlers with Tonic and generates an OpenAPI 3.0 specification from it.

func New

func New() *Optizz

New creates a new Fizz wrapper for a default Fiber engine.

func NewFromEngine

func NewFromEngine(e *fiber.App) *Optizz

NewFromEngine creates a new Fizz wrapper from an existing Fiber engine.

func (*Optizz) Engine

func (f *Optizz) Engine() *fiber.App

Engine returns the underlying Fiber engine.

func (*Optizz) Errors

func (f *Optizz) Errors() []error

Errors returns the errors that may have occurred during the spec generation.

func (*Optizz) Generator

func (f *Optizz) Generator() *openapi.Generator

Generator returns the underlying OpenAPI generator.

func (*Optizz) OpenAPI

func (f *Optizz) OpenAPI(info *openapi.Info, ct string) fiber.Handler

OpenAPI returns a Fiber HandlerFunc that serves the marshalled OpenAPI specification of the API.

type RouterGroup

type RouterGroup struct {
	Name        string
	Description string
	// contains filtered or unexported fields
}

RouterGroup is an abstraction of a Fiber router group.

func (*RouterGroup) DELETE

func (g *RouterGroup) DELETE(path string, infos []OperationOption, handlers ...fiber.Handler) *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 ...fiber.Handler) *RouterGroup

GET is a shortcut to register a new handler with the GET method.

func (*RouterGroup) Group

func (g *RouterGroup) Group(path, name, description string, handlers ...fiber.Handler) *RouterGroup

Group creates a new group of routes.

func (*RouterGroup) HEAD

func (g *RouterGroup) HEAD(path string, infos []OperationOption, handlers ...fiber.Handler) *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 ...fiber.Handler) *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 ...fiber.Handler) *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 ...fiber.Handler) *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 ...fiber.Handler) *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 ...fiber.Handler) *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 ...fiber.Handler) *RouterGroup

TRACE is a shortcut to register a new handler with the TRACE method.

func (*RouterGroup) Use

func (g *RouterGroup) Use(handlers ...fiber.Handler)

Use adds middleware to the group.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL