datamodel

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 8 Imported by: 33

Documentation

Index

Constants

View Source
const (
	OAS2  = "oas2"
	OAS3  = "oas3"
	OAS31 = "oas3_1"
)

Variables

View Source
var AllFormats = []string{OAS3, OAS31, OAS2}
View Source
var OAS2Format = []string{OAS2}
View Source
var OAS3AllFormat = []string{OAS3, OAS31}
View Source
var OAS3Format = []string{OAS3}
View Source
var OAS3_1Format = []string{OAS31}
View Source
var OpenAPI2SchemaData string
View Source
var OpenAPI3SchemaData string

Functions

func AreValuesCorrectlyTyped

func AreValuesCorrectlyTyped(valType string, values interface{}) map[string]string

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.

Types

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          string                  `json:"-"`     // API Schema for supplied spec type (2 or 3)
	Generated          time.Time               `json:"-"`
	JsonParsingChannel chan bool               `json:"-"`
}

SpecInfo represents information about a supplied specification.

func ExtractSpecInfo

func ExtractSpecInfo(spec []byte) (*SpecInfo, error)

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

func (si SpecInfo) GetJSONParsingChannel() chan bool

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.

Directories

Path Synopsis
2.0
3.0
low
2.0
3.0

Jump to

Keyboard shortcuts

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