
How We Documented 95 API Endpoints with OpenAPI and Scalar
SendRec has grown to 95 API endpoints covering authentication, video management, playlists, folders, tags, billing, webhooks, and public watch pages. We needed documentation that stayed in sync with the code and didn't require a separate build step. Here's how we set it up. The approach: embedded YAML + Scalar We wanted three things: a single YAML file we could lint and test, interactive docs that render in the browser, and zero infrastructure beyond the Go binary itself. The solution is straightforward. The OpenAPI spec lives at internal/docs/openapi.yaml , and Go's //go:embed directive bakes it into the binary at compile time: package docs import ( _ "embed" "net/http" ) //go:embed openapi.yaml var specYAML [] byte func HandleSpec ( w http . ResponseWriter , r * http . Request ) { w . Header () . Set ( "Content-Type" , "application/yaml" ) _ , _ = w . Write ( specYAML ) } For the interactive UI, we serve a minimal HTML page that loads Scalar from a CDN: func HandleDocs ( w http . Res
Continue reading on Dev.to Webdev
Opens in a new tab

