chore: upgrade go-swagger to v0.35.0 and enforce zero swagger warnings (#38299)

Updates `go-swagger` to v0.35.0 and makes swagger generation and
validation warning-free, with the build now failing on any warning
(`go-swagger` itself exits `0` on warnings).

- Generation passes `--enable-allof-compounding` (keeps `$ref` fields
bare, no spec change) and `--skip-enum-desc` (drops the enum description
that duplicates `x-go-enum-desc` and was the only source of `allOf`
noise in the OpenAPI 3.0 output).
- Fixed warnings at the source: dropped `swagger:strfmt` where it
conflicts with `required: true` (`required` kept, `time.Time` still maps
to `date-time`), fixed a malformed `units_map` example, moved the
`parameterBodies` injection hack to `swagger:parameters`, and removed
unused responses.

Fixes: https://github.com/go-gitea/gitea/issues/12508

---------

Co-authored-by: bircni <bircni@icloud.com>
This commit is contained in:
silverwind
2026-07-01 23:07:34 +02:00
committed by GitHub
parent a031454586
commit 638e4bce09
12 changed files with 187 additions and 499 deletions
-7
View File
@@ -12,13 +12,6 @@ type swaggerResponseSecretList struct {
Body []api.Secret `json:"body"`
}
// Secret
// swagger:response Secret
type swaggerResponseSecret struct {
// in:body
Body api.Secret `json:"body"`
}
// ActionVariable
// swagger:response ActionVariable
type swaggerResponseActionVariable struct {
-7
View File
@@ -98,13 +98,6 @@ type swaggerIssueTemplates struct {
Body []api.IssueTemplate `json:"body"`
}
// StopWatch
// swagger:response StopWatch
type swaggerResponseStopWatch struct {
// in:body
Body api.StopWatch `json:"body"`
}
// StopWatchList
// swagger:response StopWatchList
type swaggerResponseStopWatchList struct {
-15
View File
@@ -1,15 +0,0 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package swagger
import (
api "gitea.dev/modules/structs"
)
// NodeInfo
// swagger:response NodeInfo
type swaggerResponseNodeInfo struct {
// in:body
Body api.NodeInfo `json:"body"`
}
+8 -4
View File
@@ -8,11 +8,12 @@ import (
"gitea.dev/services/forms"
)
// not actually a response, just a hack to get go-swagger to include definitions
// of the various XYZOption structs
// not actually a set of parameters, just a hack to get go-swagger to include
// definitions of the various XYZOption structs. The annotation below uses an
// operation id that matches no route, so the spec carries no unused response
// or parameter for it while still emitting the referenced definitions.
// parameterBodies
// swagger:response parameterBodies
// swagger:parameters parameterBodies
type swaggerParameterBodies struct {
// in:body
AddCollaboratorOption api.AddCollaboratorOption
@@ -235,4 +236,7 @@ type swaggerParameterBodies struct {
// in:body
LockIssueOption api.LockIssueOption
// in:body
MergeUpstreamRequest api.MergeUpstreamRequest
}
-13
View File
@@ -84,13 +84,6 @@ type swaggerResponseTagProtection struct {
Body api.TagProtection `json:"body"`
}
// Reference
// swagger:response Reference
type swaggerResponseReference struct {
// in:body
Body api.Reference `json:"body"`
}
// ReferenceList
// swagger:response ReferenceList
type swaggerResponseReferenceList struct {
@@ -511,12 +504,6 @@ type swaggerCompare struct {
Body api.Compare `json:"body"`
}
// swagger:response MergeUpstreamRequest
type swaggerMergeUpstreamRequest struct {
// in:body
Body api.MergeUpstreamRequest `json:"body"`
}
// swagger:response MergeUpstreamResponse
type swaggerMergeUpstreamResponse struct {
// in:body