Documentation
¶
Overview ¶
Package apidoc provides an HTTP handler for serving OpenAPI documentation.
It exposes two routes:
- GET /openapi.yml — raw OpenAPI spec (always enabled)
- GET / — Scalar UI (opt-in via WithScalarUI)
Basic usage ¶
spec, _ := os.ReadFile("openapi.yml")
h, err := apidoc.New(
apidoc.WithSpec(spec),
apidoc.WithScalarUI(),
)
if err != nil {
log.Fatal(err)
}
// Mount under a prefix with chi:
r.Mount("/docs", h)
// Or with stdlib:
http.Handle("/docs/", http.StripPrefix("/docs", h))
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves OpenAPI documentation. It implements http.Handler and is intended to be mounted at a path prefix (e.g. chi's router.Mount or http.StripPrefix + http.Handle).
GET / → Scalar UI (requires [WithScalarUI]) GET /openapi.yml → raw YAML spec
Click to show internal directories.
Click to hide internal directories.