Documentation ¶
Index ¶
- Constants
- Variables
- func GetAPIServersRule() *model.Rule
- func GetComponentDescriptionsRule() *model.Rule
- func GetContactPropertiesRule() *model.Rule
- func GetDescriptionDuplicationRule() *model.Rule
- func GetDuplicatedEntryInEnumRule() *model.Rule
- func GetGlobalOperationTagsRule() *model.Rule
- func GetInfoContactRule() *model.Rule
- func GetInfoDescriptionRule() *model.Rule
- func GetInfoLicenseRule() *model.Rule
- func GetInfoLicenseUrlRule() *model.Rule
- func GetNoEvalInMarkdownRule() *model.Rule
- func GetNoRefSiblingsRule() *model.Rule
- func GetNoScriptTagsInMarkdownRule() *model.Rule
- func GetNoVerbsInPathRule() *model.Rule
- func GetOAS2APIHostRule() *model.Rule
- func GetOAS2APISchemesRule() *model.Rule
- func GetOAS2DiscriminatorRule() *model.Rule
- func GetOAS2ExamplesRule() *model.Rule
- func GetOAS2FormDataConsumesRule() *model.Rule
- func GetOAS2HostNotExampleRule() *model.Rule
- func GetOAS2HostTrailingSlashRule() *model.Rule
- func GetOAS2ParameterDescriptionRule() *model.Rule
- func GetOAS2PolymorphicAnyOfRule() *model.Rule
- func GetOAS2PolymorphicOneOfRule() *model.Rule
- func GetOAS2SchemaRule() *model.Rule
- func GetOAS2SecurityDefinedRule() *model.Rule
- func GetOAS2UnusedComponentRule() *model.Rule
- func GetOAS3ExamplesRule() *model.Rule
- func GetOAS3HostNotExampleRule() *model.Rule
- func GetOAS3HostTrailingSlashRule() *model.Rule
- func GetOAS3ParameterDescriptionRule() *model.Rule
- func GetOAS3SchemaRule() *model.Rule
- func GetOAS3SecurityDefinedRule() *model.Rule
- func GetOAS3UnusedComponentRule() *model.Rule
- func GetOpenApiTagsAlphabeticalRule() *model.Rule
- func GetOpenApiTagsRule() *model.Rule
- func GetOperationDescriptionRule() *model.Rule
- func GetOperationErrorResponseRule() *model.Rule
- func GetOperationIdRule() *model.Rule
- func GetOperationIdUniqueRule() *model.Rule
- func GetOperationIdValidInUrlRule() *model.Rule
- func GetOperationParametersRule() *model.Rule
- func GetOperationSingleTagRule() *model.Rule
- func GetOperationSuccessResponseRule() *model.Rule
- func GetOperationTagsRule() *model.Rule
- func GetPathDeclarationsMustExistRule() *model.Rule
- func GetPathNoTrailingSlashRule() *model.Rule
- func GetPathNotIncludeQueryRule() *model.Rule
- func GetPathParamsRule() *model.Rule
- func GetPathsKebabCaseRule() *model.Rule
- func GetTagDescriptionRequiredRule() *model.Rule
- func GetTypedEnumRule() *model.Rule
- func LoadRulesetSchema() gojsonschema.JSONLoader
- func NoAmbiguousPaths() *model.Rule
- type RuleSet
- type RuleSets
Constants ¶
const ( SpectralOpenAPI = "spectral:oas" SpectralRecommended = "recommended" SpectralAll = "all" SpectralOff = "off" )
Variables ¶
var AllOperationsPath = fmt.Sprintf("%s%s", allPaths, allOperations)
Functions ¶
func GetAPIServersRule ¶
GetAPIServersRule checks to make sure there is a valid 'servers' definition in the document.
func GetComponentDescriptionsRule ¶
GetComponentDescriptionsRule will check all components for description problems.
func GetContactPropertiesRule ¶
GetContactPropertiesRule will return a rule configured to look at contact properties of a spec. it uses the in-built 'truthy' function
func GetDescriptionDuplicationRule ¶
GetDescriptionDuplicationRule will check if any descriptions have been copy/pasted or duplicated. all descriptions should be unique, otherwise what is the point?
func GetDuplicatedEntryInEnumRule ¶
GetDuplicatedEntryInEnumRule will check that enums used are not duplicates
func GetGlobalOperationTagsRule ¶
GetGlobalOperationTagsRule will check that an operation tag exists in top level tags
func GetInfoContactRule ¶
GetInfoContactRule Will return a rule that uses the truthy function to check if the info object contains a contact object
func GetInfoDescriptionRule ¶
GetInfoDescriptionRule Will return a rule that uses the truthy function to check if the info object contains a description
func GetInfoLicenseRule ¶
GetInfoLicenseRule will return a rule that uses the truthy function to check if the info object contains a license
func GetInfoLicenseUrlRule ¶
GetInfoLicenseUrlRule will return a rule that uses the truthy function to check if the info object contains a license with an url that is set.
func GetNoEvalInMarkdownRule ¶
GetNoEvalInMarkdownRule will return a rule that uses the pattern function to check if there is no eval statements markdown used in descriptions
func GetNoRefSiblingsRule ¶
GetNoRefSiblingsRule will check that there are no sibling nodes next to a $ref (which is technically invalid)
func GetNoScriptTagsInMarkdownRule ¶
GetNoScriptTagsInMarkdownRule will return a rule that uses the pattern function to check if there is no script tags used in descriptions and the title.
func GetNoVerbsInPathRule ¶ added in v0.0.13
GetNoVerbsInPathRule will check all paths to make sure not HTTP verbs have been used as a segment.
func GetOAS2APIHostRule ¶
GetOAS2APIHostRule will check swagger specs for the host property being set.
func GetOAS2APISchemesRule ¶
GetOAS2APISchemesRule uses the schema function to check if swagger has schemes and that it's an array with at least one item.
func GetOAS2DiscriminatorRule ¶
GetOAS2DiscriminatorRule will check swagger schemas to ensure they are using discriminations correctly.
func GetOAS2ExamplesRule ¶
GetOAS2ExamplesRule will check the entire spec for correct example use.
func GetOAS2FormDataConsumesRule ¶
GetOAS2FormDataConsumesRule will check that an "application/x-www-form-urlencoded" or "multipart/form-data" is defined in the 'consumes' node for in any parameters that use in formData.
func GetOAS2HostNotExampleRule ¶
GetOAS2HostNotExampleRule checks to make sure that example.com is not being used as a host. TODO: how common is this? should we keep it? change it?
func GetOAS2HostTrailingSlashRule ¶
GetOAS2HostTrailingSlashRule checks to make sure there is no trailing slash on the host
func GetOAS2ParameterDescriptionRule ¶
GetOAS2ParameterDescriptionRule will check specs to make sure parameters have a description.
func GetOAS2PolymorphicAnyOfRule ¶
GetOAS2PolymorphicAnyOfRule will check that 'anyOf' has not been used in a swagger spec (introduced in 3.0)
func GetOAS2PolymorphicOneOfRule ¶
GetOAS2PolymorphicOneOfRule will check that 'oneOf' has not been used in a swagger spec (introduced in 3.0)
func GetOAS2SchemaRule ¶
GetOAS2SchemaRule will check that the schema is valid for swagger docs.
func GetOAS2SecurityDefinedRule ¶
GetOAS2SecurityDefinedRule will check that security definitions exist and validate for OpenAPI 2
func GetOAS2UnusedComponentRule ¶
GetOAS2UnusedComponentRule will check that there aren't any components anywhere that haven't been used.
func GetOAS3ExamplesRule ¶
GetOAS3ExamplesRule will check the entire spec for correct example use.
func GetOAS3HostNotExampleRule ¶
GetOAS3HostNotExampleRule checks to make sure that example.com is not being used as a host. TODO: how common is this? should we keep it? change it?
func GetOAS3HostTrailingSlashRule ¶ added in v0.0.5
GetOAS3HostTrailingSlashRule checks to make sure there is no trailing slash on the host
func GetOAS3ParameterDescriptionRule ¶
GetOAS3ParameterDescriptionRule will check specs to make sure parameters have a description.
func GetOAS3SchemaRule ¶
GetOAS3SchemaRule will check that the schema is valid for openapi 3+ docs.
func GetOAS3SecurityDefinedRule ¶
GetOAS3SecurityDefinedRule will check that security definitions exist and validate for OpenAPI 3
func GetOAS3UnusedComponentRule ¶
GetOAS3UnusedComponentRule will check that there aren't any components anywhere that haven't been used.
func GetOpenApiTagsAlphabeticalRule ¶
GetOpenApiTagsAlphabeticalRule will return a rule that uses the alphabetical function to check if tags are in alphabetical order
func GetOpenApiTagsRule ¶
GetOpenApiTagsRule uses the schema function to check if there tags exist and that it's an array with at least one item.
func GetOperationDescriptionRule ¶
GetOperationDescriptionRule will return a rule that uses the truthy function to check if an operation has defined a description or not, or does not meet the required length
func GetOperationErrorResponseRule ¶ added in v0.0.13
GetOperationErrorResponseRule will return the rule for checking for a 4xx response defined in operations.
func GetOperationIdRule ¶
GetOperationIdRule will check to make sure that operationIds exist on all operations
func GetOperationIdUniqueRule ¶
GetOperationIdUniqueRule will check to make sure that operationIds are all unique and non-repeating
func GetOperationIdValidInUrlRule ¶
GetOperationIdValidInUrlRule will check id an operationId will be valid when used in an url.
func GetOperationParametersRule ¶
GetOperationParametersRule will check that an operation has valid parameters defined
func GetOperationSingleTagRule ¶
GetOperationSingleTagRule will check to see if an operation has more than a single tag
func GetOperationSuccessResponseRule ¶
GetOperationSuccessResponseRule will check that every operation has a success response defined.
func GetOperationTagsRule ¶
GetOperationTagsRule uses the schema function to check if there tags exist and that it's an array with at least one item.
func GetPathDeclarationsMustExistRule ¶
GetPathDeclarationsMustExistRule will check to make sure there are no empty path variables
func GetPathNoTrailingSlashRule ¶
GetPathNoTrailingSlashRule will make sure that paths don't have trailing slashes
func GetPathNotIncludeQueryRule ¶
GetPathNotIncludeQueryRule checks to ensure paths are not including any query parameters.
func GetPathParamsRule ¶
GetPathParamsRule checks if path params are valid and defined.
func GetPathsKebabCaseRule ¶ added in v0.0.13
GetPathsKebabCaseRule will check that each path segment is kebab-case
func GetTagDescriptionRequiredRule ¶
GetTagDescriptionRequiredRule checks to ensure tags defined have been given a description
func GetTypedEnumRule ¶
GetTypedEnumRule checks to ensure enums are of the specified type
func LoadRulesetSchema ¶
func LoadRulesetSchema() gojsonschema.JSONLoader
LoadRulesetSchema creates a new JSON Schema loader for the RuleSet schema.
func NoAmbiguousPaths ¶ added in v0.0.12
NoAmbiguousPaths will check for paths that are ambiguous with one another
Types ¶
type RuleSet ¶
type RuleSet struct { Description string `json:"description,omitempty" yaml:"description,omitempty"` DocumentationURI string `json:"documentationUrl,omitempty" yaml:"documentationUrl,omitempty"` Formats []string `json:"formats,omitempty" yaml:"formats,omitempty"` RuleDefinitions map[string]interface{} `json:"rules" yaml:"rules"` // this can be either a string, or an entire rule (super annoying, stoplight). Rules map[string]*model.Rule `json:"-" yaml:"-"` Extends interface{} `json:"extends,omitempty" yaml:"extends,omitempty"` // can be string or tuple (again... why stoplight?) // contains filtered or unexported fields }
RuleSet represents a collection of Rule definitions.
func CreateRuleSetFromData ¶
CreateRuleSetFromData will create a new RuleSet instance from either a JSON or YAML input
func CreateRuleSetUsingJSON ¶
CreateRuleSetUsingJSON will create a new RuleSet instance from a JSON byte array
func (*RuleSet) GetExtendsValue ¶
GetExtendsValue returns an array of maps defining which ruleset this one extends. The value can be a single string or an array of tuples, so this normalizes things into a standard structure.
type RuleSets ¶
type RuleSets interface { // GenerateOpenAPIDefaultRuleSet generates a ready to run pointer to a model.RuleSet containing all // OpenAPI rules supported by vacuum. Passing all these rules would be considered a very good quality specification. GenerateOpenAPIDefaultRuleSet() *RuleSet // GenerateOpenAPIRecommendedRuleSet generates a ready to run pointer to a model.RuleSet that contains only // recommended rules (not all rules). Passing all these rules would result in a quality specification GenerateOpenAPIRecommendedRuleSet() *RuleSet // GenerateRuleSetFromSuppliedRuleSet will generate a ready to run ruleset based on a supplied configuration. This // will look for any extensions and apply all rules turned on, turned off and any custom rules. GenerateRuleSetFromSuppliedRuleSet(config *RuleSet) *RuleSet }
RuleSets is used to generate default RuleSets built into vacuum
func BuildDefaultRuleSets ¶
func BuildDefaultRuleSets() RuleSets