spechelper

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OASVersion

type OASVersion int

OASVersion defines a OpenAPI/Swagger major version.

const (
	OASVersion2 OASVersion = 2
	OASVersion3 OASVersion = 3
)

func (OASVersion) String

func (v OASVersion) String() string

String implements the fmt.Stringer interface.

Returns a friendly name representation of the version number.

type SpecHelper

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

SpecHelper wraps the kin-openapi to add additional functions used for validating specifications.

func New

func New() (*SpecHelper, error)

New instantiates a new SpecHelper, that can parse OpenAPI or Swagger specification, either in YAML or JSON.

func (*SpecHelper) Load

func (h *SpecHelper) Load(rawSpec []byte) (processedSpec *openapi3.T, originalVersion OASVersion, err error)

Load unmarshalls the provided YAML/JSON & converts it to the typed OpenAPI v3 specification.

For OpenAPI v3 specs, we simply just need to load the specification in.

For Swagger v2 specs, we'll load it in as v2 first, and then convert to v3. The conversion takes place as kin-openapi has no way to validate OpenAPI v3 specifications.

func (*SpecHelper) Validate

func (h *SpecHelper) Validate() (err error)

Validate ensures that the underlining OpenAPI/Swagger specification is proper in accordance to what Kong Gateway expects. As-of this writing, this validation logic is far more accurate than what Kong Gateway does itself.

The following configurations are not validated:

  • Security settings
  • Regexes
  • Request/response examples

Our only special sauce here is that circular references within schemas are not allowed, as the oas-validation plugin does not support it as-of this writing.

Jump to

Keyboard shortcuts

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