浏览代码

fix: fix upload specify file format is fail (#1613)

CorrectRoadH 1 年之前
父节点
当前提交
29d16d13ba
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      route/v2.go

+ 6 - 0
route/v2.go

@@ -116,6 +116,12 @@ func InitV2Router() http.Handler {
 	// })
 	// })
 
 
 	e.Use(middleware.OapiRequestValidatorWithOptions(_swagger, &middleware.Options{
 	e.Use(middleware.OapiRequestValidatorWithOptions(_swagger, &middleware.Options{
+		Skipper: func(c echo.Context) bool {
+			// jump validate when upload file
+			// because file upload can't pass validate
+			// issue: https://github.com/deepmap/oapi-codegen/issues/514
+			return strings.Contains(c.Request().URL.Path, "file/upload")
+		},
 		Options: openapi3filter.Options{AuthenticationFunc: openapi3filter.NoopAuthenticationFunc},
 		Options: openapi3filter.Options{AuthenticationFunc: openapi3filter.NoopAuthenticationFunc},
 	}))
 	}))