validate

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package validate provides OpenAPI specification validation using libopenapi.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMajorMinorVersion

func GetMajorMinorVersion(version string) string

GetMajorMinorVersion extracts the major.minor portion of a version string.

func IsValidVersion

func IsValidVersion(version string) bool

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.

Jump to

Keyboard shortcuts

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