motor

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 25 Imported by: 3

Documentation

Index

Constants

View Source
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

func BuildRolodexFromIndexConfig(indexConfig *index.SpecIndexConfig) (*index.Rolodex, error)

Types

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 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.
	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.
	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)
	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.

	// 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.
}

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.
	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
}

RuleSetExecutionResult returns the results of running the ruleset against the supplied spec.

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.

Jump to

Keyboard shortcuts

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