profile

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package profile provides loading and management of API style profiles.

Package profile provides loading and management of API style profiles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListBuiltin

func ListBuiltin() ([]string, error)

ListBuiltin returns the names of all built-in profiles.

func Load

func Load(name string) (*types.APIStyleSpec, error)

Load loads a profile by name using default search paths.

func LoadFile

func LoadFile(path string) (*types.APIStyleSpec, error)

LoadFile loads a profile from a specific file path.

Types

type Loader

type Loader struct {
	// SearchPaths are directories to search for profiles.
	SearchPaths []string
}

Loader loads and resolves API style profiles.

func NewLoader

func NewLoader() *Loader

NewLoader creates a new profile loader.

func (*Loader) Load

func (l *Loader) Load(name string) (*types.APIStyleSpec, error)

Load loads a profile by name. It first checks built-in profiles, then searches the filesystem.

type ValidationError added in v0.4.0

type ValidationError struct {
	RuleID  string
	Field   string
	Detail  string
	Warning bool // If true, this is a warning, not an error
}

ValidationError represents a validation error for a profile.

func (ValidationError) Error added in v0.4.0

func (e ValidationError) Error() string

type ValidationResult added in v0.4.0

type ValidationResult struct {
	Errors   []ValidationError
	Warnings []ValidationError
}

ValidationResult contains the results of profile validation.

func DisableInvalidRules added in v0.4.0

func DisableInvalidRules(spec *types.APIStyleSpec) *ValidationResult

DisableInvalidRules modifies the spec in-place to disable rules with invalid JSONPath expressions by changing their enforcement type to "none". This is an alternative to FilterInvalidRules that preserves the rules for LLM evaluation while skipping deterministic linting.

func FilterInvalidRules added in v0.4.0

func FilterInvalidRules(spec *types.APIStyleSpec) (*types.APIStyleSpec, *ValidationResult)

FilterInvalidRules returns a new spec with invalid rules removed. Invalid rules are those with JSONPath expressions that cannot be parsed. This function also returns the validation result for reporting.

func ValidateProfile added in v0.4.0

func ValidateProfile(spec *types.APIStyleSpec) *ValidationResult

ValidateProfile validates a profile and returns validation results. It checks for: - Invalid JSONPath expressions in enforcement.given.paths - Missing required fields - Semantic issues

func (*ValidationResult) HasErrors added in v0.4.0

func (r *ValidationResult) HasErrors() bool

HasErrors returns true if there are any errors.

func (*ValidationResult) HasWarnings added in v0.4.0

func (r *ValidationResult) HasWarnings() bool

HasWarnings returns true if there are any warnings.

Jump to

Keyboard shortcuts

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