schema

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(input map[string]interface{}, obj interface{}) error

Decode decodes a map into an object

func DecodeString

func DecodeString(input string, obj interface{}) error

DecodeString decodes a string into an object

func GetKey added in v0.1.2

func GetKey(input map[string]interface{}, key string) (interface{}, bool)

func ReadByTag added in v0.1.2

func ReadByTag(obj interface{}, target string) []string

func ValidateRequired added in v0.1.2

func ValidateRequired(input map[string]interface{}, obj interface{}) error

Types

type Array

type Array struct {
	Elem Type
}

Array is an array of objects

func (*Array) Type

func (a *Array) Type() string

Type implements the Type interface

type Field

type Field struct {
	Type Type

	// Computed describes whether the field is a status
	Computed bool

	// Required specifies if the field is required
	Required bool
}

Field is a field in a record

type Map

type Map struct {
	Elem Type
}

Map is a map<string, interface{}> without specific types

func (*Map) Type

func (m *Map) Type() string

Type implements the Type interface

type Record

type Record struct {
	Fields map[string]*Field
}

Record is an object with several values

func (*Record) OpenAPIV3

func (s *Record) OpenAPIV3() interface{}

OpenAPIV3 returns the OpenApi v3 representation of the schema

func (*Record) OpenAPIV3JSON

func (s *Record) OpenAPIV3JSON() ([]byte, error)

OpenAPIV3JSON creates the OpenAPIv3 spec for the Schema in JSON format

func (*Record) OpenAPIV3Yaml

func (s *Record) OpenAPIV3Yaml() ([]byte, error)

OpenAPIV3Yaml creates the OpenAPIv3 spec for the Schema in YAML format

func (*Record) Type

func (r *Record) Type() string

Type implements the Type interface

type ScalarType

type ScalarType int

ScalarType is a scalar type

const (
	// TypeString is a string type
	TypeString ScalarType = iota

	// TypeInt is a int type
	TypeInt

	// TypeBool is a bool type
	TypeBool
)

func (ScalarType) String

func (i ScalarType) String() string

func (ScalarType) Type

func (s ScalarType) Type() string

Type implements the Type interface

type Schema

type Schema struct {
	Spec   *Record
	Status *Record
}

Schema is an OpenAPIv3 schema of a resource

func GenerateSchema

func GenerateSchema(s interface{}) (*Schema, error)

GenerateSchema generates an OpenAPIv3 schema

type Type

type Type interface {
	Type() string
}

Type describes a valid type for the schema

Jump to

Keyboard shortcuts

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