generator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SimpleReferences = make(map[string]RefType)

Functions

func GenerateErrors

func GenerateErrors(w io.Writer, errorsRaw []byte)

func GenerateMethods

func GenerateMethods(w, wTest io.Writer, methodsRaw []byte)

func GenerateObjects

func GenerateObjects(w, testW io.Writer, objectsRaw []byte)

func GenerateVersion

func GenerateVersion(w io.Writer, packageRaw []byte)

Types

type AllOf

type AllOf struct {
	Name              string
	Description       string
	Fields            []NestedGenner
	ArrayNestingLevel int

	// fields for nested AllOf
	IsRequired bool
}

func (AllOf) Gen

func (ao AllOf) Gen() (gen string)

func (AllOf) GetName

func (ao AllOf) GetName() string

func (AllOf) TestGen

func (ao AllOf) TestGen() (testGen string)

type Coder

type Coder interface {
	GetCode() int
}

type Enum

type Enum struct {
	Name        string
	Description string
	ValuesType  string
	EnumValues  []interface{}
	EnumNames   []string
	Limits      Limits

	IsRequired        bool
	ArrayNestingLevel int
	// contains filtered or unexported fields
}

func (Enum) Gen

func (e Enum) Gen() (gen string)

func (Enum) GetName

func (e Enum) GetName() string

func (Enum) Param

func (e Enum) Param() (p Param)

func (Enum) TestGen

func (e Enum) TestGen() (testGen string)

type Error

type Error struct {
	Name        string
	Code        int
	Description string
	IsGlobal    bool
	Subcodes    *[]string
	Solution    *string
}

func (Error) Gen

func (e Error) Gen() (gen string)

type ErrorJSON

type ErrorJSON struct {
	Code        int    `json:"code"`
	Description string `json:"description"`
	Global      *bool  `json:"global"`
	Subcodes    *[]map[string]string
}

type Errors

type Errors []Error

func (Errors) Gen

func (es Errors) Gen() (gen string)

type ErrorsFile

type ErrorsFile struct {
	Definitions struct {
		Subcodes map[string]SubcodeJSON `json:"subcodes"`
	} `json:"definitions"`
	Errors map[string]ErrorJSON
}

type Genner

type Genner interface {
	Gen() (gen string)
}

type GennerWithTest

type GennerWithTest interface {
	Genner
	TestGen() (testGen string)
}

type Limits

type Limits struct {
	Minimum   interface{} `json:"minimum"`
	Maximum   interface{} `json:"maximum"`
	MinLength *int        `json:"minLength"`
	MaxLength *int        `json:"maxLength"`
	MinItems  *int        `json:"minItems"`
	MaxItems  *int        `json:"maxItems"`
	Format    *string     `json:"format"`
	Default   interface{} `json:"default"`
}

func (*Limits) Add

func (l *Limits) Add(newL Limits)

type Method

type Method struct {
	Name         string
	VKDevName    string
	Description  string
	AccessTokens []string
	ErrorRefs    []string

	GenRequest  bool
	RequestName string
	FullName    string

	Params      []ParamNameNestedGenner
	ResponseRef *string
	SetFields   []SetField
}

func (Method) Gen

func (m Method) Gen() (gen string)

func (Method) TestGen

func (m Method) TestGen() (testGen string)

type MethodJSON

type MethodJSON struct {
	Name            string              `json:"name"`
	Description     string              `json:"description"`
	AccessTokenType []string            `json:"access_token_type"`
	Parameters      []Parameter         `json:"parameters"`
	Responses       map[string]Property `json:"responses"`
	Errors          []Property          `json:"errors"`
}

type MethodsFile

type MethodsFile struct {
	Methods []MethodJSON `json:"methods"`
}

type NameGennerWithTest

type NameGennerWithTest interface {
	Namer
	GennerWithTest
}

type NameNestedGenner

type NameNestedGenner interface {
	Namer
	NestedGenner
}

type Namer

type Namer interface {
	GetName() string
}

type NestedGenner

type NestedGenner interface {
	// contains filtered or unexported methods
}

type Object

type Object struct {
	Name              string
	Description       string
	Fields            []NameNestedGenner
	ArrayNestingLevel int

	// fields for nested Object
	IsRequired bool
}

func (Object) Gen

func (o Object) Gen() (gen string)

func (Object) GetName

func (o Object) GetName() string

func (Object) TestGen

func (o Object) TestGen() (testGen string)

type ObjectsFile

type ObjectsFile struct {
	Definitions map[string]Property
}

type OneOf

type OneOf struct {
	Name              string
	Description       string
	Fields            []NestedGenner
	ArrayNestingLevel int

	// fields for nested OneOf
	IsRequired bool
	// contains filtered or unexported fields
}

func (OneOf) Gen

func (of OneOf) Gen() (gen string)

func (OneOf) GetName

func (of OneOf) GetName() string

func (OneOf) TestGen

func (of OneOf) TestGen() (testGen string)

type PackageFile

type PackageFile struct {
	Version string `json:"version"`
}

type Param

type Param struct {
	Name              string
	Type              string
	HasCustomType     bool
	IsRequired        bool
	ArrayNestingLevel int
	Limits            Limits
}

type ParamNameNestedGenner

type ParamNameNestedGenner interface {
	NameNestedGenner
	Param() Param
}

type Parameter

type Parameter struct {
	Property
	Name string `json:"name"`
}

type Property

type Property struct {
	Type *interface{} `json:"type"`

	Description *string `json:"description"`

	Required *bool `json:"required"`
	Limits

	Ref *string `json:"$ref"`

	Enum      *[]interface{} `json:"enum"`
	EnumNames *[]string      `json:"enumNames"`

	// type == array
	Items *Property `json:"items"`

	// type == object
	PatternProperties *map[string]map[string]string `json:"patternProperties"`
	Properties        *map[string]Property          `json:"properties"`
	AllOf             *[]Property                   `json:"allOf"`
	OneOf             *[]Property                   `json:"oneOf"`
}

type RefType

type RefType struct {
	ArrayNestingLevel int
	Type              string
}

type SetField

type SetField struct {
	Name  string
	Value string
}

type SimpleType

type SimpleType struct {
	Name              string
	Description       string
	Type              string
	Limits            Limits
	ArrayNestingLevel int
	IsRequired        bool
	// contains filtered or unexported fields
}

func (SimpleType) Gen

func (t SimpleType) Gen() (gen string)

func (SimpleType) GetName

func (t SimpleType) GetName() string

func (SimpleType) Param

func (t SimpleType) Param() (p Param)

func (SimpleType) TestGen

func (t SimpleType) TestGen() (testGen string)

type Subcode

type Subcode struct {
	Name string
	Code int
}

func (Subcode) Gen

func (sc Subcode) Gen() (gen string)

type SubcodeJSON

type SubcodeJSON map[string]float64

type Subcodes

type Subcodes []Subcode

func (Subcodes) Gen

func (scs Subcodes) Gen() (gen string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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