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

+10 -2
View File
@@ -1,4 +1,4 @@
.PHONY: build test lint fmt fmt-check vet tidy tidy-check vuln release-check snapshot check run
.PHONY: build test lint fmt fmt-check vet tidy tidy-check vuln openapi openapi-check release-check snapshot check run
# Without the leading v, as goreleaser's {{ .Version }} reports it.
VERSION ?= $(patsubst v%,%,$(shell git describe --tags --always --dirty 2>/dev/null || echo dev))
@@ -37,6 +37,14 @@ tidy-check:
vuln:
go tool govulncheck ./...
# Runs every go:generate directive, which writes docs/swagger.json.
openapi:
go generate ./...
# Fails when docs/swagger.json differs from what the route table produces.
openapi-check: openapi
git diff --exit-code -- docs/swagger.json
# Validates .goreleaser.yaml without building anything.
release-check:
goreleaser check
@@ -49,7 +57,7 @@ snapshot:
# The gate .gitea/workflows/test.yml runs, in the same order.
# .gitea/workflows/security.yml runs vuln.
check: fmt-check tidy-check vet lint test release-check
check: fmt-check tidy-check vet lint openapi-check test release-check
run:
go run ./cmd/uberbringer --config config.toml