openapi3lint

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 15 Imported by: 0

README

OpenAPI 3 Lint

This is a Go-based OpenAPI 3 spec linter.

Why Spectrum Linter?

There are a few linters available.

The reasons this exists are:

  1. written in Go so its easy to use/modify for Go devs
  2. policy violations are grouped by rule, vs. line number for easier mitigation
  3. policy violations are identified by JSON Schema pointere vs. line number for easier identification when using merged files

Other Linters

There are other linters available. To date, Spectrum Linter hasn't beeen inspired by any of them, though there is a desire and effort to align on rule names and potentially rule definitions to achieve similar behavior.

  1. Mermade OAS-Kit - https://github.com/mermade/oas-kit
  2. https://mermade.github.io/oas-kit/default-rules.html
  3. https://mermade.github.io/oas-kit/linter-rules.html
  4. Spectral - https://github.com/stoplightio/spectral
  5. Inspired by Speccy
  6. Speccy - https://github.com/wework/speccy
  7. Inspired by OAS-Kit

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateRules

func ValidateRules(rules map[string]Rule) error

Types

type Policy

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

func (*Policy) AddRule

func (pol *Policy) AddRule(rule Rule, errorOnCollision bool) error

func (*Policy) RuleNames

func (pol *Policy) RuleNames() []string

func (*Policy) ValidateSpec

func (pol *Policy) ValidateSpec(spec *oas3.Swagger, pointerBase, filterSeverity string) (*lintutil.PolicyViolationsSets, error)

type PolicyConfig

type PolicyConfig struct {
	Rules map[string]RuleConfig `json:"rules,omitempty"`
}

func NewPolicyConfigFile

func NewPolicyConfigFile(filename string) (PolicyConfig, error)

func (*PolicyConfig) StandardPolicy

func (cfg *PolicyConfig) StandardPolicy() (Policy, error)

type Rule

type Rule interface {
	Name() string
	Scope() string
	Severity() string
	ProcessSpec(spec *oas3.Swagger, pointerBase string) *lintutil.PolicyViolationsSets
	ProcessOperation(spec *oas3.Swagger, op *oas3.Operation, opPointer, path, method string) []lintutil.PolicyViolation
}

type RuleConfig

type RuleConfig struct {
	Severity string `json:"severity"`
}

type RulesMap

type RulesMap map[string]Rule

Directories

Path Synopsis
cmd/oas3lint command

Jump to

Keyboard shortcuts

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