Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidSchemaName = errors.New("invalid schema name")
)
Functions ¶
This section is empty.
Types ¶
type Policy ¶
type Policy string
Policy controls what the validator does when it encounters a condition it cannot fully validate (unknown route, method not allowed for a matched path, security scheme type the WAF cannot enforce).
type RequestValidator ¶
type RequestValidator struct {
// contains filtered or unexported fields
}
func NewRequestValidator ¶
func NewRequestValidator(logger *log.Entry) *RequestValidator
func (*RequestValidator) LoadSchema ¶
func (rv *RequestValidator) LoadSchema(ref string, schema string, opts *SchemaOptions) error
func (*RequestValidator) RegisterBodyDecoder ¶
func (rv *RequestValidator) RegisterBodyDecoder(contentType, decoderName string) error
RegisterBodyDecoder registers a decoder for the given Content-Type so that a loaded OpenAPI schema can declare and validate requests of that type. decoderName must be one of the built-in identifiers: "json", "urlencoded", "multipart", "yaml", "csv", "plain", "file". Note that this mutates kin-openapi's process-global decoder registry — see the note on NewRequestValidator.
func (*RequestValidator) ValidateRequest ¶
type SchemaData ¶
type SchemaData struct {
Schema *openapi3.T
Router routers.Router
Options SchemaOptions
}
type SchemaOptions ¶
type SchemaOptions struct {
OnRouteNotFound Policy
OnMethodNotAllowed Policy
OnUnsupportedSecurityScheme Policy
}
SchemaOptions configures per-schema validation behavior. A nil *SchemaOptions passed to LoadSchema means "use defaults" (all policies = drop, matching pre-option behavior).
type ValidationError ¶
type ValidationError struct {
Reason string
Field string
SchemaPath string
Message string
Value string
Expected string
OriginalError error
}
ValidationError provides detailed information about validation failures
func (*ValidationError) Error ¶
func (ve *ValidationError) Error() string