Documentation
¶
Overview ¶
Package swagger provides an HTTP handler to serve Swagger UI with embedded OpenAPI specs.
Index ¶
- type Config
- type Handler
- func (h *Handler) Routes(mux *http.ServeMux)
- func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServeResources(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServeSpec(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServeUI(w http.ResponseWriter, r *http.Request)
- type Resource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// BasePath is the URL path prefix where Swagger UI is served (e.g., "/swagger")
BasePath string
// SpecPath is the URL path to serve the OpenAPI spec (e.g., "/openapi/specs")
SpecPath string
// ResourcesPath is the URL path to serve the resources list (e.g., "/openapi/resources")
ResourcesPath string
// Specs is a map of spec name to spec content (YAML or JSON bytes)
Specs map[string][]byte
// DefaultSpec is the name of the default spec to serve when no query param is provided
DefaultSpec string
}
Config holds the configuration for the Swagger UI handler.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves Swagger UI and OpenAPI specifications.
func New ¶
New creates a new Swagger UI handler with the given configuration. swaggerUIZip should be the bytes of the swagger-ui.zip file.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
func (*Handler) ServeResources ¶
func (h *Handler) ServeResources(w http.ResponseWriter, r *http.Request)
ServeResources serves the resources list. Use with chi: router.Get("/openapi/resources", h.ServeResources)
Click to show internal directories.
Click to hide internal directories.