X Tutup
Skip to content

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

Merged
mtojek merged 3 commits intomainfrom
fix/apidocgen-strict-mode
Feb 6, 2026
Merged

fix: enable strict mode for swagger generation & upgrade swag#21975
mtojek merged 3 commits intomainfrom
fix/apidocgen-strict-mode

Conversation

@mtojek
Copy link
Member

@mtojek mtojek commented Feb 6, 2026

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).

The upstream swag CLI (v1.16.2) does not expose a --strict flag, so
warnings about duplicate routes are silently ignored (exit code 0).
With Strict mode, duplicate @router declarations become hard errors
instead of silent overwrites.

This adds a Go wrapper (scripts/apidocgen/swaginit/main.go) that
calls the swag gen.Build() API directly with Strict: true, and
updates generate.sh to use it instead of 'go tool swag init'.
Notable improvements:
- Better generics support (map params, function-scoped types)
- More precise numeric format annotations (float64, int64)
- x-enum-descriptions for richer API docs
- json:omitempty marks fields as optional
- Security fix for CVE-2024-45338 (x/net)
- Swagger output now uses spaces instead of tabs
@mtojek mtojek changed the title fix(apidocgen): enable strict mode for swagger generation & upgrade swag fix: enable strict mode for swagger generation & upgrade swag Feb 6, 2026
@mtojek mtojek marked this pull request as ready for review February 6, 2026 10:44
@mtojek mtojek requested a review from johnstcn February 6, 2026 10:44
@mtojek mtojek merged commit 456c0bc into main Feb 6, 2026
36 checks passed
@mtojek mtojek deleted the fix/apidocgen-strict-mode branch February 6, 2026 12:04
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup