{"modulePath":"github.com/ascendsoftware/oapi-codegen","version":"v1.0.12","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package middleware\n\nPackage middleware implements middleware function for go-chi or net/http, which validates incoming HTTP requests to make sure that they conform to the given OAPI 3.0 specification. When OAPI validation fails on the request, we return an HTTP/400.\n\n## Functions\n\n```go\nfunc OapiRequestValidator(swagger *openapi3.T) func(next http.Handler) http.Handler\n```\nOapiRequestValidator Creates middleware to validate request by swagger spec. This middleware is good for net/http either since go-chi is 100% compatible with net/http.\n\n```go\nfunc OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) func(next http.Handler) http.Handler\n```\nOapiRequestValidatorWithOptions Creates middleware to validate request by swagger spec. This middleware is good for net/http either since go-chi is 100% compatible with net/http.\n\n## Types\n\n```go\ntype ErrorHandler func(w http.ResponseWriter, message string, statusCode int)\n```\nErrorHandler is called when there is an error in validation\n\n```go\ntype MultiErrorHandler func(openapi3.MultiError) (int, error)\n```\nMultiErrorHandler is called when oapi returns a MultiError type\n\n```go\ntype Options struct {\n\tOptions           openapi3filter.Options\n\tErrorHandler      ErrorHandler\n\tMultiErrorHandler MultiErrorHandler\n\t// SilenceServersWarning allows silencing a warning for https://github.com/ascendsoftware/oapi-codegen/issues/882 that reports when an OpenAPI spec has `spec.Servers != nil`\n\tSilenceServersWarning bool\n}\n```\nOptions to customize request validation, openapi3filter specified options will be passed through.\n\n","path":"github.com/ascendsoftware/oapi-codegen/pkg/chi-middleware","name":"middleware","synopsis":"Package middleware implements middleware function for go-chi or net/http, which validates incoming HTTP requests to make sure that they conform to the given OAPI 3.0 specification.","isRedistributable":true}
