Documentation
¶
Overview ¶
Package requests contains all the logic, models and interfaces for validating OpenAPI 3+ Requests. The package depends on *http.Request
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateRequestSchema ¶
func ValidateRequestSchema(input *ValidateRequestSchemaInput) (bool, []*errors.ValidationError)
ValidateRequestSchema will validate a http.Request pointer against a schema. If validation fails, it will return a list of validation errors as the second return value. The schema will be stored and reused from cache if available, otherwise it will be compiled on each call.
Types ¶
type RequestBodyValidator ¶
type RequestBodyValidator interface {
// ValidateRequestBody will validate the request body for an operation. The first return value will be true if the
// request body is valid, false if it is not. The second return value will be a slice of ValidationError pointers if
// the body is not valid.
ValidateRequestBody(request *http.Request) (bool, []*errors.ValidationError)
// ValidateRequestBodyWithPathItem will validate the request body for an operation. The first return value will be true if the
// request body is valid, false if it is not. The second return value will be a slice of ValidationError pointers if
// the body is not valid.
ValidateRequestBodyWithPathItem(request *http.Request, pathItem *v3.PathItem, pathValue string) (bool, []*errors.ValidationError)
}
RequestBodyValidator is an interface that defines the methods for validating request bodies for Operations.
ValidateRequestBodyWithPathItem method accepts an *http.Request and returns true if validation passed,
false if validation failed and a slice of ValidationError pointers.
func NewRequestBodyValidator ¶
func NewRequestBodyValidator(document *v3.Document, opts ...config.Option) RequestBodyValidator
NewRequestBodyValidator will create a new RequestBodyValidator from an OpenAPI 3+ document
type ValidateRequestSchemaInput ¶ added in v0.8.0
type ValidateRequestSchemaInput struct {
Request *http.Request // Required: The HTTP request to validate
Schema *base.Schema // Required: The OpenAPI schema to validate against
Version float32 // Required: OpenAPI version (3.0 or 3.1)
Options []config.Option // Optional: Functional options (defaults applied if empty/nil)
}
ValidateRequestSchemaInput contains parameters for request schema validation.