validate

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowsOperationMethod

func AllowsOperationMethod(version, method string) bool

func BodyRefHasInvalidSiblings

func BodyRefHasInvalidSiblings(body *openapi.RequestBody, version string) bool

func CallbackRefHasInvalidSiblings

func CallbackRefHasInvalidSiblings(callback *openapi.Callback, version string) bool

func ExampleRefHasInvalidSiblings

func ExampleRefHasInvalidSiblings(example *openapi.Example, version string) bool

func ExtraHas

func ExtraHas(extra map[string]any, keys ...string) bool

func HasInvalidReferenceExtra

func HasInvalidReferenceExtra(extra map[string]any, version string) bool

func HasNonExtensionExtra

func HasNonExtensionExtra(extra map[string]any) bool

func HasParameterRefSiblings

func HasParameterRefSiblings(param *openapi.Parameter, version string) bool

func HasSchemaRefSiblings

func HasSchemaRefSiblings(schema *openapi.Schema) bool

func HasSerializedExample

func HasSerializedExample(example *openapi.Example) bool

func HeaderRefHasInvalidSiblings

func HeaderRefHasInvalidSiblings(header *openapi.Header, version string) bool

func IsFixedMethod

func IsFixedMethod(method string) bool

func IsHTTPSURI

func IsHTTPSURI(value string) bool

func IsLocalReference

func IsLocalReference(ref string, resources map[string]any) bool

func IsNonRelativeURI

func IsNonRelativeURI(value string) bool

func IsNumber

func IsNumber(value any) bool

func IsOpenAPI31

func IsOpenAPI31(version string) bool

func IsOpenAPI32

func IsOpenAPI32(version string) bool

func IsServerURL

func IsServerURL(value string) bool

func IsURIReference

func IsURIReference(value string) bool

func IsValidParameterIn

func IsValidParameterIn(in string) bool

func LinkRefHasInvalidSiblings

func LinkRefHasInvalidSiblings(link *openapi.Link, version string) bool

func MarshalAny

func MarshalAny(value any) any

func MediaTypeAllowsNamedEncoding

func MediaTypeAllowsNamedEncoding(mediaType string) bool

func MediaTypeBase

func MediaTypeBase(mediaType string) string

func MediaTypeIsMultipart

func MediaTypeIsMultipart(mediaType string) bool

func MediaTypeRefHasInvalidSiblings

func MediaTypeRefHasInvalidSiblings(mediaType *openapi.MediaType, version string) bool

func NormalizeTemplatedPath

func NormalizeTemplatedPath(path string) string

func OperationsOf

func OperationsOf(item *openapi.PathItem) map[string]*openapi.Operation

func ReferenceTargetExists

func ReferenceTargetExists(ref string, resources map[string]any) bool

func RegisterSchemaAnchor

func RegisterSchemaAnchor(value reflect.Value, base, fieldName string, resources map[string]any)

func RegisterSchemaResource

func RegisterSchemaResource(value reflect.Value, base string, resources map[string]any)

func ResolveJSONPointer

func ResolveJSONPointer(root any, pointer string) any

func ResolveParameterRef

func ResolveParameterRef(ref string, componentParameters map[string]*openapi.Parameter) *openapi.Parameter

func ResolveParameterRefs

func ResolveParameterRefs(
	params []*openapi.Parameter,
	componentParameters map[string]*openapi.Parameter,
) []*openapi.Parameter

func ResolveURIReference

func ResolveURIReference(base, ref string) (string, bool)

func ResponseRefHasInvalidSiblings

func ResponseRefHasInvalidSiblings(response *openapi.Response, version string) bool

func SchemaBaseURI

func SchemaBaseURI(value reflect.Value, base string) string

func SchemaTypeIncludesArray

func SchemaTypeIncludesArray(schema *openapi.Schema) bool

func SecurityRequirementMayUseURI

func SecurityRequirementMayUseURI(name, version string) bool

func SecuritySchemeOAuth2MetadataURL

func SecuritySchemeOAuth2MetadataURL(scheme *openapi.SecurityScheme) (string, bool)

func SecuritySchemeRefHasInvalidSiblings

func SecuritySchemeRefHasInvalidSiblings(scheme *openapi.SecurityScheme, version string) bool

func ValidParameterStyle

func ValidParameterStyle(in, style, version string) bool

func ValidateAnySchema

func ValidateAnySchema(context string, value any, version string, visited map[*openapi.Schema]bool) []error

func ValidateCallback

func ValidateCallback(
	context string,
	callback *openapi.Callback,
	version string,
	operationIDs map[string]string,
	securitySchemes map[string]*openapi.SecurityScheme,
	componentParameters map[string]*openapi.Parameter,
) []error

func ValidateComponentKeys

func ValidateComponentKeys[T any](kind string, values map[string]T) []error

func ValidateComponents

