Documentation ¶
Index ¶
- Constants
- Variables
- func AreValuesCorrectlyTyped(valType string, values interface{}) map[string]string
- func CheckEnumForDuplicates(seq []*yaml.Node) []*yaml.Node
- func ValidateRuleFunctionContextAgainstSchema(ruleFunction RuleFunction, ctx RuleFunctionContext) (bool, []string)
- type CircularReferenceResult
- type DescriptionReference
- type EnumReference
- type Example
- type ExternalLookupFunction
- type IndexingError
- type Reference
- type ReferenceMapped
- type Rule
- type RuleAction
- type RuleCategory
- type RuleCategoryResult
- type RuleFunction
- type RuleFunctionContext
- type RuleFunctionProperty
- type RuleFunctionResult
- type RuleFunctionSchema
- type RuleResultSet
- func (rr *RuleResultSet) CalculateCategoryHealth(category string) int
- func (rr *RuleResultSet) GenerateSpectralReport(source string) []reports.SpectralReport
- func (rr *RuleResultSet) GetErrorCount() int
- func (rr *RuleResultSet) GetErrorsByRuleCategory(category string) []*RuleFunctionResult
- func (rr *RuleResultSet) GetHintByRuleCategory(category string) []*RuleFunctionResult
- func (rr *RuleResultSet) GetInfoByRuleCategory(category string) []*RuleFunctionResult
- func (rr *RuleResultSet) GetInfoCount() int
- func (rr *RuleResultSet) GetResultsByRuleCategory(category string) []*RuleFunctionResult
- func (rr *RuleResultSet) GetResultsForCategoryWithLimit(category string, limit int) *RuleResultsForCategory
- func (rr *RuleResultSet) GetRuleResultsForCategory(category string) *RuleResultsForCategory
- func (rr *RuleResultSet) GetWarnCount() int
- func (rr *RuleResultSet) GetWarningsByRuleCategory(category string) []*RuleFunctionResult
- func (rr *RuleResultSet) Len() int
- func (rr *RuleResultSet) Less(i, j int) bool
- func (rr *RuleResultSet) PrepareForSerialization(info *SpecInfo)
- func (rr *RuleResultSet) SortResultsByLineNumber() []*RuleFunctionResult
- func (rr *RuleResultSet) Swap(i, j int)
- type RuleResultsForCategory
- type SearchResult
- type SpecIndex
- func (index *SpecIndex) ExtractComponentsFromRefs(refs []*Reference) []*Reference
- func (index *SpecIndex) ExtractExternalDocuments(node *yaml.Node) []*Reference
- func (index *SpecIndex) ExtractRefs(node, parent *yaml.Node, seenPath []string, level int, poly bool, pName string) []*Reference
- func (index *SpecIndex) FindComponent(componentId string, parent *yaml.Node) *Reference
- func (index *SpecIndex) GetAllCallbacks() map[string]*Reference
- func (index *SpecIndex) GetAllCombinedReferences() map[string]*Reference
- func (index *SpecIndex) GetAllDescriptions() []*DescriptionReference
- func (index *SpecIndex) GetAllDescriptionsCount() int
- func (index *SpecIndex) GetAllEnums() []*EnumReference
- func (index *SpecIndex) GetAllExamples() map[string]*Reference
- func (index *SpecIndex) GetAllExternalDocuments() map[string]*Reference
- func (index *SpecIndex) GetAllHeaders() map[string]*Reference
- func (index *SpecIndex) GetAllLinks() map[string]*Reference
- func (index *SpecIndex) GetAllOperationsServers() map[string]map[string][]*Reference
- func (index *SpecIndex) GetAllParameters() map[string]*Reference
- func (index *SpecIndex) GetAllParametersFromOperations() map[string]map[string]map[string]*Reference
- func (index *SpecIndex) GetAllPaths() map[string]map[string]*Reference
- func (index *SpecIndex) GetAllReferences() map[string]*Reference
- func (index *SpecIndex) GetAllRequestBodies() map[string]*Reference
- func (index *SpecIndex) GetAllResponses() map[string]*Reference
- func (index *SpecIndex) GetAllRootServers() []*Reference
- func (index *SpecIndex) GetAllSchemas() map[string]*Reference
- func (index *SpecIndex) GetAllSecuritySchemes() map[string]*Reference
- func (index *SpecIndex) GetAllSequencedReferences() []*Reference
- func (index *SpecIndex) GetAllSummaries() []*DescriptionReference
- func (index *SpecIndex) GetAllSummariesCount() int
- func (index *SpecIndex) GetComponentParameterCount() int
- func (index *SpecIndex) GetComponentSchemaCount() int
- func (index *SpecIndex) GetDiscoveredReferences() map[string]*Reference
- func (index *SpecIndex) GetGlobalLinksCount() int
- func (index *SpecIndex) GetGlobalTagsCount() int
- func (index *SpecIndex) GetGlobalTagsNode() *yaml.Node
- func (index *SpecIndex) GetInlineDuplicateParamCount() int
- func (index *SpecIndex) GetInlineOperationDuplicateParameters() map[string][]*Reference
- func (index *SpecIndex) GetInlineUniqueParamCount() int
- func (index *SpecIndex) GetLinesWithReferences() map[int]bool
- func (index *SpecIndex) GetMappedReferences() map[string]*Reference
- func (index *SpecIndex) GetMappedReferencesSequenced() []*ReferenceMapped
- func (index *SpecIndex) GetOperationCount() int
- func (index *SpecIndex) GetOperationParameterReferences() map[string]map[string]map[string]*Reference
- func (index *SpecIndex) GetOperationParametersIndexErrors() []*IndexingError
- func (index *SpecIndex) GetOperationTags() map[string]map[string][]*Reference
- func (index *SpecIndex) GetOperationTagsCount() int
- func (index *SpecIndex) GetOperationsParameterCount() int
- func (index *SpecIndex) GetParametersNode() *yaml.Node
- func (index *SpecIndex) GetPathCount() int
- func (index *SpecIndex) GetPathsNode() *yaml.Node
- func (index *SpecIndex) GetPolyAllOfReferences() []*Reference
- func (index *SpecIndex) GetPolyAnyOfReferences() []*Reference
- func (index *SpecIndex) GetPolyOneOfReferences() []*Reference
- func (index *SpecIndex) GetPolyReferences() map[string]*Reference
- func (index *SpecIndex) GetRawReferenceCount() int
- func (index *SpecIndex) GetReferencesWithSiblings() map[string]*Reference
- func (index *SpecIndex) GetRefsByLine() map[string]map[int]bool
- func (index *SpecIndex) GetRootNode() *yaml.Node
- func (index *SpecIndex) GetRootSecurityNode() *yaml.Node
- func (index *SpecIndex) GetRootSecurityReferences() []*Reference
- func (index *SpecIndex) GetRootServersNode() *yaml.Node
- func (index *SpecIndex) GetSchemasNode() *yaml.Node
- func (index *SpecIndex) GetTotalTagsCount() int
- type SpecInfo
Constants ¶
const ( CategoryExamples = "examples" CategoryOperations = "operations" CategoryInfo = "information" CategoryDescriptions = "descriptions" CategorySchemas = "schemas" CategorySecurity = "security" CategoryTags = "tags" CategoryValidation = "validation" CategoryAll = "all" )
const ( OAS2 = "oas2" OAS3 = "oas3" OAS31 = "oas3_1" )
Variables ¶
var AllFormats = []string{OAS3, OAS31, OAS2}
var OAS2Format = []string{OAS2}
var OAS3AllFormat = []string{OAS3, OAS31}
var OAS3Format = []string{OAS3}
var OAS3_1Format = []string{OAS31}
var OpenAPI2SchemaData string
var OpenAPI3SchemaData string
var RuleCategories = make(map[string]*RuleCategory)
var RuleCategoriesOrdered []*RuleCategory
Functions ¶
func AreValuesCorrectlyTyped ¶
AreValuesCorrectlyTyped will look through an array of unknown values and check they match against the supplied type as a string. The return value is empty if everything is OK, or it contains failures in the form of a value as a key and a message as to why it's not valid
func CheckEnumForDuplicates ¶
func CheckEnumForDuplicates(seq []*yaml.Node) []*yaml.Node
CheckEnumForDuplicates will check an array of nodes to check if there are any duplicates.
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 CircularReferenceResult ¶
type CircularReferenceResult struct { Journey []*Reference JourneyString string Start *Reference LoopIndex int LoopPoint *Reference }
CircularReferenceResult contains a circular reference found when traversing the graph.
type DescriptionReference ¶
DescriptionReference holds data about a description that was found and where it was found.
type EnumReference ¶
type EnumReference struct { Node *yaml.Node Type *yaml.Node Path string }
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 ExternalLookupFunction ¶
type ExternalLookupFunction func(id string) (foundNode *yaml.Node, rootNode *yaml.Node, lookupError error)
ExternalLookupFunction is for lookup functions that take a JSONSchema reference and tries to find that node in the URI based document. Decides if the reference is local, remote or in a file.
type IndexingError ¶
IndexingError holds data about something that went wrong during indexing.
type Reference ¶
type Reference struct { Definition string Name string Node *yaml.Node ParentNode *yaml.Node Resolved bool Circular bool Seen bool Path string // this won't always be available. }
Reference is a wrapper around *yaml.Node results to make things more manageable when performing algorithms on data models. the *yaml.Node def is just a bit too low level for tracking state.
type ReferenceMapped ¶
ReferenceMapped is a helper struct for mapped references put into sequence (we lose the key)
type Rule ¶
type Rule struct { Id string `json:"id,omitempty" yaml:"id,omitempty"` Description string `json:"description,omitempty" yaml:"description,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"` }
Rule is a structure that represents a rule as part of a ruleset.
func (*Rule) GetSeverityAsIntValue ¶
GetSeverityAsIntValue will return the severity state of the rule as an integer. If the severity is not known then -1 is returned.
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 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 GetSchema() RuleFunctionSchema }
RuleFunction is any compatible structure that can be used to run vacuum rules.
type RuleFunctionContext ¶
type RuleFunctionContext struct { RuleAction *RuleAction Rule *Rule Given interface{} // path/s being used by rule. Options interface{} Index *SpecIndex SpecInfo *SpecInfo }
RuleFunctionContext defines a RuleAction, Rule and Options for a RuleFunction being run.
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"` Range reports.Range `json:"range" yaml:"range"` Path string `json:"path" yaml:"path"` RuleId string `json:"ruleId" yaml:"ruleId"` RuleSeverity string `json:"ruleSeverity" yaml:"ruleSeverity"` Rule *Rule `json:"-" yaml:"-"` StartNode *yaml.Node `json:"-" yaml:"-"` EndNode *yaml.Node `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.
func BuildFunctionResultString ¶
func BuildFunctionResultString(message string) RuleFunctionResult
BuildFunctionResultString will create a RuleFunctionResult from a string already parsed into a message.
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.
type RuleFunctionSchema ¶
type RuleFunctionSchema struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` Required []string `json:"required,omitempty" yaml:"required,omitempty"` RequiresField bool `json:"requiresField,omitempty" yaml:"requiresField,omitempty"` Properties []RuleFunctionProperty `json:"properties,omitempty" yaml:"properties,omitempty"` MinProperties int `json:"minProperties,omitempty" yaml:"minProperties,omitempty"` MaxProperties int `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"` ErrorMessage string `json:"errorMessage,omitempty" yaml:"errorMessage,omitempty"` }
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" yaml:"results"` // 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
NewRuleResultSetPointer 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 (*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 *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) 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 ¶
SearchResult represents the position of a result in a specification.
type SpecIndex ¶
type SpecIndex struct {
// contains filtered or unexported fields
}
SpecIndex is a complete pre-computed index of the entire specification. Numbers are pre-calculated and quick direct access to paths, operations, tags are all available. No need to walk the entire node tree in rules, everything is pre-walked if you need it.
func NewSpecIndex ¶
func NewSpecIndex(rootNode *yaml.Node) *SpecIndex
NewSpecIndex will create a new index of an OpenAPI or Swagger spec. It's not resolved or converted into anything other than a raw index of every node for every content type in the specification. This process runs as fast as possible so dependencies looking through the tree, don't need to walk the entire thing over, and over.
func (*SpecIndex) ExtractComponentsFromRefs ¶
ExtractComponentsFromRefs returns located components from references. The returned nodes from here can be used for resolving as they contain the actual object properties.
func (*SpecIndex) ExtractExternalDocuments ¶
ExtractExternalDocuments will extract the number of externalDocs nodes found in the document.
func (*SpecIndex) ExtractRefs ¶
func (index *SpecIndex) ExtractRefs(node, parent *yaml.Node, seenPath []string, level int, poly bool, pName string) []*Reference
ExtractRefs will return a deduplicated slice of references for every unique ref found in the document. The total number of refs, will generally be much higher, you can extract those from GetRawReferenceCount()
func (*SpecIndex) FindComponent ¶
FindComponent will locate a component by its reference, returns nil if nothing is found. This method will recurse through remote, local and file references. For each new external reference a new index will be created. These indexes can then be traversed recursively.
func (*SpecIndex) GetAllCallbacks ¶
GetAllCallbacks will return all links found in the document (under components)
func (*SpecIndex) GetAllCombinedReferences ¶
GetAllCombinedReferences will return the number of unique and polymorphic references discovered.
func (*SpecIndex) GetAllDescriptions ¶
func (index *SpecIndex) GetAllDescriptions() []*DescriptionReference
GetAllDescriptions will return all descriptions found in the document
func (*SpecIndex) GetAllDescriptionsCount ¶
GetAllDescriptionsCount will collect together every single description found in the document
func (*SpecIndex) GetAllEnums ¶
func (index *SpecIndex) GetAllEnums() []*EnumReference
GetAllEnums will return all enums found in the document
func (*SpecIndex) GetAllExamples ¶
GetAllExamples will return all examples found in the document (under components)
func (*SpecIndex) GetAllExternalDocuments ¶
GetAllExternalDocuments will return all external documents found
func (*SpecIndex) GetAllHeaders ¶
GetAllHeaders will return all headers found in the document (under components)
func (*SpecIndex) GetAllLinks ¶
GetAllLinks will return all links found in the document (under components)
func (*SpecIndex) GetAllOperationsServers ¶
GetAllOperationsServers will return all operation overrides for servers.
func (*SpecIndex) GetAllParameters ¶
GetAllParameters will return all parameters found in the document (under components)
func (*SpecIndex) GetAllParametersFromOperations ¶
func (index *SpecIndex) GetAllParametersFromOperations() map[string]map[string]map[string]*Reference
GetAllParametersFromOperations will return all paths indexed in the document
func (*SpecIndex) GetAllPaths ¶
GetAllPaths will return all paths indexed in the document
func (*SpecIndex) GetAllReferences ¶
GetAllReferences will return every reference found in the spec, after being de-duplicated.
func (*SpecIndex) GetAllRequestBodies ¶
GetAllRequestBodies will return all requestBodies found in the document (under components)
func (*SpecIndex) GetAllResponses ¶
GetAllResponses will return all responses found in the document (under components)
func (*SpecIndex) GetAllRootServers ¶
GetAllRootServers will return all root servers defined
func (*SpecIndex) GetAllSchemas ¶
GetAllSchemas will return all schemas found in the document
func (*SpecIndex) GetAllSecuritySchemes ¶
GetAllSecuritySchemes will return all security schemes / definitions found in the document.
func (*SpecIndex) GetAllSequencedReferences ¶
GetAllSequencedReferences will return every reference (in sequence) that was found (non-polymorphic)
func (*SpecIndex) GetAllSummaries ¶
func (index *SpecIndex) GetAllSummaries() []*DescriptionReference
GetAllSummaries will return all summaries found in the document
func (*SpecIndex) GetAllSummariesCount ¶
GetAllSummariesCount will collect together every single summary found in the document
func (*SpecIndex) GetComponentParameterCount ¶
GetComponentParameterCount returns the number of parameter components defined
func (*SpecIndex) GetComponentSchemaCount ¶
GetComponentSchemaCount will return the number of schemas located in the 'components' or 'definitions' node.
func (*SpecIndex) GetDiscoveredReferences ¶
GetDiscoveredReferences will return all unique references found in the spec
func (*SpecIndex) GetGlobalLinksCount ¶
GetGlobalLinksCount for each response of each operation method, multiple links can be defined
func (*SpecIndex) GetGlobalTagsCount ¶
GetGlobalTagsCount will return the number of tags found in the top level 'tags' node of the document.
func (*SpecIndex) GetGlobalTagsNode ¶
func (index *SpecIndex) GetGlobalTagsNode() *yaml.Node
GetGlobalTagsNode returns document root node.
func (*SpecIndex) GetInlineDuplicateParamCount ¶
GetInlineDuplicateParamCount returns the number of inline duplicate parameters (operation params)
func (*SpecIndex) GetInlineOperationDuplicateParameters ¶
GetInlineOperationDuplicateParameters will return a map of duplicates located in operation parameters.
func (*SpecIndex) GetInlineUniqueParamCount ¶
GetInlineUniqueParamCount returns the number of unique inline parameters (operation params)
func (*SpecIndex) GetLinesWithReferences ¶ added in v0.0.2
GetLinesWithReferences will return a map of lines that have a $ref
func (*SpecIndex) GetMappedReferences ¶
GetMappedReferences will return all references that were mapped successfully to actual property nodes. this collection is completely unsorted, traversing it may produce random results when resolving it and encountering circular references can change results depending on where in the collection the resolver started its journey through the index.
func (*SpecIndex) GetMappedReferencesSequenced ¶
func (index *SpecIndex) GetMappedReferencesSequenced() []*ReferenceMapped
GetMappedReferencesSequenced will return all references that were mapped successfully to nodes, performed in sequence as they were read in from the document.
func (*SpecIndex) GetOperationCount ¶
GetOperationCount returns the number of operations (for all paths) located in the document
func (*SpecIndex) GetOperationParameterReferences ¶
func (index *SpecIndex) GetOperationParameterReferences() map[string]map[string]map[string]*Reference
GetOperationParameterReferences will return all references to operation parameters
func (*SpecIndex) GetOperationParametersIndexErrors ¶
func (index *SpecIndex) GetOperationParametersIndexErrors() []*IndexingError
GetOperationParametersIndexErrors any errors that occurred when indexing operation parameters
func (*SpecIndex) GetOperationTags ¶
GetOperationTags will return all references to all tags found in operations.
func (*SpecIndex) GetOperationTagsCount ¶
GetOperationTagsCount will return the number of operation tags found (tags referenced in operations)
func (*SpecIndex) GetOperationsParameterCount ¶
GetOperationsParameterCount returns the number of parameters defined in paths and operations. this method looks in top level (path level) and inside each operation (get, post etc.). Parameters can be hiding within multiple places.
func (*SpecIndex) GetParametersNode ¶
func (index *SpecIndex) GetParametersNode() *yaml.Node
GetParametersNode will return the schema's node found in the spec
func (*SpecIndex) GetPathCount ¶
GetPathCount will return the number of paths found in the spec
func (*SpecIndex) GetPathsNode ¶
func (index *SpecIndex) GetPathsNode() *yaml.Node
GetPathsNode returns document root node.
func (*SpecIndex) GetPolyAllOfReferences ¶
GetPolyAllOfReferences will return every 'allOf' polymorphic reference in the doc
func (*SpecIndex) GetPolyAnyOfReferences ¶
GetPolyAnyOfReferences will return every 'anyOf' polymorphic reference in the doc
func (*SpecIndex) GetPolyOneOfReferences ¶
GetPolyOneOfReferences will return every 'allOf' polymorphic reference in the doc
func (*SpecIndex) GetPolyReferences ¶
GetPolyReferences will return every polymorphic reference in the doc
func (*SpecIndex) GetRawReferenceCount ¶
GetRawReferenceCount will return the number of raw references located in the document.
func (*SpecIndex) GetReferencesWithSiblings ¶
GetReferencesWithSiblings will return a map of all the references with sibling nodes (illegal)
func (*SpecIndex) GetRefsByLine ¶ added in v0.0.2
GetRefsByLine will return all references and the lines at which they were found.
func (*SpecIndex) GetRootNode ¶
func (index *SpecIndex) GetRootNode() *yaml.Node
GetRootNode returns document root node.
func (*SpecIndex) GetRootSecurityNode ¶
func (index *SpecIndex) GetRootSecurityNode() *yaml.Node
GetRootSecurityNode will return the root security node
func (*SpecIndex) GetRootSecurityReferences ¶
GetRootSecurityReferences will return all root security settings
func (*SpecIndex) GetRootServersNode ¶
func (index *SpecIndex) GetRootServersNode() *yaml.Node
GetRootServersNode will return the root servers node
func (*SpecIndex) GetSchemasNode ¶
func (index *SpecIndex) GetSchemasNode() *yaml.Node
GetSchemasNode will return the schema's node found in the spec
func (*SpecIndex) GetTotalTagsCount ¶
GetTotalTagsCount will return the number of global and operation tags found that are unique.
type SpecInfo ¶
type SpecInfo struct { SpecType string `json:"type"` Version string `json:"version"` SpecFormat string `json:"format"` SpecFileType string `json:"fileType"` RootNode *yaml.Node `json:"-"` // reference to the root node of the spec. SpecBytes *[]byte `json:"bytes"` // the original bytes SpecJSONBytes *[]byte `json:"-"` // original bytes converted to JSON SpecJSON *map[string]interface{} `json:"-"` // standard JSON map of original bytes Error error `json:"-"` // something go wrong? APISchema gojsonschema.JSONLoader `json:"-"` // API Schema for supplied spec type (2 or 3) Generated time.Time `json:"-"` // contains filtered or unexported fields }
SpecInfo represents information about a supplied specification.
func ExtractSpecInfo ¶
ExtractSpecInfo will look at a supplied OpenAPI specification, and return a *SpecInfo pointer, or an error if the spec cannot be parsed correctly.
func (SpecInfo) GetJSONParsingChannel ¶
GetJSONParsingChannel returns a channel that will close once async JSON parsing is completed. This is required as rules may start executing before we're even done reading in the spec to JSON.