Generate the OpenAPI document from a route table
Security / Vulnerability check (push) Successful in 38s
Test / Lint and test (push) Successful in 1m53s

The server registers its routes from one table in server/routes.go, and
tools/genopenapi (run by go generate) writes docs/swagger.json, an
OpenAPI 3.1 document, from the same table and the Go types it names.
Schemas are reflected with invopop/jsonschema: descriptions from the
first paragraph of the doc comments, enums and limits from jsonschema
tags. Request schemas are strict, as the decoder is; response schemas
allow fields added later. The daemon serves the embedded document at
GET /openapi.json without a token, internal/app passes it to the server
in its config, and release archives and the Docker build include it.

Tests keep it honest: a golden test and a CI step fail when the
document is stale, every registered route must be in the table, and the
tags are held to validation, to the Go constants and to the values the
handlers send. receipt.Element and printqueue.Status gain field doc
comments for the descriptions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-11-30 09:30:42 -06:00
1 parent 9f7c5db923
commit bdd337e2dc
31 files changed
+3153 -128

No files matched your search

+5
View File
@@ -7,6 +7,7 @@ require (
github.com/go-viper/mapstructure/v2 v2.5.0
github.com/gofiber/fiber/v3 v3.7.0
github.com/golang-jwt/jwt/v5 v5.3.1
github.com/invopop/jsonschema v0.14.0
github.com/liamg/tml v0.7.1
github.com/pelletier/go-toml/v2 v2.4.3
github.com/spf13/cobra v1.10.2
@@ -19,6 +20,8 @@ require (
require (
github.com/BurntSushi/toml v1.6.0 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/buger/jsonparser v1.6.1 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/gofiber/schema v1.10.2 // indirect
github.com/gofiber/utils/v2 v2.6.5 // indirect
@@ -29,6 +32,8 @@ require (
github.com/mattn/go-colorable v0.1.16 // indirect
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/molecule-man/go-brrr v1.3.1 // indirect
github.com/pb33f/go-yaml v0.2.0 // indirect
github.com/pb33f/ordered-map/v2 v2.3.2 // indirect
github.com/philhofer/fwd v1.2.1 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect