validate

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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