Documentation
¶
Index ¶
- func ExampleBothSpecs(db *gorm.DB)
- func ExampleCustomization()
- func ExampleResolveSpec(db *gorm.DB)
- func ExampleRestheadSpec(db *gorm.DB)
- func ExampleWithFuncSpec()
- func ExampleWithUIHandler(db *gorm.DB)
- func SetupUIRoute(router *mux.Router, path string, config UIConfig)
- func UIHandler(config UIConfig) http.HandlerFunc
- type Components
- type Contact
- type FuncSpecEndpoint
- type Generator
- type GeneratorConfig
- type Info
- type MediaType
- type OpenAPISpec
- type Operation
- type Parameter
- type PathItem
- type RequestBody
- type Response
- type Schema
- type SecurityScheme
- type Server
- type UIConfig
- type UIType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExampleBothSpecs ¶
ExampleBothSpecs shows how to combine both RestheadSpec and ResolveSpec
func ExampleCustomization ¶
func ExampleCustomization()
ExampleCustomization shows advanced customization options
func ExampleResolveSpec ¶
ExampleResolveSpec shows how to configure OpenAPI generation for ResolveSpec
func ExampleRestheadSpec ¶
ExampleRestheadSpec shows how to configure OpenAPI generation for RestheadSpec
func ExampleWithFuncSpec ¶
func ExampleWithFuncSpec()
ExampleWithFuncSpec shows how to add FuncSpec endpoints to OpenAPI
func ExampleWithUIHandler ¶ added in v0.0.120
ExampleWithUIHandler shows how to serve OpenAPI documentation with a web UI
func SetupUIRoute ¶ added in v0.0.120
SetupUIRoute adds the OpenAPI UI route to a mux router This is a convenience function for the most common use case
func UIHandler ¶ added in v0.0.120
func UIHandler(config UIConfig) http.HandlerFunc
UIHandler creates an HTTP handler that serves an OpenAPI UI
Types ¶
type Components ¶
type Components struct {
Schemas map[string]Schema `json:"schemas,omitempty"`
SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"`
}
type FuncSpecEndpoint ¶
type FuncSpecEndpoint struct {
Path string
Method string
Summary string
Description string
SQLQuery string
Parameters []string // Parameter names extracted from SQL
}
FuncSpecEndpoint represents a FuncSpec endpoint for OpenAPI generation
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator creates OpenAPI specifications
func NewGenerator ¶
func NewGenerator(config GeneratorConfig) *Generator
NewGenerator creates a new OpenAPI generator
func (*Generator) Generate ¶
func (g *Generator) Generate() (*OpenAPISpec, error)
Generate creates the complete OpenAPI specification
func (*Generator) GenerateJSON ¶
GenerateJSON generates OpenAPI spec as JSON string
type GeneratorConfig ¶
type GeneratorConfig struct {
Title string
Description string
Version string
BaseURL string
Registry *modelregistry.DefaultModelRegistry
IncludeRestheadSpec bool
IncludeResolveSpec bool
IncludeFuncSpec bool
FuncSpecEndpoints map[string]FuncSpecEndpoint // path -> endpoint info
}
GeneratorConfig holds configuration for OpenAPI spec generation
type MediaType ¶
type MediaType struct {
Schema *Schema `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
}
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"`
Security []map[string][]string `json:"security,omitempty"`
}
OpenAPISpec represents the OpenAPI 3.0 specification structure
type Operation ¶
type Operation struct {
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
OperationID string `json:"operationId,omitempty"`
Tags []string `json:"tags,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty"`
Responses map[string]Response `json:"responses"`
Security []map[string][]string `json:"security,omitempty"`
}
type RequestBody ¶
type Schema ¶
type Schema struct {
Type string `json:"type,omitempty"`
Format string `json:"format,omitempty"`
Description string `json:"description,omitempty"`
Properties map[string]*Schema `json:"properties,omitempty"`
Items *Schema `json:"items,omitempty"`
Required []string `json:"required,omitempty"`
Ref string `json:"$ref,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Example interface{} `json:"example,omitempty"`
AdditionalProperties interface{} `json:"additionalProperties,omitempty"`
OneOf []*Schema `json:"oneOf,omitempty"`
AnyOf []*Schema `json:"anyOf,omitempty"`
}
type SecurityScheme ¶
type SecurityScheme struct {
Type string `json:"type"` // "apiKey", "http", "oauth2", "openIdConnect"
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"` // For apiKey
In string `json:"in,omitempty"` // For apiKey: "query", "header", "cookie"
Scheme string `json:"scheme,omitempty"` // For http: "basic", "bearer"
BearerFormat string `json:"bearerFormat,omitempty"` // For http bearer
}
type UIConfig ¶ added in v0.0.120
type UIConfig struct {
// UIType specifies which UI framework to use (default: SwaggerUI)
UIType UIType
// SpecURL is the URL to the OpenAPI spec JSON (default: "/openapi")
SpecURL string
// Title is the page title (default: "API Documentation")
Title string
// FaviconURL is the URL to the favicon (optional)
FaviconURL string
// CustomCSS allows injecting custom CSS (optional)
CustomCSS string
// Theme for the UI (light/dark, depends on UI type)
Theme string
}
UIConfig holds configuration for the OpenAPI UI handler