Documentation
¶
Index ¶
- Variables
- func BuildEndNode(node *yaml.Node) *yaml.Node
- func ConvertToMarshalable(data interface{}) interface{}
- func CreateCustomHTTPClient(config HTTPClientConfig) (*http.Client, error)
- func CreateRemoteURLHandler(client *http.Client) func(url string) (*http.Response, error)
- func FilterIgnoredResults(results []model.RuleFunctionResult, ignored model.IgnoredItems) []model.RuleFunctionResult
- func FilterIgnoredResultsPtr(results []*model.RuleFunctionResult, ignored model.IgnoredItems) []*model.RuleFunctionResult
- func LocateComponentPaths(context model.RuleFunctionContext, component v3.Foundational, ...) (primaryPath string, allPaths []string)
- func LocateSchemaPropertyPaths(context model.RuleFunctionContext, schema *v3.Schema, keyNode *yaml.Node, ...) (primaryPath string, allPaths []string)
- func QuickCheckMarshalable(data interface{}) bool
- func RenderMarkdownTable(headers []string, rows [][]string) string
- func ShouldUseCustomHTTPClient(config HTTPClientConfig) bool
- func SuppliedOrDefault(supplied, original string) string
- type HTTPClientConfig
- type LintFileRequest
- type MarshalingIssue
Constants ¶
This section is empty.
Variables ¶
var ( LocationRegex = regexp.MustCompile(`((?:[a-zA-Z]:)?[^\s│]*?[/\\]?[^\s│/\\]+\.[a-zA-Z]+):(\d+):(\d+)`) JsonPathRegex = regexp.MustCompile(`\$\.\S+`) CircularRefRegex = regexp.MustCompile(`\b[a-zA-Z0-9_-]+(?:\s*->\s*[a-zA-Z0-9_-]+)+\b`) PartRegex = regexp.MustCompile(`([a-zA-Z0-9_-]+)|(\s*->\s*)`) BacktickRegex = regexp.MustCompile("`([^`]+)`") SingleQuoteRegex = regexp.MustCompile(`'([^']+)'`) LogPrefixRegex = regexp.MustCompile(`\[([^]]+)]`) )
Functions ¶
func BuildEndNode ¶ added in v0.9.0
BuildEndNode will return a new yaml.Node with the same line as the input node, but with a column that is the sum of the input node's column and the length of the input node's value.
func ConvertToMarshalable ¶ added in v0.17.10
func ConvertToMarshalable(data interface{}) interface{}
ConvertToMarshalable attempts to convert problematic structures to JSON-marshalable ones. This is a helper that can be used to fix issues, but for validation we just report them.
func CreateCustomHTTPClient ¶ added in v0.17.8
func CreateCustomHTTPClient(config HTTPClientConfig) (*http.Client, error)
CreateCustomHTTPClient creates an HTTP client with custom TLS configuration for certificate-based authentication and custom CA certificates.
func CreateRemoteURLHandler ¶ added in v0.17.8
CreateRemoteURLHandler creates a RemoteURLHandler function for use with libopenapi that uses the provided HTTP client for all remote requests.
func FilterIgnoredResults ¶ added in v0.17.11
func FilterIgnoredResults(results []model.RuleFunctionResult, ignored model.IgnoredItems) []model.RuleFunctionResult
FilterIgnoredResults does the filtering of ignored results on non-pointer result elements
func FilterIgnoredResultsPtr ¶ added in v0.17.11
func FilterIgnoredResultsPtr(results []*model.RuleFunctionResult, ignored model.IgnoredItems) []*model.RuleFunctionResult
FilterIgnoredResultsPtr filters the given results slice, taking out any (RuleID, Path) combos that were listed in the ignore file
func LocateComponentPaths ¶ added in v0.18.0
func LocateComponentPaths( context model.RuleFunctionContext, component v3.Foundational, keyNode *yaml.Node, valueNode *yaml.Node, ) (primaryPath string, allPaths []string)
LocateComponentPaths finds all paths where a component appears in the document. It uses DrDocument.LocateModelsByKeyAndValue to find all locations where the component is referenced, not just its definition location. This is a generic version that works with any component type that has GenerateJSONPath. Returns the primary path and all paths where the component appears.
func LocateSchemaPropertyPaths ¶ added in v0.17.10
func LocateSchemaPropertyPaths( context model.RuleFunctionContext, schema *v3.Schema, keyNode *yaml.Node, valueNode *yaml.Node, ) (primaryPath string, allPaths []string)
LocateSchemaPropertyPaths finds all paths where a schema property appears in the document. It uses DrDocument.LocateModelsByKeyAndValue to find all locations where the schema is referenced, not just its definition location. Returns the primary path and all paths where the schema appears.
func QuickCheckMarshalable ¶ added in v0.17.10
func QuickCheckMarshalable(data interface{}) bool
QuickCheckMarshalable does a quick check to see if data can be marshaled to JSON without doing a deep analysis. Returns true if marshalable, false otherwise.
func RenderMarkdownTable ¶ added in v0.16.15
RenderMarkdownTable builds a Markdown table from headers and rows.
func ShouldUseCustomHTTPClient ¶ added in v0.17.8
func ShouldUseCustomHTTPClient(config HTTPClientConfig) bool
ShouldUseCustomHTTPClient returns true if any TLS-related configuration is provided
func SuppliedOrDefault ¶ added in v0.7.0
Types ¶
type HTTPClientConfig ¶ added in v0.17.8
HTTPClientConfig holds configuration for creating a custom HTTP client
type LintFileRequest ¶ added in v0.9.0
type LintFileRequest struct {
FileName string
BaseFlag string
MultiFile bool
Remote bool
SkipCheckFlag bool
Silent bool
DetailsFlag bool
TimeFlag bool
NoMessageFlag bool
ExtensionRefs bool
AllResultsFlag bool
FailSeverityFlag string
CategoryFlag string
SnippetsFlag bool
ErrorsFlag bool
TotalFiles int
FileIndex int
TimeoutFlag int
IgnoreArrayCircleRef bool
IgnorePolymorphCircleRef bool
NoClip bool
IgnoredResults model.IgnoredItems
DefaultRuleSets rulesets.RuleSets
SelectedRS *rulesets.RuleSet
Functions map[string]model.RuleFunction
Lock *sync.Mutex
Logger *slog.Logger
PipelineOutput bool
ShowRules bool
HTTPClientConfig HTTPClientConfig
}
type MarshalingIssue ¶ added in v0.17.10
type MarshalingIssue struct {
Line int
Column int
Path string
Reason string
KeyValue string // The actual key that's problematic
}
MarshalingIssue represents a location where JSON marshaling will fail
func CheckJSONMarshaling ¶ added in v0.17.10
func CheckJSONMarshaling(data interface{}, rootNode *yaml.Node) []MarshalingIssue
CheckJSONMarshaling attempts to marshal the data and returns any marshaling issues found. It only performs deep checking if the initial marshal fails.
func FindMarshalingIssuesInYAML ¶ added in v0.17.10
func FindMarshalingIssuesInYAML(rootNode *yaml.Node) []MarshalingIssue
FindMarshalingIssuesInYAML directly checks the YAML AST for marshaling issues without needing the unmarshaled data. This is useful when SpecJSON is nil.