model

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: MIT Imports: 18 Imported by: 3

Documentation

Index

Constants

View Source
const (
	SeverityError        = "error"
	SeverityWarn         = "warn"
	SeverityInfo         = "info"
	SeverityHint         = "hint"
	SeverityNone         = "none"
	CategoryExamples     = "examples"
	CategoryOperations   = "operations"
	CategoryInfo         = "information"
	CategoryDescriptions = "descriptions"
	CategorySchemas      = "schemas"
	CategorySecurity     = "security"
	CategoryTags         = "tags"
	CategoryValidation   = "validation"
	CategoryOWASP        = "OWASP"
	CategoryAll          = "all"
)
View Source
const (
	OAS2  = "oas2"
	OAS3  = "oas3"
	OAS31 = "oas3_1"
	OAS32 = "oas3_2"
)
View Source
const FunctionCategoryCore = "core"
View Source
const FunctionCategoryCustomJS = "customjs"
View Source
const FunctionCategoryOWASP = "owasp"
View Source
const FunctionCategoryOpenAPI = "openapi"
View Source
const GithubUrl = "https://github.com/daveshanley/vacuum"
View Source
const WebsiteUrl = "https://quobix.com/vacuum"

Variables

View Source
var AllExceptOAS3_1 = []string{OAS2, OAS3}
View Source
var AllFormats = []string{OAS3, OAS31, OAS32, OAS2}
View Source
var OAS2Format = []string{OAS2}
View Source
var OAS3AllFormat = []string{OAS3, OAS31, OAS32}
View Source
var OAS3Format = []string{OAS3}
View Source
var OAS3_1Format = []string{OAS31}
View Source
var OAS3_2Format = []string{OAS32}
View Source
var RuleCategories = make(map[string]*RuleCategory)
View Source
var RuleCategoriesOrdered []*RuleCategory

Functions

func BuildOperationFieldPath added in v0.17.8

func BuildOperationFieldPath(path, method, field string) string

BuildOperationFieldPath builds a path for operation fields

func BuildResponsePath added in v0.17.8

func BuildResponsePath(path, method, code string) string

BuildResponsePath builds a path for responses

func CompileRegex added in v0.0.44

func CompileRegex(context RuleFunctionContext, pattern string, results *[]RuleFunctionResult) *regexp.Regexp

CompileRegex attempts to compile the provided `Pattern` from the ruleset. If it fails, returns nil and adds an error to the result set. Any rule using this should then return the results if there is no *Regexp returned.

func ReturnPooledRuleFunctionResult added in v0.17.8

func ReturnPooledRuleFunctionResult(result *RuleFunctionResult)

ReturnPooledRuleFunctionResult returns a RuleFunctionResult to the pool for reuse. This should be called when the result is no longer needed to reduce memory pressure.

func ValidateRuleFunctionContextAgainstSchema

func ValidateRuleFunctionContextAgainstSchema(ruleFunction RuleFunction, ctx RuleFunctionContext) (bool, []string)

ValidateRuleFunctionContextAgainstSchema will perform run-time validation against a rule to ensure that options being passed in are acceptable and meet the needs of the Rule schema

Types

type AutoFixFunction added in v0.20.0

type AutoFixFunction func(node *yaml.Node, document *yaml.Node, context *RuleFunctionContext) (*yaml.Node, error)

AutoFixFunction defines the signature for auto-fix functions

type Example

