From 81bc8b486a655f54cbdba47d41972560cd780644 Mon Sep 17 00:00:00 2001 From: caixw Date: Wed, 4 Dec 2024 11:56:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(openapi):=20Disable=20=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E9=98=BB=E6=AD=A2=20API=20=E7=9A=84=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openapi/middleware.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi/middleware.go b/openapi/middleware.go index 7e5cfb46..d744f383 100644 --- a/openapi/middleware.go +++ b/openapi/middleware.go @@ -362,7 +362,7 @@ func (o *Operation) Callback(name, path, method string, f func(*Operation)) *Ope // 两者稍有区别,前者不会对数据进行验证。 func (d *Document) API(f func(o *Operation)) web.Middleware { return web.MiddlewareFunc(func(next web.HandlerFunc, method, pattern, router string) web.HandlerFunc { - if !d.disable && pattern != "" && method != "" && + if pattern != "" && method != "" && (d.enableHead || method != http.MethodHead) && (d.enableOptions || method != http.MethodOptions) { o := &Operation{