fix: enable strict mode for swagger generation & upgrade swag (#21975)

Adds a Go wrapper (`scripts/apidocgen/swaginit/main.go`) that calls
swag's Go API with `Strict: true`. The `--strict` flag isn't available
in swag's CLI in any version, so the wrapper is the only way to enable
it.

Also upgrades swag from v1.16.2 to v1.16.6 (better generics support,
precise numeric formats, `x-enum-descriptions`, CVE-2024-45338 fix).
This commit is contained in:
Marcin Tojek
2026-02-06 13:04:35 +01:00
committed by GitHub
parent 193e4bd73b
commit 456c0bced9
7 changed files with 97 additions and 25 deletions
+4 -6
View File
@@ -18,12 +18,10 @@ trap cleanup EXIT
log "Use temporary file: ${API_MD_TMP_FILE}"
pushd "${PROJECT_ROOT}"
go tool github.com/swaggo/swag/cmd/swag init \
--generalInfo="coderd.go" \
--dir="./coderd,./codersdk,./enterprise/coderd,./enterprise/wsproxy/wsproxysdk" \
--output="./coderd/apidoc" \
--outputTypes="go,json" \
--parseDependency=true
# Use our custom wrapper instead of "go tool swag init" to enable
# Strict mode, which turns duplicate-route warnings into hard errors.
# The upstream swag CLI does not expose a --strict flag.
go run "${APIDOCGEN_DIR}/swaginit/main.go"
popd
pushd "${APIDOCGEN_DIR}"