Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Registry = &APIRegistry{ Routes: make(map[string]*RouteDoc), }
Global Registry
Functions ¶
func SwaggerUIHandler ¶
func SwaggerUIHandler(swaggerJSONURL string) http.HandlerFunc
SwaggerUIHandler returns an http.HandlerFunc that serves Swagger UI HTML, configured to fetch the OpenAPI JSON specification from the given URL.
Types ¶
type APIRegistry ¶
type APIRegistry struct {
Routes map[string]*RouteDoc
Title string
Desc string
// contains filtered or unexported fields
}
func (*APIRegistry) GenerateOpenAPI ¶
func (r *APIRegistry) GenerateOpenAPI() map[string]interface{}
GenerateOpenAPI returns the full OpenAPI 3.0 JSON structure
func (*APIRegistry) GetRoutes ¶
func (r *APIRegistry) GetRoutes() []*RouteDoc
GetRoutes returns a thread-safe slice of all registered routes
func (*APIRegistry) Register ¶
func (r *APIRegistry) Register(method, path string, doc *RouteDoc)
func (*APIRegistry) ToJSON ¶
func (r *APIRegistry) ToJSON() ([]byte, error)
ToJSON returns the JSON bytes of the OpenAPI spec
type MediaTypeDoc ¶
type MediaTypeDoc struct {
Schema SchemaDoc `json:"schema"`
}
type RequestBodyDoc ¶
type RequestBodyDoc struct {
Content map[string]MediaTypeDoc `json:"content"`
}
type ResponseDoc ¶
type ResponseDoc struct {
Description string `json:"description"`
}
type RouteDoc ¶
type RouteDoc struct {
Method string `json:"method"`
Path string `json:"path"`
Summary string `json:"summary"`
Description string `json:"description"`
Tags []string `json:"tags"`
Params []ParamDoc `json:"parameters,omitempty"`
RequestBody *RequestBodyDoc `json:"requestBody,omitempty"`
Responses map[string]ResponseDoc `json:"responses"`
}
Click to show internal directories.
Click to hide internal directories.