Generate the OpenAPI document from a route table
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:
1 parent
9f7c5db923
commit
bdd337e2dc
31 files changed
+3153
-128
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user