Documentation
¶
Index ¶
- func GenerateExample(t interface{}) interface{}
- func GetTypeName(t interface{}) string
- func SwaggerUI(spec *OpenAPISpec) fiber.Handler
- type Components
- type Contact
- type Generator
- type Header
- type Info
- type License
- type MediaType
- type OpenAPISpec
- type Operation
- type Parameter
- type PathItem
- type RequestBody
- type Response
- type RouteDecorator
- type RouteInfo
- type Server
- type SwaggerMiddleware
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateExample ¶
func GenerateExample(t interface{}) interface{}
GenerateExample generates an example from a struct
func GetTypeName ¶
func GetTypeName(t interface{}) string
GetTypeName gets the type name for a Go type
Types ¶
type Components ¶
type Components struct {
Schemas map[string]interface{} `json:"schemas,omitempty"`
}
Components holds reusable components
type Contact ¶
type Contact struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
Contact information
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates OpenAPI specifications
func NewGenerator ¶
NewGenerator creates a new Swagger generator
func (*Generator) Generate ¶
func (g *Generator) Generate() (*OpenAPISpec, error)
Generate generates the OpenAPI specification
func (*Generator) GenerateJSON ¶
GenerateJSON generates the OpenAPI specification as JSON
type Header ¶
type Header struct {
Description string `json:"description,omitempty"`
Schema interface{} `json:"schema,omitempty"`
}
Header represents a header
type Info ¶
type Info struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Version string `json:"version"`
Contact *Contact `json:"contact,omitempty"`
License *License `json:"license,omitempty"`
}
Info contains metadata about the API
type MediaType ¶
type MediaType struct {
Schema interface{} `json:"schema,omitempty"`
}
MediaType represents a media type
type OpenAPISpec ¶
type OpenAPISpec struct {
OpenAPI string `json:"openapi"`
Info Info `json:"info"`
Servers []Server `json:"servers,omitempty"`
Paths map[string]PathItem `json:"paths"`
Components Components `json:"components,omitempty"`
Tags []Tag `json:"tags,omitempty"`
}
OpenAPISpec represents the OpenAPI 3.0 specification
type Operation ¶
type Operation struct {
Tags []string `json:"tags,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
OperationID string `json:"operationId,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty"`
Responses map[string]Response `json:"responses"`
Security []map[string][]string `json:"security,omitempty"`
}
Operation represents an API operation
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
In string `json:"in"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Schema interface{} `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
}
Parameter represents a parameter
func HeaderParameter ¶
HeaderParameter creates a header parameter
func PathParameter ¶
PathParameter creates a path parameter
func QueryParameter ¶
QueryParameter creates a query parameter
type PathItem ¶
type PathItem struct {
Get *Operation `json:"get,omitempty"`
Post *Operation `json:"post,omitempty"`
Put *Operation `json:"put,omitempty"`
Delete *Operation `json:"delete,omitempty"`
Patch *Operation `json:"patch,omitempty"`
}
PathItem represents a path in the API
type RequestBody ¶
type RequestBody struct {
Description string `json:"description,omitempty"`
Content map[string]MediaType `json:"content"`
Required bool `json:"required,omitempty"`
}
RequestBody represents a request body
type Response ¶
type Response struct {
Description string `json:"description"`
Content map[string]MediaType `json:"content,omitempty"`
Headers map[string]Header `json:"headers,omitempty"`
}
Response represents a response
type RouteDecorator ¶
RouteDecorator is a function type for decorating routes
func WithDescription ¶
func WithDescription(description string) RouteDecorator
WithDescription decorates a route with a description
func WithParameters ¶
func WithParameters(parameters ...Parameter) RouteDecorator
WithParameters decorates a route with parameters
func WithSummary ¶
func WithSummary(summary string) RouteDecorator
WithSummary decorates a route with a summary
func WithValidation ¶
func WithValidation(requestType, responseType interface{}) RouteDecorator
WithValidation decorates a route with validation information
type RouteInfo ¶
type RouteInfo struct {
Method string
Path string
Handler string
Summary string
Description string
Tags []string
RequestType interface{}
ResponseType interface{}
Parameters []Parameter
}
RouteInfo holds information about a route
type SwaggerMiddleware ¶
type SwaggerMiddleware struct {
// contains filtered or unexported fields
}
SwaggerMiddleware handles automatic Swagger generation
func NewSwaggerMiddleware ¶
func NewSwaggerMiddleware(generator *Generator, enabled bool) *SwaggerMiddleware
NewSwaggerMiddleware creates a new Swagger middleware
func (*SwaggerMiddleware) AutoRegister ¶
func (sm *SwaggerMiddleware) AutoRegister(app *fiber.App)
AutoRegister automatically registers routes from Fiber app
func (*SwaggerMiddleware) RegisterGroup ¶
func (sm *SwaggerMiddleware) RegisterGroup(prefix string, routes []RouteInfo)
RegisterGroup registers a group of routes
func (*SwaggerMiddleware) RegisterRoute ¶
func (sm *SwaggerMiddleware) RegisterRoute(method, path string, decorators ...RouteDecorator)
RegisterRoute manually registers a route
func (*SwaggerMiddleware) RegisterRoutes ¶
func (sm *SwaggerMiddleware) RegisterRoutes(app *fiber.App)
RegisterRoutes registers routes with Swagger