type Example struct {
	Summary       string      `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description   string      `json:"description,omitempty" yaml:"description,omitempty"`
	Value         interface{} `json:"value,omitempty" yaml:"value,omitempty"`
	ExternalValue string      `json:"externalValue,omitempty" yaml:"externalValue,omitempty"`
}

type IgnoredItems added in v0.11.0

type IgnoredItems map[string][]string

IgnoredItems is a map of the rule ID to an array of violation paths

type JSONPathBuilder added in v0.17.8

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

Simple JSONPath builder for basic path construction

func GetJSONPathBuilder added in v0.17.8

func GetJSONPathBuilder() *JSONPathBuilder

GetJSONPathBuilder returns a simple JSONPath builder

func (*JSONPathBuilder) Build added in v0.17.8

func (b *JSONPathBuilder) Build() string

Build constructs the JSONPath

func (*JSONPathBuilder) Field added in v0.17.8

func (b *JSONPathBuilder) Field(field string) *JSONPathBuilder

Field adds a field to the path

func (*JSONPathBuilder) Index added in v0.17.8

func (b *JSONPathBuilder) Index(index int) *JSONPathBuilder

Index adds an index to the path

func (*JSONPathBuilder) Key added in v0.17.8

func (b *JSONPathBuilder) Key(key string) *JSONPathBuilder

Key adds a key to the path

func (*JSONPathBuilder) Reset added in v0.17.8

func (b *JSONPathBuilder) Reset() *JSONPathBuilder

Reset clears the builder

func (*JSONPathBuilder) Root added in v0.17.8

func (b *JSONPathBuilder) Root() *JSONPathBuilder

Root starts a JSONPath

type Rule

type Rule struct {
	Id                 string         `json:"id,omitempty" yaml:"id,omitempty"`
	Description        string         `json:"description,omitempty" yaml:"description,omitempty"`
	DocumentationURL   string         `json:"documentationUrl,omitempty" yaml:"documentationUrl,omitempty"`
	Message            string         `json:"message,omitempty" yaml:"message,omitempty"`
	Given              interface{}    `json:"given,omitempty" yaml:"given,omitempty"`
	Formats            []string       `json:"formats,omitempty" yaml:"formats,omitempty"`
	Resolved           bool           `json:"resolved,omitempty" yaml:"resolved,omitempty"`
	Recommended        bool           `json:"recommended,omitempty" yaml:"recommended,omitempty"`
	Type               string         `json:"type,omitempty" yaml:"type,omitempty"`
	Severity           string         `json:"severity,omitempty" yaml:"severity,omitempty"`
	Then               interface{}    `json:"then,omitempty" yaml:"then,omitempty"`
	PrecompiledPattern *regexp.Regexp `json:"-" yaml:"-"` // regex is slow.
	RuleCategory       *RuleCategory  `json:"category,omitempty" yaml:"category,omitempty"`
	Name               string         `json:"-" yaml:"-"`
	HowToFix           string         `json:"howToFix,omitempty" yaml:"howToFix,omitempty"`
	AutoFixFunction    string         `json:"autoFixFunction,omitempty" yaml:"autoFixFunction,omitempty"`
}

Rule is a structure that represents a rule as part of a ruleset.

func (*Rule) GetSeverityAsIntValue

func (r *Rule) GetSeverityAsIntValue() int

GetSeverityAsIntValue will return the severity state of the rule as an integer. If the severity is not known then -1 is returned.

func (Rule) ToJSON

func (r Rule) ToJSON() string

ToJSON render out a rule to JSON.

type RuleAction

type RuleAction struct {
	Field           string      `json:"field,omitempty" yaml:"field,omitempty"`
	Function        string      `json:"function,omitempty" yaml:"function,omitempty"`
	FunctionOptions interface{} `json:"functionOptions,omitempty" yaml:"functionOptions,omitempty"`
}

RuleAction is what to do, on what field, and what options are to be used.

func CastToRuleAction

func CastToRuleAction(action interface{}) *RuleAction

CastToRuleAction is a utility function to cast an unknown structure into a RuleAction. useful for when building rules or testing out concepts.

type RuleCategory

type RuleCategory struct {
	Id          string `json:"id" yaml:"id"`                             // The category ID
	Name        string `json:"name,omitempty" yaml:"name"`               // The name of the category
	Description string `json:"description,omitempty" yaml:"description"` // What is the category all about?
}

type RuleCategoryResult

type RuleCategoryResult struct {
	Rule      *Rule
	Results   []*RuleFunctionResult
	Seen      int
	Health    int
	Errors    int
	Warnings  int
	Info      int
	Hints     int
	Truncated bool
}

RuleCategoryResult contains metrics for a rule scored as part of a category.

type RuleFunction

type RuleFunction interface {
	RunRule(nodes []*yaml.Node, context RuleFunctionContext) []RuleFunctionResult // The place where logic is run
	GetSchema() RuleFunctionSchema                                                // How to use the function and its details.
	GetCategory() string                                                          // Returns the category the function is a part of.
}

RuleFunction is any compatible structure that can be used to run vacuum rules.

type RuleFunctionContext

type RuleFunctionContext struct {
	RuleAction *RuleAction         `json:"ruleAction,omitempty" yaml:"ruleAction,omitempty"` // A reference to the action defined configured by the rule
	Rule       *Rule               `json:"rule,omitempty" yaml:"rule,omitempty"`             // A reference to the Rule being used for the function
	Given      interface{}         `json:"given,omitempty" yaml:"given,omitempty"`           // Path/s being used by rule, multiple paths can be used
	Options    interface{}         `json:"options,omitempty" yaml:"options,omitempty"`       // Function options
	SpecInfo   *datamodel.SpecInfo `json:"specInfo,omitempty" yaml:"specInfo,omitempty"`     // A reference to all specification information for the spec being parsed.
	Index      *index.SpecIndex    `json:"-" yaml:"-"`                                       // A reference to the index created for the spec being parsed
	Document   libopenapi.Document `json:"-" yaml:"-"`                                       // A reference to the document being parsed
	DrDocument *model.DrDocument   `json:"-" yaml:"-"`                                       // A high level, more powerful representation of the document being parsed. Powered by the doctor.
	Logger     *slog.Logger        `json:"-" yaml:"-"`                                       // Custom logger

	// MaxConcurrentValidations controls the maximum number of parallel validations for functions that support
	// concurrency limiting (e.g., oasExampleSchema). Default is 10 if not set or 0.
	MaxConcurrentValidations int `json:"-" yaml:"-"`

	// ValidationTimeout controls the maximum time allowed for validation functions that support timeouts
	// (e.g., oasExampleSchema). Default is 10 seconds if not set or 0.
	ValidationTimeout time.Duration `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

RuleFunctionContext defines a RuleAction, Rule and Options for a RuleFunction being run.

func (*RuleFunctionContext) ClearOptionsCache added in v0.17.8

func (ctx *RuleFunctionContext) ClearOptionsCache()

ClearOptionsCache clears the cached options map. This should be called when the context is reused with different options to ensure cache consistency.

func (*RuleFunctionContext) GetOptionsStringMap added in v0.17.8

func (ctx *RuleFunctionContext) GetOptionsStringMap() map[string]string

GetOptionsStringMap returns the cached options as a string map, converting from interface{} if needed. This method caches the result to avoid repeated interface conversions during rule execution.

type RuleFunctionProperty

type RuleFunctionProperty struct {
	Name        string `json:"name" yaml:"name"`
	Description string `json:"description" yaml:"description"`
}

RuleFunctionProperty is used by RuleFunctionSchema to describe the functionOptions a Rule accepts

type RuleFunctionResult

type RuleFunctionResult struct {
	Message      string            `json:"message" yaml:"message"`                         // What failed and why?
	Range        reports.Range     `json:"range" yaml:"range"`                             // Where did it happen?
	Path         string            `json:"path" yaml:"path"`                               // the JSONPath to where it can be found, the first is extracted if there are multiple.
	Paths        []string          `json:"paths,omitempty" yaml:"paths,omitempty"`         // the JSONPath(s) to where it can be found, if there are multiple.
	RuleId       string            `json:"ruleId" yaml:"ruleId"`                           // The ID of the rule
	RuleSeverity string            `json:"ruleSeverity" yaml:"ruleSeverity"`               // the severity of the rule used
	Origin       *index.NodeOrigin `json:"origin,omitempty" yaml:"origin,omitempty"`       // Where did the result come from (source)?
	Rule         *Rule             `json:"-" yaml:"-"`                                     // The rule used
	StartNode    *yaml.Node        `json:"-" yaml:"-"`                                     // Start of the violation
	EndNode      *yaml.Node        `json:"-" yaml:"-"`                                     // end of the violation
	Timestamp    *time.Time        `json:"-" yaml:"-"`                                     // When the result was created.
	AutoFixed    bool              `json:"autoFixed,omitempty" yaml:"autoFixed,omitempty"` // Whether this violation was auto-fixed

	// ModelContext may or may nor be populated, depending on the rule used and the context of the rule. If it is
	// populated, then this is a reference to the model that fired the rule. (not currently used yet)
	ModelContext any `json:"-" yaml:"-"`
}

RuleFunctionResult describes a failure with linting after being run through a rule

func BuildFunctionResult

func BuildFunctionResult(key, message string, value interface{}) RuleFunctionResult

BuildFunctionResult will create a RuleFunctionResult from a key, message and value. Deprecated: use BuildFunctionResultWithDescription instead.

func BuildFunctionResultString

func BuildFunctionResultString(message string) RuleFunctionResult

BuildFunctionResultString will create a RuleFunctionResult from a string already parsed into a message.

func BuildFunctionResultWithDescription added in v0.1.0

func BuildFunctionResultWithDescription(desc, key, message string, value interface{}) RuleFunctionResult

BuildFunctionResultWithDescription will create a RuleFunctionResult from a description, key, message and value.

func BuildPooledFunctionResult added in v0.17.8

func BuildPooledFunctionResult(key, message string, value interface{}) *RuleFunctionResult

BuildPooledFunctionResult will create a RuleFunctionResult from the pool for better performance. The caller is responsible for returning the result to the pool when done.

func BuildPooledFunctionResultWithDescription added in v0.17.8

func BuildPooledFunctionResultWithDescription(desc, key, message string, value interface{}) *RuleFunctionResult

BuildPooledFunctionResultWithDescription will create a RuleFunctionResult from the pool for better performance. The caller is responsible for returning the result to the pool when done.

func GetPooledRuleFunctionResult added in v0.17.8

func GetPooledRuleFunctionResult() *RuleFunctionResult

GetPooledRuleFunctionResult gets a RuleFunctionResult from the pool. This helps reduce allocations by reusing objects.

func MapPathAndNodesToResults

func MapPathAndNodesToResults(path string, startNode, endNode *yaml.Node, results []RuleFunctionResult) []RuleFunctionResult

MapPathAndNodesToResults will map the same start/end nodes with the same path.

func NewRuleFunctionResultFromPool added in v0.17.8

func NewRuleFunctionResultFromPool(message, path, ruleId, ruleSeverity string) *RuleFunctionResult

NewRuleFunctionResultFromPool creates a new RuleFunctionResult using the pool and initializes it with the provided values.

type RuleFunctionSchema

type RuleFunctionSchema struct {
	Name          string                 `json:"name,omitempty" yaml:"name,omitempty"`                   // The name of this function **important**
	Required      []string               `json:"required,omitempty" yaml:"required,omitempty"`           // List of all required properties to be set
	RequiresField bool                   `json:"requiresField,omitempty" yaml:"requiresField,omitempty"` // 'field' must be used with this function
	Properties    []RuleFunctionProperty `json:"properties,omitempty" yaml:"properties,omitempty"`       // all properties to be passed to the function
	MinProperties int                    `json:"minProperties,omitempty" yaml:"minProperties,omitempty"` // Minimum number of properties
	MaxProperties int                    `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"` // Maximum number of properties
	ErrorMessage  string                 `json:"errorMessage,omitempty" yaml:"errorMessage,omitempty"`   // Error message to be used in case of failed validartion.
}

RuleFunctionSchema describes the name, required properties and a slice of RuleFunctionProperty properties.

func (RuleFunctionSchema) GetPropertyDescription

func (rfs RuleFunctionSchema) GetPropertyDescription(name string) string

GetPropertyDescription is a shortcut method for extracting the description of a property by its name.

type RuleResultSet

type RuleResultSet struct {
	Results      []*RuleFunctionResult `json:"results,omitempty" yaml:"results,omitempty"`           // All the results!
	FixedResults []*RuleFunctionResult `json:"fixedResults,omitempty" yaml:"fixedResults,omitempty"` // Results that were automatically fixed
	WarnCount    int                   `json:"warningCount" yaml:"warningCount"`                     // Total warnings
	ErrorCount   int                   `json:"errorCount" yaml:"errorCount"`                         // Total errors
	InfoCount    int                   `json:"infoCount" yaml:"infoCount"`                           // Total info
	// contains filtered or unexported fields
}

RuleResultSet contains all the results found during a linting run, and all the methods required to filter, sort and calculate counts.

func NewRuleResultSet

func NewRuleResultSet(results []RuleFunctionResult) *RuleResultSet

NewRuleResultSet will encapsulate a set of results into a set, that can then be queried. the function will create pointers to results, instead of copying them again.

func NewRuleResultSetPointer added in v0.0.4

func NewRuleResultSetPointer(results []*RuleFunctionResult) *RuleResultSet

the function will create pointers to results, instead of copying them again.

func (*RuleResultSet) AddFixedResults added in v0.20.0

func (rr *RuleResultSet) AddFixedResults(fixedResults []RuleFunctionResult)

AddFixedResults adds fixed results from execution result to the RuleResultSet

func (*RuleResultSet) CalculateCategoryHealth

func (rr *RuleResultSet) CalculateCategoryHealth(category string) int

CalculateCategoryHealth checks how many errors and warnings a category has generated and determine a value between 0 and 100, 0 being errors fired, 100 being no warnings and no errors.

func (*RuleResultSet) GenerateSpectralReport

func (rr *RuleResultSet) GenerateSpectralReport(source string) []reports.SpectralReport

GenerateSpectralReport will return a Spectral compatible report structure, easily serializable

func (*RuleResultSet) GetErrorCount

func (rr *RuleResultSet) GetErrorCount() int

GetErrorCount will return the number of errors returned by the rule results.

func (*RuleResultSet) GetErrorsByRuleCategory

func (rr *RuleResultSet) GetErrorsByRuleCategory(category string) []*RuleFunctionResult

GetErrorsByRuleCategory will return all results with an error level severity from rule category.

func (*RuleResultSet) GetHintByRuleCategory added in v0.0.2

func (rr *RuleResultSet) GetHintByRuleCategory(category string) []*RuleFunctionResult

GetHintByRuleCategory will return all results with hint level severity from rule category.

func (*RuleResultSet) GetInfoByRuleCategory

func (rr *RuleResultSet) GetInfoByRuleCategory(category string) []*RuleFunctionResult

GetInfoByRuleCategory will return all results with an info level severity from rule category.

func (*RuleResultSet) GetInfoCount

func (rr *RuleResultSet) GetInfoCount() int

GetInfoCount will return the number of warnings returned by the rule results.

func (*RuleResultSet) GetResultsByRuleCategory

func (rr *RuleResultSet) GetResultsByRuleCategory(category string) []*RuleFunctionResult

GetResultsByRuleCategory will return results filtered by the supplied category

func (*RuleResultSet) GetResultsForCategoryWithLimit added in v0.0.2

func (rr *RuleResultSet) GetResultsForCategoryWithLimit(category string, limit int) *RuleResultsForCategory

GetResultsForCategoryWithLimit is identical to GetRuleResultsForCategory, except for the fact that there will be a limit on the number of results returned, defined by the limit arg. This is used by the HTML report to stop gigantic files from being created, iterating through all the results.

func (*RuleResultSet) GetRuleResultsForCategory

func (rr *RuleResultSet) GetRuleResultsForCategory(category string) *RuleResultsForCategory

GetRuleResultsForCategory will return all rules that returned results during linting, complete with pre compiled statistics for easy indexing.

func (*RuleResultSet) GetWarnCount

func (rr *RuleResultSet) GetWarnCount() int

GetWarnCount will return the number of warnings returned by the rule results.

func (*RuleResultSet) GetWarningsByRuleCategory

func (rr *RuleResultSet) GetWarningsByRuleCategory(category string) []*RuleFunctionResult

GetWarningsByRuleCategory will return all results with a warning level severity from rule category.

func (*RuleResultSet) Len

func (rr *RuleResultSet) Len() int

Len returns the length of the results

func (*RuleResultSet) Less

func (rr *RuleResultSet) Less(i, j int) bool

Less determines which result has the lower line number

func (*RuleResultSet) PrepareForSerialization added in v0.0.4

func (rr *RuleResultSet) PrepareForSerialization(info *datamodel.SpecInfo)

PrepareForSerialization will create a new Range for start and end nodes as well as pre-render code. When saving a vacuum report, this will be required, so the report can be re-constructed later without the original spec being required.

func (*RuleResultSet) ResetCounts added in v0.16.10

func (rr *RuleResultSet) ResetCounts()

func (*RuleResultSet) SortResultsByLineNumber

func (rr *RuleResultSet) SortResultsByLineNumber() []*RuleFunctionResult

SortResultsByLineNumber will re-order the results by line number. This is a destructive sort, Once the results are sorted, they are permanently sorted.

func (*RuleResultSet) Swap

func (rr *RuleResultSet) Swap(i, j int)

Swap will re-sort a result if it's in the wrong order.

type RuleResultsForCategory

type RuleResultsForCategory struct {
	RuleResults []*RuleCategoryResult
	Category    *RuleCategory
}

RuleResultsForCategory boils down result statistics for a linting category

func (*RuleResultsForCategory) Len

func (rr *RuleResultsForCategory) Len() int

Len returns the length of the results

func (*RuleResultsForCategory) Less

func (rr *RuleResultsForCategory) Less(i, j int) bool

Less determines which result has the lower severity (errors bubble to top)

func (*RuleResultsForCategory) Swap

func (rr *RuleResultsForCategory) Swap(i, j int)

Swap will re-sort a result if it's in the wrong order.

type SearchResult

type SearchResult struct {
	Key  string `json:"key"`
	Line int    `json:"line"`
	Col  int    `json:"col"`
}

SearchResult represents the position of a result in a specification.

type StringTemplates added in v0.17.8

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

StringTemplates provides efficient string building for common patterns in vacuum. This replaces fmt.Sprintf usage to reduce allocation overhead.

func GetStringTemplates added in v0.17.8

func GetStringTemplates() *StringTemplates

GetStringTemplates returns the global StringTemplates instance

func NewStringTemplates added in v0.17.8

func NewStringTemplates() *StringTemplates

NewStringTemplates creates a new StringTemplates instance

func (*StringTemplates) BuildAPIKeyMessage added in v0.17.8

func (st *StringTemplates) BuildAPIKeyMessage(key string) string

BuildAPIKeyMessage builds an API key security message Pattern: "API keys must not be passed via URL parameters (`key`)"

func (*StringTemplates) BuildAlphabeticalMessage added in v0.17.8

func (st *StringTemplates) BuildAlphabeticalMessage(ruleMessage, item1, item2 string) string

BuildAlphabeticalMessage builds an alphabetical ordering error message Pattern: "ruleMessage: `item1` must be placed before `item2` (alphabetical)"

func (*StringTemplates) BuildArrayPath added in v0.17.8

func (st *StringTemplates) BuildArrayPath(base string, index int) string

BuildArrayPath builds an array access path Pattern: "base[index]"

func (*StringTemplates) BuildBothDefinedMessage added in v0.17.8

func (st *StringTemplates) BuildBothDefinedMessage(ruleMessage, field1, field2 string) string

BuildBothDefinedMessage builds a message for XOR validation Pattern: "ruleMessage: `field1` and `field2` must not be both defined or undefined"

func (*StringTemplates) BuildCachedFieldValidationMessage added in v0.17.8

func (st *StringTemplates) BuildCachedFieldValidationMessage(ruleMessage, field, condition string) string

BuildCachedFieldValidationMessage builds a cached field validation message This caches common validation patterns to avoid rebuilding the same messages

func (*StringTemplates) BuildCachedPatternMessage added in v0.17.8

func (st *StringTemplates) BuildCachedPatternMessage(ruleMessage, value, pattern string) string

BuildCachedPatternMessage builds a cached pattern validation message

func (*StringTemplates) BuildCredentialsMessage added in v0.17.8

func (st *StringTemplates) BuildCredentialsMessage(param string) string

BuildCredentialsMessage builds a credentials security message Pattern: "URL parameters must not contain credentials, passwords, or secrets (`param`)"

func (*StringTemplates) BuildEnumValidationMessage added in v0.17.8

func (st *StringTemplates) BuildEnumValidationMessage(ruleMessage, value string, allowedValues interface{}) string

BuildEnumValidationMessage builds an enum validation error message Pattern: "ruleMessage: `value` must equal to one of: [values]"

func (*StringTemplates) BuildFieldMessage added in v0.17.8

func (st *StringTemplates) BuildFieldMessage(ruleMessage, field, message string) string

BuildFieldMessage builds a general field message Pattern: "ruleMessage: `field` message"

func (*StringTemplates) BuildFieldMustNotMessage added in v0.17.8

func (st *StringTemplates) BuildFieldMustNotMessage(ruleMessage, field, condition string) string

BuildFieldMustNotMessage builds a "must not" validation error message Pattern: "ruleMessage: `field` must not be condition"

func (*StringTemplates) BuildFieldValidationMessage added in v0.17.8

func (st *StringTemplates) BuildFieldValidationMessage(ruleMessage, field, condition string) string

BuildFieldValidationMessage builds a validation error message for a field Pattern: "ruleMessage: `field` must be condition"

func (*StringTemplates) BuildHTTPVerbInPathMessage added in v0.17.8

func (st *StringTemplates) BuildHTTPVerbInPathMessage(path, verb string) string

BuildHTTPVerbInPathMessage builds an HTTP verb in path error message Pattern: "path `path` contains an HTTP Verb `verb`"

func (*StringTemplates) BuildJSONPath added in v0.17.8

func (st *StringTemplates) BuildJSONPath(base, field string) string

BuildJSONPath builds a JSON path string Pattern: "base.field"

func (*StringTemplates) BuildKebabCaseMessage added in v0.17.8

func (st *StringTemplates) BuildKebabCaseMessage(segments string) string

BuildKebabCaseMessage builds a kebab-case validation message Pattern: "path segments `segments` do not use kebab-case"

func (*StringTemplates) BuildMissingExampleMessage added in v0.17.8

func (st *StringTemplates) BuildMissingExampleMessage(propName string) string

BuildMissingExampleMessage builds a missing example error message Pattern: "media type schema property `propName` is missing `examples` or `example`"

func (*StringTemplates) BuildMissingRequiredMessage added in v0.17.8

func (st *StringTemplates) BuildMissingRequiredMessage(itemType, item, context string) string

BuildMissingRequiredMessage builds a missing required field message Pattern: "missing response code `code` for `method`"

func (*StringTemplates) BuildNumericalOrderingMessage added in v0.17.8

func (st *StringTemplates) BuildNumericalOrderingMessage(ruleMessage, value1, value2 string) string

BuildNumericalOrderingMessage builds a numerical ordering error message Pattern: "ruleMessage: `value1` is less than `value2`, they need to be swapped (numerical ordering)"

func (*StringTemplates) BuildOWASPResponseMessage added in v0.17.8

func (st *StringTemplates) BuildOWASPResponseMessage(code, headers string) string

BuildOWASPResponseMessage builds an OWASP response validation message Pattern: "response with code `code`, must contain one of the defined headers: `headers`"

func (*StringTemplates) BuildPatternMatchMessage added in v0.17.8

func (st *StringTemplates) BuildPatternMatchMessage(ruleMessage, pattern string) string

BuildPatternMatchMessage builds a pattern match error message Pattern: "ruleMessage: matches the expression `pattern`"

func (*StringTemplates) BuildPatternMessage added in v0.17.8

func (st *StringTemplates) BuildPatternMessage(ruleMessage, value, pattern string) string

BuildPatternMessage builds a pattern validation error message Pattern: "ruleMessage: `value` does not match the expression `pattern`"

func (*StringTemplates) BuildPropertyArrayPath added in v0.17.8

func (st *StringTemplates) BuildPropertyArrayPath(base, property string, index int) string

BuildPropertyArrayPath builds a property array path Pattern: "base.property[index]"

func (*StringTemplates) BuildQuotedPath added in v0.17.8

func (st *StringTemplates) BuildQuotedPath(base, field string) string

BuildQuotedPath builds a quoted field path Pattern: "base['field']"

func (*StringTemplates) BuildRegexCompileErrorMessage added in v0.17.8

func (st *StringTemplates) BuildRegexCompileErrorMessage(ruleMessage, pattern, errorMsg string) string

BuildRegexCompileErrorMessage builds a regex compilation error message Pattern: "ruleMessage: `pattern` cannot be compiled into a regular expression [`error`]"

func (*StringTemplates) BuildRequiredFieldMessage added in v0.17.8

func (st *StringTemplates) BuildRequiredFieldMessage(field string) string

BuildRequiredFieldMessage builds a required field error message Pattern: "`required` field `field` is not defined in `properties`"

func (*StringTemplates) BuildSecurityDefinedMessage added in v0.17.8

func (st *StringTemplates) BuildSecurityDefinedMessage(path, method string) string

BuildSecurityDefinedMessage builds a security defined message Pattern: "`security` was not defined for path `path` in method `method`"

func (*StringTemplates) BuildSecurityEmptyMessage added in v0.17.8

func (st *StringTemplates) BuildSecurityEmptyMessage(path, method string) string

BuildSecurityEmptyMessage builds a security empty message Pattern: "`security` is empty for path `path` in method `method`"

func (*StringTemplates) BuildSecurityNullElementsMessage added in v0.17.8

func (st *StringTemplates) BuildSecurityNullElementsMessage(path, method string) string

BuildSecurityNullElementsMessage builds a security null elements message Pattern: "`security` has null elements for path `path` in method `method`"

func (*StringTemplates) BuildTypeErrorMessage added in v0.17.8

func (st *StringTemplates) BuildTypeErrorMessage(ruleMessage, value, typeDesc, errorMessage string) string

BuildTypeErrorMessage builds a type validation error message Pattern: "ruleMessage: `value` is a type. errorMessage"

func (*StringTemplates) BuildUnknownSchemaTypeMessage added in v0.17.8

func (st *StringTemplates) BuildUnknownSchemaTypeMessage(schemaType string) string

BuildUnknownSchemaTypeMessage builds an unknown schema type error message Pattern: "unknown schema type: `type`"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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