requests

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 21 Imported by: 1

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

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

NewRequestBodyValidator will create a new RequestBodyValidator from an OpenAPI 3+ document

Jump to

Keyboard shortcuts

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