motor

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 17 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

This section is empty.

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
	Spec            []byte                        // The raw bytes of the OpenAPI specification.
	SpecInfo        *datamodel.SpecInfo           // Pre-parsed spec-info.
	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.
	Document        libopenapi.Document           // a ready to render model.
}

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.

}

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