func ValidateComponents(
	components *openapi.Components,
	version string,
	operationIDs map[string]string,
	securitySchemes map[string]*openapi.SecurityScheme,
	componentParameters map[string]*openapi.Parameter,
) []error

func ValidateDiscriminator

func ValidateDiscriminator(context string, schema *openapi.Schema, version string) []error

func ValidateDocument

func ValidateDocument(doc *openapi.Document, version string) []error

func ValidateEncoding

func ValidateEncoding(context, mediaTypeName string, encoding *openapi.Encoding, version string) []error

func ValidateExample

func ValidateExample(context string, example *openapi.Example, version string) []error

func ValidateExclusiveBoundaries

func ValidateExclusiveBoundaries(context string, schema *openapi.Schema, version string) []error

func ValidateHeader

func ValidateHeader(context string, header *openapi.Header, version string) []error

func ValidateInfo

func ValidateInfo(info openapi.Info, version string) []error
func ValidateLink(context string, link *openapi.Link, version string) []error

func ValidateMediaType

func ValidateMediaType(context, mediaTypeName string, mediaType *openapi.MediaType, version string) []error

func ValidateOAuthFlow

func ValidateOAuthFlow(
	context string,
	flow *openapi.OAuthFlow,
	version string,
	needsAuthorizationURL, needsTokenURL bool,
) []error

func ValidateOAuthFlows

func ValidateOAuthFlows(context string, flows *openapi.OAuthFlows, version string) []error

func ValidateOperation

func ValidateOperation(
	context string,
	op *openapi.Operation,
	version string,
	operationIDs map[string]string,
	securitySchemes map[string]*openapi.SecurityScheme,
	componentParameters map[string]*openapi.Parameter,
) []error

func ValidateParameterSerialization

func ValidateParameterSerialization(context string, param *openapi.Parameter, version string) []error

func ValidateParameters

func ValidateParameters(
	context string,
	params []*openapi.Parameter,
	version string,
	componentParameters map[string]*openapi.Parameter,
) []error

func ValidatePathItem

func ValidatePathItem(
	path string,
	item *openapi.PathItem,
	version string,
	operationIDs map[string]string,
	securitySchemes map[string]*openapi.SecurityScheme,
	componentParameters map[string]*openapi.Parameter,
) []error

func ValidatePathItemOperations

func ValidatePathItemOperations(
	context string,
	item *openapi.PathItem,
	version string,
	operationIDs map[string]string,
	securitySchemes map[string]*openapi.SecurityScheme,
	componentParameters map[string]*openapi.Parameter,
) []error

func ValidatePathParams

func ValidatePathParams(path, method string, params []*openapi.Parameter) []error

func ValidateQueryParameterMix

func ValidateQueryParameterMix(context string, params []*openapi.Parameter) []error

func ValidateReferenceTargets

func ValidateReferenceTargets(doc *openapi.Document) []error

func ValidateRequestBody

func ValidateRequestBody(context string, body *openapi.RequestBody, version string) []error

func ValidateResponse

func ValidateResponse(context string, response *openapi.Response, version string) []error

func ValidateSchema

func ValidateSchema(context string, schema *openapi.Schema, version string, visited map[*openapi.Schema]bool) []error

func ValidateSchema304Fields

func ValidateSchema304Fields(context string, schema *openapi.Schema) []error

func ValidateSecurityRequirements

func ValidateSecurityRequirements(
	context string,
	requirements []openapi.SecurityRequirement,
	schemes map[string]*openapi.SecurityScheme,
	version string,
) []error

func ValidateSecurityScheme

func ValidateSecurityScheme(context string, scheme *openapi.SecurityScheme, version string) []error

func ValidateServer

func ValidateServer(context string, server *openapi.Server, version string) []error

func ValidateServerNames

func ValidateServerNames(servers []openapi.Server, version string) []error

func ValidateTagParents

func ValidateTagParents(tags []openapi.Tag, tagByName map[string]int) []error

func ValidateTags

func ValidateTags(tags []openapi.Tag, version string) []error

func ValidateXML

func ValidateXML(context string, schema *openapi.Schema) []error

func WithoutFragment

func WithoutFragment(raw string) string

Types

type Error

type Error struct {
	Err      error
	Severity Severity
}

Error represents a validation error with an associated severity level.

func Errorf

func Errorf(format string, args ...any) *Error

Errorf creates a new validation error with SeverityError.

func Infof

func Infof(format string, args ...any) *Error

Infof creates a new validation error with SeverityInfo.

func Warningf

func Warningf(format string, args ...any) *Error

Warningf creates a new validation error with SeverityWarning.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap returns the underlying error.

type Severity

type Severity int

Severity represents the severity level of a validation error.

const (
	// SeverityError indicates a strict validation failure.
	SeverityError Severity = iota
	// SeverityWarning indicates a validation warning that doesn't necessarily invalidate the document.
	SeverityWarning
	// SeverityInfo indicates informational validation feedback.
	SeverityInfo
)

Jump to

Keyboard shortcuts

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