{"modulePath":"github.com/ascendsoftware/oapi-codegen","version":"v1.0.12","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package middleware\n\n## Constants\n\n```go\nconst (\n\tGinContextKey = \"oapi-codegen/gin-context\"\n\tUserDataKey   = \"oapi-codegen/user-data\"\n)\n```\n\n## Functions\n\n```go\nfunc GetGinContext(c context.Context) *gin.Context\n```\nGetGinContext gets the echo context from within requests. It returns nil if not found or wrong type.\n\n```go\nfunc GetUserData(c context.Context) interface{}\n```\n\n```go\nfunc OapiRequestValidator(swagger *openapi3.T) gin.HandlerFunc\n```\nOapiRequestValidator is an gin middleware function 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 with error message\n\n```go\nfunc OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) gin.HandlerFunc\n```\nOapiRequestValidatorWithOptions creates a validator from a swagger object, with validation options\n\n```go\nfunc OapiValidatorFromYamlFile(path string) (gin.HandlerFunc, error)\n```\nOapiValidatorFromYamlFile creates a validator middleware from a YAML file path\n\n```go\nfunc ValidateRequestFromContext(c *gin.Context, router routers.Router, options *Options) error\n```\nValidateRequestFromContext is called from the middleware above and actually does the work of validating a request.\n\n## Types\n\n```go\ntype ErrorHandler func(c *gin.Context, message string, statusCode int)\n```\nErrorHandler is called when there is an error in validation\n\n```go\ntype MultiErrorHandler func(openapi3.MultiError) error\n```\nMultiErrorHandler is called when oapi returns a MultiError type\n\n```go\ntype Options struct {\n\tErrorHandler      ErrorHandler\n\tOptions           openapi3filter.Options\n\tParamDecoder      openapi3filter.ContentParameterDecoder\n\tUserData          interface{}\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. These are passed through to openapi3filter.\n\n","path":"github.com/ascendsoftware/oapi-codegen/pkg/gin-middleware","name":"middleware","synopsis":"","isRedistributable":true}
