schema

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Endpoint   string
	StatusCode int
	Violations []Violation
}

Result holds all violations from validating a response against a spec.

func (*Result) Format

func (r *Result) Format(color bool) string

Format produces a readable validation report.

func (*Result) HasErrors

func (r *Result) HasErrors() bool

HasErrors returns true if any violation is an error (not just warning).

type Spec

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

Spec holds a parsed OpenAPI 3.0 specification.

func LoadSpec

func LoadSpec(path string) (*Spec, error)

LoadSpec reads an OpenAPI spec from a YAML or JSON file.

func (*Spec) ValidateResponse

func (s *Spec) ValidateResponse(method, path string, statusCode int, body string) *Result

ValidateResponse checks a response body against the schema defined for the given method, path, and status code in the spec.

type Violation

type Violation struct {
	Path     string
	Message  string
	Severity string // "error" or "warning"
}

Violation represents a single schema validation failure.

Jump to

Keyboard shortcuts

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