docs

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package docs serves grain's OpenAPI specification.

The spec is generated at build time by `swag init` (see the root Makefile's `generate` target) from doc comments scattered across the HTTP handlers, then embedded into the binary via //go:embed in main.go. This package is the runtime side of that pipeline: it holds the spec bytes and serves them.

The HTML shell that consumes the spec — grain's restyled Swagger UI — lives in www/views/api-docs.html and is rendered through the standard template engine from client/registerEndpoints.go. The swagger-ui-dist JS/CSS bundle is downloaded into www/static/swagger at build time (see tests/docker/Dockerfile and the assets job in .github/workflows/release.yml). Keeping the runtime here narrow means swap-out is just an HTML rewrite, no Go changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeSpec

func ServeSpec(w http.ResponseWriter, r *http.Request)

ServeSpec writes the embedded OpenAPI JSON. Mounted at /api/docs/openapi.json so the Swagger UI can fetch it same-origin (no CORS dance for the dashboard).

func SetSpec

func SetSpec(b []byte)

SetSpec installs the embedded OpenAPI JSON. Called once during startup; not safe for concurrent use, which matches the existing SetEmbeddedWWW pattern in client/embed.go.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL