requestvalidation

package
v3.1.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package requestvalidation provides OpenAPI request validation for selected HTTP boundaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResponseValidation

type ResponseValidation struct {
	RequiredHeaderValues map[string]string
	ExpectedMediaType    string
	RequiredHeaders      []string
	ExcludeBody          bool
}

ResponseValidation configures response-contract checks around a real HTTP response.

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator validates HTTP requests against one loaded OpenAPI document.

func NewIDPValidator

func NewIDPValidator() (*Validator, error)

NewIDPValidator loads the IDP OpenAPI document.

func NewManagementValidator

func NewManagementValidator() (*Validator, error)

NewManagementValidator loads the management OpenAPI document.

func NewValidator

func NewValidator(name string, content []byte) (*Validator, error)

NewValidator loads and validates an OpenAPI document from content.

func (*Validator) OperationID

func (validator *Validator) OperationID(req *http.Request) (operationID string, matched bool, err error)

OperationID resolves the OpenAPI operation id for req. Requests that do not match the document return matched=false and a nil error.

func (*Validator) Validate

func (validator *Validator) Validate(req *http.Request) error

Validate checks req against the matching OpenAPI operation.

func (*Validator) ValidateHTTPResponse

func (validator *Validator) ValidateHTTPResponse(
	req *http.Request,
	response *http.Response,
	validation ResponseValidation,
) error

ValidateHTTPResponse validates response against the OpenAPI operation that matches req.

func (*Validator) ValidateResponse

func (validator *Validator) ValidateResponse(
	req *http.Request,
	statusCode int,
	header http.Header,
	body []byte,
	validation ResponseValidation,
) error

ValidateResponse validates response metadata and body bytes against the matching OpenAPI operation. The status code must be documented by the operation; body validation can be disabled for browser or header-only flows.

Jump to

Keyboard shortcuts

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