spec

package
v1.44.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExceptionForCamelCase = map[string]string{
	"id":   "ID",
	"xprv": "XPrv",
	"url":  "URL",
}

ExceptionForCamelCase - camel case names exception.

Functions

func GenModule

func GenModule(dir string, m Module) error

func GenerateAnyType

func GenerateAnyType(m Module, t Type, isRoot bool) string

GenerateAnyType - root generator function for type.

func GenerateOptionalType

func GenerateOptionalType(m Module, t Type) string

GenerateOptionalType - pointer or null simple type.

Types

type APIReference

type APIReference struct {
	Version string   `json:"version"`
	Modules []Module `json:"modules"`
}

type Description

type Description struct {
	Name        string `json:"name,omitempty"`
	Summary     string `json:"summary,omitempty"`
	Description string `json:"description,omitempty"`
	ConstName   string `json:"-"` // populated manually, used in templates only
	GoComment   string `json:"-"` // populated manually, used in templates only
}

func (*Description) ToComment

func (d *Description) ToComment() string

ToComment generates comment for generate code from spec.

type Function

type Function struct {
	Description
	Params []Type `json:"params"`
	Result Type   `json:"result"`
}

type Module

type Module struct {
	Description
	Types     []Type     `json:"types"`
	Functions []Function `json:"functions"`
}

type Type

type Type struct {
	Description
	Type          TypeName `json:"type,omitempty"`
	GoType        string   `json:"-"`
	Value         string   `json:"value"`
	RefName       string   `json:"ref_name,omitempty"`
	GenericName   string   `json:"generic_name,omitempty"`
	NumberType    string   `json:"number_type,omitempty"`
	NumberSize    int      `json:"number_size,omitempty"`
	GenericArgs   []Type   `json:"generic_args,omitempty"`
	OptionalInner *Type    `json:"optional_inner,omitempty"`
	ArrayItem     *Type    `json:"array_item,omitempty"`
	StructFields  []Type   `json:"struct_fields,omitempty"`
	EnumConsts    []Type   `json:"enum_consts,omitempty"`
	EnumTypes     []Type   `json:"enum_types"`
}

Type description from JSON spec.

type TypeName

type TypeName string
const (
	Ref          TypeName = "Ref"
	Optional     TypeName = "Optional"
	String       TypeName = "String"
	Number       TypeName = "Number"
	Value        TypeName = "Value"
	Struct       TypeName = "Struct"
	None         TypeName = "None"
	BigInt       TypeName = "BigInt"
	Boolean      TypeName = "Boolean"
	Array        TypeName = "Array"
	Generic      TypeName = "Generic"
	EnumOfTypes  TypeName = "EnumOfTypes"
	EnumOfConsts TypeName = "EnumOfConsts"
)

TypeName different values.

Jump to

Keyboard shortcuts

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