responses

package
v0.0.51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 20 Imported by: 1

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 ValidateResponseSchema

func ValidateResponseSchema(
	request *http.Request,
	response *http.Response,
	schema *base.Schema,
	renderedSchema,
	jsonSchema []byte) (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.

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)

	// SetPathItem will set the pathItem for the ResponseBodyValidator, all validations will be performed
	// against this pathItem otherwise if not set, each validation will perform a lookup for the
	// pathItem based on the *http.Request
	SetPathItem(path *v3.PathItem, pathValue string)
}

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) ResponseBodyValidator

NewResponseBodyValidator will create a new ResponseBodyValidator from an OpenAPI 3+ document

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL