openapi

package
v0.0.53 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllOperationsJSONPath

func GetAllOperationsJSONPath() string

GetAllOperationsJSONPath wil return a string that can be used as a query for extracting all OpenAPI operations.

func GetComponentsFromRoot

func GetComponentsFromRoot(nodes []*yaml.Node) []*yaml.Node

GetComponentsFromRoot will extract all operation (paths nodes) from the root of an OpenAPI document.

func GetOperationsFromRoot

func GetOperationsFromRoot(nodes []*yaml.Node) []*yaml.Node

GetOperationsFromRoot will extract all operation (paths nodes) from the root of an OpenAPI document.

func GetTagsFromRoot

func GetTagsFromRoot(nodes []*yaml.Node) []*yaml.Node

GetTagsFromRoot will extract all tag nodes from the root of an OpenAPI document.

Types

type APIServers

type APIServers struct{}

APIServers checks that each operation only has a single tag.

func (APIServers) GetSchema

func (as APIServers) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the APIServers rule.

func (APIServers) RunRule

func (as APIServers) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the APIServers rule, based on supplied context and a supplied []*yaml.Node slice.

type AmbiguousPaths added in v0.0.12

type AmbiguousPaths struct {
}

AmbiguousPaths will determine if paths can be confused by a compiler.

func (AmbiguousPaths) GetSchema added in v0.0.12

func (ap AmbiguousPaths) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the AmbiguousPaths rule.

func (AmbiguousPaths) RunRule added in v0.0.12

func (ap AmbiguousPaths) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the AmbiguousPaths rule, based on supplied context and a supplied []*yaml.Node slice.

type ComponentDescription

type ComponentDescription struct {
}

ComponentDescription will check through all components and determine if they are correctly described

func (ComponentDescription) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the ComponentDescription rule.

func (ComponentDescription) RunRule

func (cd ComponentDescription) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the ComponentDescription rule, based on supplied context and a supplied []*yaml.Node slice.

type DescriptionDuplication

type DescriptionDuplication struct {
}

DescriptionDuplication will check if a description has been duplicated (copy/paste)

func (DescriptionDuplication) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the DescriptionDuplication rule.

func (DescriptionDuplication) RunRule

func (dd DescriptionDuplication) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the DescriptionDuplication rule, based on supplied context and a supplied []*yaml.Node slice.

type DuplicatedEnum

type DuplicatedEnum struct {
}

DuplicatedEnum will check enum values match the types provided

func (DuplicatedEnum) GetSchema

func (de DuplicatedEnum) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the DuplicatedEnum rule.

func (DuplicatedEnum) RunRule

func (de DuplicatedEnum) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the DuplicatedEnum rule, based on supplied context and a supplied []*yaml.Node slice.

type Examples

type Examples struct {
}

Examples is a rule that checks that examples are being correctly used.

func (Examples) GetSchema

func (ex Examples) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the TagDefined rule.

func (Examples) RunRule

func (ex Examples) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the Examples rule, based on supplied context and a supplied []*yaml.Node slice.

type FormDataConsumeCheck

type FormDataConsumeCheck struct {
}

FormDataConsumeCheck will check enum values match the types provided

func (FormDataConsumeCheck) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the FormDataConsumeCheck rule.

func (FormDataConsumeCheck) RunRule

func (fd FormDataConsumeCheck) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the FormDataConsumeCheck rule, based on supplied context and a supplied []*yaml.Node slice.

type NoEvalInDescriptions

type NoEvalInDescriptions struct {
}

NoEvalInDescriptions will check if a description contains potentially malicious javascript

func (NoEvalInDescriptions) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the NoEvalInDescriptions rule.

func (NoEvalInDescriptions) RunRule

func (ne NoEvalInDescriptions) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the NoEvalInDescriptions rule, based on supplied context and a supplied []*yaml.Node slice.

type NoRefSiblings

type NoRefSiblings struct {
}

NoRefSiblings will check for anything placed next to a $ref (like a description) and will throw some shade if something is found. This rule is there to prevent us from adding useless properties to a $ref child.

func (NoRefSiblings) GetSchema

func (nrs NoRefSiblings) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the NoRefSiblings rule.

func (NoRefSiblings) RunRule

func (nrs NoRefSiblings) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the NoRefSiblings rule, based on supplied context and a supplied []*yaml.Node slice.

type OAS2Discriminator

type OAS2Discriminator struct{}

OAS2Discriminator checks swagger schemas are using discriminators properly.

func (OAS2Discriminator) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the OperationSingleTag rule.

func (OAS2Discriminator) RunRule

func (od OAS2Discriminator) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the OperationSingleTag rule, based on supplied context and a supplied []*yaml.Node slice.

type OAS2OperationSecurityDefined

type OAS2OperationSecurityDefined struct {
}

OAS2OperationSecurityDefined will check to make sure operation security has been defined correctly for swagger docs.

func (OAS2OperationSecurityDefined) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the UniqueOperationId rule.

func (OAS2OperationSecurityDefined) RunRule

func (sd OAS2OperationSecurityDefined) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the OAS2OperationSecurityDefined rule, based on supplied context and a supplied []*yaml.Node slice.

type OASSchema

type OASSchema struct {
}

OASSchema will check that the document is a valid OpenAPI schema.

func (OASSchema) GetSchema

func (os OASSchema) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the OASSchema rule.

func (OASSchema) RunRule

func (os OASSchema) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the OASSchema rule, based on supplied context and a supplied []*yaml.Node slice.

type Operation4xResponse added in v0.0.13

type Operation4xResponse struct {
}

Operation4xResponse is a rule that checks if an operation returns a 4xx (user error) code.

func (Operation4xResponse) GetSchema added in v0.0.13

GetSchema returns a model.RuleFunctionSchema defining the schema of the SuccessResponse rule.

func (Operation4xResponse) RunRule added in v0.0.13

func (or Operation4xResponse) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the Operation4xResponse rule, based on supplied context and a supplied []*yaml.Node slice.

type OperationDescription

type OperationDescription struct {
}

OperationDescription will check if an operation has a description, and if the description is useful

func (OperationDescription) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the OperationDescription rule.

func (OperationDescription) RunRule

func (od OperationDescription) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the OperationDescription rule, based on supplied context and a supplied []*yaml.Node slice.

type OperationId

type OperationId struct {
}

OperationId is a rule that will check if each operation provides an operationId

func (OperationId) GetSchema

func (oId OperationId) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the OperationId rule.

func (OperationId) RunRule

func (oId OperationId) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the OperationId rule, based on supplied context and a supplied []*yaml.Node slice.

type OperationParameters

type OperationParameters struct {
}

OperationParameters is a rule that checks for valid parameters and parameters combinations

func (OperationParameters) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the OperationParameters rule.

func (OperationParameters) RunRule

func (op OperationParameters) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the OperationParameters rule, based on supplied context and a supplied []*yaml.Node slice.

type OperationSecurityDefined

type OperationSecurityDefined struct {
}

OperationSecurityDefined is a rule that checks operation security against defined global schemes.

func (OperationSecurityDefined) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the OperationSecurityDefined rule.

func (OperationSecurityDefined) RunRule

func (osd OperationSecurityDefined) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the OperationSecurityDefined rule, based on supplied context and a supplied []*yaml.Node slice.

type OperationSingleTag

type OperationSingleTag struct {
}

OperationSingleTag checks that each operation only has a single tag.

func (OperationSingleTag) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the OperationSingleTag rule.

func (OperationSingleTag) RunRule

func (ost OperationSingleTag) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the OperationSingleTag rule, based on supplied context and a supplied []*yaml.Node slice.

type OperationTags

type OperationTags struct{}

OperationTags is a rule that checks operations are using tags and they are not empty.

func (OperationTags) GetSchema

func (ot OperationTags) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the TagDefined rule.

func (OperationTags) RunRule

func (ot OperationTags) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the OperationTags rule, based on supplied context and a supplied []*yaml.Node slice.

type ParameterDescription

type ParameterDescription struct {
}

ParameterDescription will check swagger spec parameters for a description. ($.parameters)

func (ParameterDescription) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the ParameterDescription rule.

func (ParameterDescription) RunRule

func (pd ParameterDescription) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the ParameterDescription rule, based on supplied context and a supplied []*yaml.Node slice.

type PathParameters

type PathParameters struct {
}

PathParameters is a rule that checks path level and operation level parameters for correct paths. The rule is one of the more complex ones, so here is a little detail as to what is happening. -- normalize paths to replace vars with % -- check for duplicate paths based on param placement -- check for duplicate param names in paths -- check for any unknown params (no name) -- check if required is set, that it's set to true only. -- check no duplicate params -- operation paths only -- all params in path must be defined -- all defined path params must be in path.

func (PathParameters) GetSchema

func (pp PathParameters) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the PathParameters rule.

func (PathParameters) RunRule

func (pp PathParameters) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the PathParameters rule, based on supplied context and a supplied []*yaml.Node slice.

type PathsKebabCase added in v0.0.13

type PathsKebabCase struct {
}

PathsKebabCase Checks to ensure each segment of a path is using kebab case.

func (PathsKebabCase) GetSchema added in v0.0.13

func (vp PathsKebabCase) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the VerbsInPath rule.

func (PathsKebabCase) RunRule added in v0.0.13

func (vp PathsKebabCase) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the PathsKebabCase rule, based on supplied context and a supplied []*yaml.Node slice.

type PolymorphicAnyOf

type PolymorphicAnyOf struct {
}

PolymorphicAnyOf checks that there is no polymorphism used, in particular 'anyOf'

func (PolymorphicAnyOf) GetSchema

func (pm PolymorphicAnyOf) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the PolymorphicAnyOf rule.

func (PolymorphicAnyOf) RunRule

func (pm PolymorphicAnyOf) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the PolymorphicAnyOf rule, based on supplied context and a supplied []*yaml.Node slice.

type PolymorphicOneOf

type PolymorphicOneOf struct {
}

PolymorphicOneOf checks that there is no polymorphism used, in particular 'anyOf'

func (PolymorphicOneOf) GetSchema

func (pm PolymorphicOneOf) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the PolymorphicOneOf rule.

func (PolymorphicOneOf) RunRule

func (pm PolymorphicOneOf) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the PolymorphicOneOf rule, based on supplied context and a supplied []*yaml.Node slice.

type PostResponseSuccess

type PostResponseSuccess struct {
}

PostResponseSuccess is a rule that will check if a post operations contain a successful response code or not.

func (PostResponseSuccess) GetSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the PostResponseSuccess rule.

func (PostResponseSuccess) RunRule

func (prs PostResponseSuccess) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the PostResponseSuccess rule, based on supplied context and a supplied []*yaml.Node slice.

type SuccessResponse

type SuccessResponse struct {
}

SuccessResponse is a rule that checks if an operation returns a code >= 200 and <= 400

func (SuccessResponse) GetSchema

func (sr SuccessResponse) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the SuccessResponse rule.

func (SuccessResponse) RunRule

func (sr SuccessResponse) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the SuccessResponse rule, based on supplied context and a supplied []*yaml.Node slice.

type TagDefined

type TagDefined struct{}

TagDefined is a rule that checks if an operation uses a tag, it's also defined in the global tag definitions.

func (TagDefined) GetSchema

func (td TagDefined) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the TagDefined rule.

func (TagDefined) RunRule

func (td TagDefined) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the TagDefined rule, based on supplied context and a supplied []*yaml.Node slice.

type TypedEnum

type TypedEnum struct{}

TypedEnum will check enum values match the types provided

func (TypedEnum) GetSchema

func (te TypedEnum) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the TypedEnum rule.

func (TypedEnum) RunRule

func (te TypedEnum) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the TypedEnum rule, based on supplied context and a supplied []*yaml.Node slice.

type UniqueOperationId

type UniqueOperationId struct {
}

UniqueOperationId is a rule that will check if each operation provides an operationId, as well as making sure that all the operationId's in the spec are unique.

func (UniqueOperationId) GetSchema

func (oId UniqueOperationId) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the UniqueOperationId rule.

func (UniqueOperationId) RunRule

func (oId UniqueOperationId) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the UniqueOperationId rule, based on supplied context and a supplied []*yaml.Node slice.

type UnusedComponent

type UnusedComponent struct {
}

UnusedComponent will check if a component or definition has been created, but it's not used anywhere by anything.

func (UnusedComponent) GetSchema

func (uc UnusedComponent) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the UnusedComponent rule.

func (UnusedComponent) RunRule

func (uc UnusedComponent) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the UnusedComponent rule, based on supplied context and a supplied []*yaml.Node slice.

type VerbsInPaths added in v0.0.13

type VerbsInPaths struct {
}

VerbsInPaths Checks to make sure that no HTTP verbs have been used

func (VerbsInPaths) GetSchema added in v0.0.13

func (vp VerbsInPaths) GetSchema() model.RuleFunctionSchema

GetSchema returns a model.RuleFunctionSchema defining the schema of the VerbsInPath rule.

func (VerbsInPaths) RunRule added in v0.0.13

func (vp VerbsInPaths) RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult

RunRule will execute the VerbsInPath rule, based on supplied context and a supplied []*yaml.Node slice.

Jump to

Keyboard shortcuts

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