Documentation
¶
Index ¶
- Constants
- func BuildRolodexFromIndexConfig(indexConfig *index.SpecIndexConfig, customFS fs.FS) (*index.Rolodex, error)
- type ExecutionOptions
- type RuleComposer
- type RuleLookupError
- type RuleSetExecution
- type RuleSetExecutionResult
- func ApplyAsyncAPIRulesToRuleSet(execution *RuleSetExecution, opts *ExecutionOptions, ...) (*RuleSetExecutionResult, bool)
- func ApplyRulesToRuleSet(execution *RuleSetExecution) *RuleSetExecutionResult
- func ApplyRulesToRuleSetWithOptions(execution *RuleSetExecution, executionOptions *ExecutionOptions) *RuleSetExecutionResult
Constants ¶
const CircularReferencesFix string = "Circular references are created by schemas that reference back to themselves somewhere " +
"in the chain. The link could be very deep, or it could be super shallow. Sometimes it's hard to know what is looping " +
"without resolving the references. This model is looping, Remove the looping link in the chain. This can also appear with missing or " +
"references that cannot be located or resolved correctly."
todo: move copy into virtual file system or some kind of map.
Variables ¶
This section is empty.
Functions ¶
func BuildRolodexFromIndexConfig ¶ added in v0.4.0
Types ¶
type ExecutionOptions ¶ added in v0.26.5
type ExecutionOptions struct {
ResolveAllRefs bool // Force resolved document/index selection for all rules
NestedRefsDocContext bool // Resolve nested relative refs from the referenced document's path/index in resolved execution
}
ExecutionOptions configures optional execution behavior without extending RuleSetExecution's public struct surface.
type RuleComposer ¶
type RuleComposer struct {
}
RuleComposer will consume a ruleset specification into a *model.RuleSet
func CreateRuleComposer ¶
func CreateRuleComposer() *RuleComposer
CreateRuleComposer will create a new RuleComposer and return a pointer to it.
func (*RuleComposer) ComposeRuleSet ¶
func (rc *RuleComposer) ComposeRuleSet(ruleset []byte) (*rulesets.RuleSet, error)
ComposeRuleSet compose a byte array ruleset specification into a *model.RuleSet
type RuleLookupError ¶ added in v0.26.7
func (*RuleLookupError) Error ¶ added in v0.26.7
func (e *RuleLookupError) Error() string
func (*RuleLookupError) Unwrap ¶ added in v0.26.7
func (e *RuleLookupError) Unwrap() error
type RuleSetExecution ¶
type RuleSetExecution struct {
RuleSet *rulesets.RuleSet // The RuleSet in which to apply
SpecFileName string // The path of the specification file, used to correctly label location
Spec []byte // The raw bytes of the OpenAPI specification.
SpecInfo *datamodel.SpecInfo // Pre-parsed spec-info.
IndexUnresolved *index.SpecIndex // The unresolved index, even if a file is not an OpenAPI spec, it's still indexed.
IndexResolved *index.SpecIndex // The resolved index, like the unresolved one, but with references resolved.
CustomFunctions map[string]model.RuleFunction // custom functions loaded from plugin.
AutoFixFunctions map[string]model.AutoFixFunction // auto-fix functions loaded from plugin.
PanicFunction func(p any) // In case of emergency, do this thing here.
SilenceLogs bool // Prevent any warnings about rules/rule-sets being printed.
Base string // The base path or URL of the specification, used for resolving relative or remote paths.
AllowLookup bool // Allow remote lookup of files or links
Document libopenapi.Document // a ready to render model.
DrDocument *doctorModel.DrDocument // a high level, more powerful model, powered by the doctorModel.
AsyncAPI *asyncapi_context.Context // AsyncAPI context, populated only for AsyncAPI execution.
SkipDocumentCheck bool // Skip the document check, useful for fragments and non openapi specs.
Logger *slog.Logger // A custom logger.
Timeout time.Duration // The timeout for each rule to run, prevents run-away rules, default is five seconds.
NodeLookupTimeout time.Duration // The timeout for each node yaml path lookup, prevents any endless loops, default is 500ms (https://github.com/daveshanley/vacuum/issues/502)
BuildGraph bool // Build a graph of the document, powered by the doctorModel. (default is false)
RenderChanges bool // Not used by vacuum, used by the openapi doctor (defaults to false).
BuildDeepGraph bool // Build a deep graph of the document, all paths in the graph will be followed, no caching on schemas. (default is false). Required when using ignore files as an object can be referenced in multiple places.
ExtractReferencesSequentially bool // Extract references sequentially, defaults to false, can be slow.
ExtractReferencesFromExtensions bool // Extract references from extension objects (x-), this may pull in all kinds of non-parsable files in.
ApplyAutoFixes bool // Apply auto-fixes for rules that support it
CanonicalDocument *yaml.Node // The single source of truth for all modifications
// https://pb33f.io/libopenapi/circular-references/#circular-reference-results
IgnoreCircularArrayRef bool // Ignore array circular references
IgnoreCircularPolymorphicRef bool // Ignore polymorphic circular references
// not generally used.
StorageRoot string // The root path for storage, used for storing files upstream by the doctorModel. You probably don't need this.
RolodexFS fs.FS // supply a custom local filesystem to be used by the rolodex, useful if you need fine grained control over local file references.
// HTTP client configuration for TLS/certificate support
HTTPClientConfig vacuumUtils.HTTPClientConfig // Configuration for custom HTTP client with certificate support
// FetchConfig configures JavaScript fetch() requests in custom functions.
// Threading chain: CLI flags → GetFetchConfig() → RuleSetExecution.FetchConfig →
// ruleContext.fetchConfig → RuleFunctionContext.FetchConfig → NewFetchModuleFromConfig()
FetchConfig *vacuumUtils.FetchConfig
// Turbo mode and experimental optimization flags
TurboMode bool // Skip expensive rules and inline ignore checks
SkipResolve bool // Skip second-pass reference resolution
SkipCircularCheck bool // Skip circular reference result injection
SkipSchemaErrors bool // Skip schema build error injection
SpecFormat string
}
RuleSetExecution is an instruction set for executing a ruleset. It's a convenience structure to allow the signature of ApplyRulesToRuleSet to change, without a huge refactor. The ApplyRulesToRuleSet function only returns a single error also.
type RuleSetExecutionResult ¶
type RuleSetExecutionResult struct {
RuleSetExecution *RuleSetExecution // The execution struct that was used invoking the result.
Results []model.RuleFunctionResult // The results of the execution.
IgnoredResults []model.RuleFunctionResult // Results that were ignored due to inline ignore directives.
FixedResults []model.RuleFunctionResult // Results that were automatically fixed.
Index *index.SpecIndex // The index that was created from the specification, used by the rules.
SpecInfo *datamodel.SpecInfo // A reference to the SpecInfo object, used by all the rules.
Errors []error // Any errors that were returned.
FilesProcessed int // number of files extracted by the rolodex
FileSize int64 // total filesize loaded by the rolodex
DocumentConfig *datamodel.DocumentConfiguration // The document configuration used to create the document.
AsyncAPI *asyncapi_context.Context // The AsyncAPI context created for AsyncAPI execution.
ModifiedSpec []byte // The spec with autofix changes applied (if any fixes were made).
// contains filtered or unexported fields
}
RuleSetExecutionResult returns the results of running the ruleset against the supplied spec.
func ApplyAsyncAPIRulesToRuleSet ¶ added in v0.29.0
func ApplyAsyncAPIRulesToRuleSet( execution *RuleSetExecution, opts *ExecutionOptions, builtinFunctions functions.Functions, ) (*RuleSetExecutionResult, bool)
ApplyAsyncAPIRulesToRuleSet handles AsyncAPI documents before the shared applicator enters libopenapi's OpenAPI document builder. The boolean return tells the caller whether the document was AsyncAPI-shaped and fully handled.
func ApplyRulesToRuleSet ¶
func ApplyRulesToRuleSet(execution *RuleSetExecution) *RuleSetExecutionResult
ApplyRulesToRuleSet is a replacement for ApplyRules. This function was created before trying to use vacuum as an API. The signature is not sufficient, but is embedded everywhere. This new method uses a message structure, to allow the signature to grow, without breaking anything.
func ApplyRulesToRuleSetWithOptions ¶ added in v0.26.5
func ApplyRulesToRuleSetWithOptions(execution *RuleSetExecution, executionOptions *ExecutionOptions) *RuleSetExecutionResult
ApplyRulesToRuleSetWithOptions applies a ruleset with explicit execution options.
func (*RuleSetExecutionResult) HasTruncatedPaths ¶ added in v0.30.0
func (r *RuleSetExecutionResult) HasTruncatedPaths() bool
HasTruncatedPaths reports whether result-path reconciliation limited resolved aliases.
func (*RuleSetExecutionResult) Release ¶ added in v0.25.4
func (r *RuleSetExecutionResult) Release()
Release frees memory-heavy resources retained by the result once the caller is finished inspecting it. This includes vacuum-owned documents, the doctor document, indexes, and libopenapi's process-wide caches.
The cache reset is global, not scoped to this result. Calling Release can affect other concurrent linting or document-processing routines running in the same process. Prefer ReleaseOwnedResources for long-lived or concurrent workflows. Caller-supplied documents are never released by vacuum.
func (*RuleSetExecutionResult) ReleaseOwnedResources ¶ added in v0.26.5
func (r *RuleSetExecutionResult) ReleaseOwnedResources()
ReleaseOwnedResources frees result-owned documents, indexes and other retained execution resources without resetting libopenapi's process-wide caches. Caller-supplied documents are never released by vacuum.