Skip to content

Commit 5b7ff06

Browse files
gmtstephanejamietanna
authored andcommitted
fix warn log condition
1 parent 6ff8ccf commit 5b7ff06

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

oapi_validate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type Options struct {
7777

7878
// OapiRequestValidatorWithOptions creates a validator from a swagger object, with validation options
7979
func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) gin.HandlerFunc {
80-
if swagger.Servers != nil && (options == nil || options.SilenceServersWarning) {
80+
if swagger.Servers != nil && (options == nil || !options.SilenceServersWarning) {
8181
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.")
8282
}
8383

0 commit comments

Comments
 (0)