Documentation
¶
Overview ¶
Package responses contains all the logic, models and interfaces for validating OpenAPI 3+ Responses The package depends on *http.Response
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateResponseHeaders ¶ added in v0.4.6
func ValidateResponseHeaders( request *http.Request, response *http.Response, headers *orderedmap.Map[string, *v3.Header], opts ...config.Option, ) (bool, []*errors.ValidationError)
ValidateResponseHeaders validates the response headers against the OpenAPI spec.
func ValidateResponseSchema ¶
func ValidateResponseSchema(input *ValidateResponseSchemaInput) (bool, []*errors.ValidationError)
ValidateResponseSchema will validate the response body for a http.Response pointer. The request is used to locate the operation in the specification, the response is used to ensure the response code, media type and the schema of the response body are valid.
This function is used by the ValidateResponseBody function, but can be used independently. The schema will be compiled from cache if available, otherwise it will be compiled and cached.
Types ¶
type ResponseBodyValidator ¶
type ResponseBodyValidator interface {
// ValidateResponseBody will validate the response body for a http.Response pointer. The request is used to
// locate the operation in the specification, the response is used to ensure the response code, media type and the
// schema of the response body are valid.
ValidateResponseBody(request *http.Request, response *http.Response) (bool, []*errors.ValidationError)
// ValidateResponseBodyWithPathItem will validate the response body for a http.Response pointer. The request is used to
// locate the operation in the specification, the response is used to ensure the response code, media type and the
// schema of the response body are valid.
ValidateResponseBodyWithPathItem(request *http.Request, response *http.Response, pathItem *v3.PathItem, pathFound string) (bool, []*errors.ValidationError)
}
ResponseBodyValidator is an interface that defines the methods for validating response bodies for Operations.
ValidateResponseBody method accepts an *http.Request and returns true if validation passed,
false if validation failed and a slice of ValidationError pointers.
func NewResponseBodyValidator ¶
func NewResponseBodyValidator(document *v3.Document, opts ...config.Option) ResponseBodyValidator
NewResponseBodyValidator will create a new ResponseBodyValidator from an OpenAPI 3+ document
type ValidateResponseSchemaInput ¶ added in v0.8.0
type ValidateResponseSchemaInput struct {
Request *http.Request // Required: The HTTP request (for context)
Response *http.Response // Required: The HTTP response 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)
}
ValidateResponseSchemaInput contains parameters for response schema validation.