chore: stabilize lint and verify builds

This commit is contained in:
2026-02-06 11:51:32 +08:00
parent edede17880
commit 1782f64417
114 changed files with 3032 additions and 1345 deletions

View File

@@ -44,7 +44,7 @@ type Config struct {
// Controls the display of operationId in operations list.
// default: false
DisplayOperationId bool `json:"displayOperationId,omitempty"`
DisplayOperationID bool `json:"displayOperationId,omitempty"`
// The default expansion depth for models (set to -1 completely hide the models).
// default: 1
@@ -109,7 +109,7 @@ type Config struct {
// OAuth redirect URL.
// default: ""
OAuth2RedirectUrl string `json:"oauth2RedirectUrl,omitempty"`
OAuth2RedirectURL string `json:"oauth2RedirectUrl,omitempty"`
// MUST be a function. Function to intercept remote definition, "Try it out", and OAuth 2.0 requests.
// Accepts one argument requestInterceptor(request) and must return the modified request, or a Promise that resolves to the modified request.
@@ -141,7 +141,7 @@ type Config struct {
// For example for locally deployed validators (https://github.com/swagger-api/validator-badge).
// Setting it to either none, 127.0.0.1 or localhost will disable validation.
// default: ""
ValidatorUrl string `json:"validatorUrl,omitempty"`
ValidatorURL string `json:"validatorUrl,omitempty"`
// If set to true, enables passing credentials, as defined in the Fetch standard, in CORS requests that are sent by the browser.
// Note that Swagger UI cannot currently set cookies cross-domain (see https://github.com/swagger-api/swagger-js/issues/1163).
@@ -174,7 +174,7 @@ type Config struct {
// Programmatically set values for an API key or Bearer authorization scheme.
// In case of OpenAPI 3.0 Bearer scheme, apiKeyValue must contain just the token itself without the Bearer prefix.
// default: ""
PreauthorizeApiKey template.JS `json:"-"`
PreauthorizeAPIKey template.JS `json:"-"`
// Applies custom CSS styles.
// default: ""
@@ -194,6 +194,7 @@ func (fc FilterConfig) Value() interface{} {
if fc.Expression != "" {
return fc.Expression
}
return fc.Enabled
}
@@ -211,13 +212,14 @@ func (shc SyntaxHighlightConfig) Value() interface{} {
if shc.Activate {
return shc
}
return false
}
type OAuthConfig struct {
// ID of the client sent to the OAuth2 provider.
// default: ""
ClientId string `json:"clientId,omitempty"`
ClientID string `json:"clientId,omitempty"`
// Never use this parameter in your production environment.
// It exposes cruicial security information. This feature is intended for dev/test environments only.

View File

@@ -35,13 +35,13 @@ func New(config ...Config) fiber.Handler {
once sync.Once
)
return func(c fiber.Ctx) error {
return func(ctx fiber.Ctx) error {
// Set prefix
once.Do(
func() {
prefix = strings.ReplaceAll(c.Route().Path, "*", "")
prefix = strings.ReplaceAll(ctx.Route().Path, "*", "")
forwardedPrefix := getForwardedPrefix(c)
forwardedPrefix := getForwardedPrefix(ctx)
if forwardedPrefix != "" {
prefix = forwardedPrefix + prefix
}
@@ -53,26 +53,28 @@ func New(config ...Config) fiber.Handler {
},
)
p := c.Path(utils.CopyString(c.Params("*")))
p := ctx.Path(utils.CopyString(ctx.Params("*")))
switch p {
case defaultIndex:
c.Type("html")
return index.Execute(c, cfg)
ctx.Type("html")
return index.Execute(ctx, cfg)
case defaultDocURL:
var doc string
if doc, err = swag.ReadDoc(cfg.InstanceName); err != nil {
return err
return fmt.Errorf("read swagger doc: %w", err)
}
return c.Type("json").SendString(doc)
return ctx.Type("json").SendString(doc)
case "", "/":
return c.Redirect().To(path.Join(prefix, defaultIndex))
return ctx.Redirect().To(path.Join(prefix, defaultIndex))
default:
// return fs(c)
return static.New("/swagger", static.Config{
FS: swaggerFiles.FS,
Browse: true,
})(c)
})(ctx)
}
}
}

View File

@@ -95,8 +95,8 @@ const indexTmpl string = `
{{if .PreauthorizeBasic}}
ui.preauthorizeBasic({{.PreauthorizeBasic}});
{{end}}
{{if .PreauthorizeApiKey}}
ui.preauthorizeApiKey({{.PreauthorizeApiKey}});
{{if .PreauthorizeAPIKey}}
ui.preauthorizeApiKey({{.PreauthorizeAPIKey}});
{{end}}
window.ui = ui