Documentation
¶
Overview ¶
Package validate provides OpenAPI specification validation using libopenapi.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMajorMinorVersion ¶
GetMajorMinorVersion extracts the major.minor portion of a version string.
func IsValidVersion ¶
IsValidVersion checks if the given version string is a valid OpenAPI version.
Types ¶
type ValidationError ¶
type ValidationError struct {
Message string
Line int
Column int
Path string
RuleID string
Severity string // "error" or "warning"
}
ValidationError represents a single validation error or warning.
func (ValidationError) Error ¶
func (e ValidationError) Error() string
Error implements the error interface.
type ValidationResult ¶
type ValidationResult struct {
Valid bool
Version string
Errors []ValidationError
Warnings []ValidationError
}
ValidationResult contains the results of validating an OpenAPI spec.
func ParseAndValidate ¶
func ParseAndValidate(specBytes []byte) (*libopenapi.Document, *ValidationResult, error)
ParseAndValidate parses an OpenAPI spec and returns the libopenapi document along with validation results. This is useful when you need both the parsed document for further processing and validation results.
func Validate ¶
func Validate(specBytes []byte) (*ValidationResult, error)
Validate validates an OpenAPI specification from YAML or JSON bytes. It uses libopenapi to parse and validate the spec.
func ValidateFile ¶
func ValidateFile(path string) (*ValidationResult, error)
ValidateFile validates an OpenAPI specification from a file path.