generate

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SpecParameters  = "parameters"
	SpecRequestBody = "requestBody"
)
View Source
const (
	TypeString  SchemaType = "string"
	TypeNumber  SchemaType = "number"
	TypeInteger SchemaType = "integer"
	TypeBoolean SchemaType = "boolean"
	TypeArray   SchemaType = "array"
	TypeObject  SchemaType = "object"

	FormatDate     SchemaFormat = "date"
	FormatDateTime SchemaFormat = "date-time"
	FormatPassword SchemaFormat = "password"
	FormatByte     SchemaFormat = "byte"
	FormatBinary   SchemaFormat = "binary"
	FormatEmail    SchemaFormat = "email"
	FormatUuid     SchemaFormat = "uuid"
	FormatUri      SchemaFormat = "uri"
	FormatHostname SchemaFormat = "hostname"
	FormatIPv4     SchemaFormat = "ipv4"
	FormatIPv6     SchemaFormat = "ipv6"
)

Variables

View Source
var SchemaFormatToRule = map[SchemaFormat]RuleFormat{
	FormatDate:     "ISO8601",
	FormatDateTime: "ISO8601",
	FormatEmail:    "email",
	FormatUuid:     "uuid",
	FormatUri:      "url",
	FormatIPv4:     "ip_v4",
	FormatIPv6:     "ip_v6",
}
View Source
var SchemaTypeToRule = map[SchemaType]RuleType{
	TypeString:  "string",
	TypeNumber:  "numeric",
	TypeInteger: "integer",
	TypeBoolean: "boolean",
}

Functions

func Generate

func Generate(validators *[]Validator, spec yaml.MapSlice) []string

func GetRequestBodyParameters

func GetRequestBodyParameters(data yaml.MapSlice, path []string) map[string]*Parameter

Types

type Parameter

type Parameter struct {
	Name        string
	In          string
	Required    bool
	Description string
	Type        string
	ArrayType   string
	Format      string
	Pattern     string
	Min         *float64
	Max         *float64
	IsObject    bool
}

func (*Parameter) Rules

func (p *Parameter) Rules() (rules Rules)

type RuleFormat

type RuleFormat string

type RuleNumeric

type RuleNumeric *float64

type RuleType

type RuleType string

type Rules

type Rules []string

func (Rules) String

func (r Rules) String() string

type SchemaFormat

type SchemaFormat string

type SchemaType

type SchemaType string

type Validator

type Validator struct {
	Name       string
	Parameters map[string]*Parameter
}

Jump to

Keyboard shortcuts

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