You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// MultiErrorHandler is called when oapi returns a MultiError type
26
+
// MultiErrorHandler is called when the OpenAPI filter returns an openapi3.MultiError (https://pkg.go.dev/github.com/getkin/kin-openapi/openapi3#MultiError)
// Options to customize request validation, openapi3filter specified options will be passed through.
29
+
// Options allows configuring the OapiRequestValidator.
30
30
typeOptionsstruct {
31
-
Options openapi3filter.Options
32
-
ErrorHandlerErrorHandler
31
+
// Options contains any configuration for the underlying `openapi3filter`
32
+
Options openapi3filter.Options
33
+
// ErrorHandler is called when a validation error occurs.
34
+
//
35
+
// If not provided, `http.Error` will be called
36
+
ErrorHandlerErrorHandler
37
+
// MultiErrorHandler is called when there is an openapi3.MultiError (https://pkg.go.dev/github.com/getkin/kin-openapi/openapi3#MultiError) returned by the `openapi3filter`.
38
+
//
39
+
// If not provided `defaultMultiErrorHandler` will be used.
33
40
MultiErrorHandlerMultiErrorHandler
34
41
// SilenceServersWarning allows silencing a warning for https://github.com/deepmap/oapi-codegen/issues/882 that reports when an OpenAPI spec has `spec.Servers != nil`
35
42
SilenceServersWarningbool
36
43
}
37
44
38
-
// OapiRequestValidator Creates middleware to validate request by OpenAPI spec.
45
+
// OapiRequestValidator Creates the middleware to validate that incoming requests match the given OpenAPI 3.x spec, with a default set of configuration.
// OapiRequestValidatorWithOptions Creates middleware to validate request by OpenAPI spec.
50
+
// OapiRequestValidatorWithOptions Creates the middleware to validate that incoming requests match the given OpenAPI 3.x spec, allowing explicit configuration.
51
+
//
52
+
// NOTE that this may panic if the OpenAPI spec isn't valid, or if it cannot be used to create the middleware
log.Println("WARN: OapiRequestValidatorWithOptions called with an OpenAPI spec that has `Servers` set. This may lead to an HTTP 400 with `no matching operation was found` when sending a valid request, as the validator performs `Host` header validation. If you're expecting `Host` header validation, you can silence this warning by setting `Options.SilenceServersWarning = true`. See https://github.com/deepmap/oapi-codegen/issues/882 for more information.")
0 commit comments