responses

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 22 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)

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