golang

package
v2.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error added in v2.1.1

type Error struct {
	Code    int
	Message string
}

func (Error) StringCode added in v2.3.0

func (e Error) StringCode() string

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator main package structure

func NewClient

func NewClient(schema smd.Schema, settings Settings) *Generator

NewClient create Generator from zenrpc/v2 SMD.

func (*Generator) Generate

func (g *Generator) Generate() ([]byte, error)

Generate returns generated Go client.

type Method added in v2.1.1

type Method struct {
	Name string

	// Params contains all method arguments
	Params []Value

	// RPC requires single one return value
	Returns *Value

	// Models contains all models which linked from Params or Return values by ModelName
	Models []Model

	// Description describes what the method does
	Description string

	// Typed errors
	Errors []Error
}

func (Method) CommentDescription added in v2.1.1

func (m Method) CommentDescription() string

CommentDescription add to head of all lines two slashes

func (Method) HasErrors added in v2.3.0

func (m Method) HasErrors() bool

func (Method) HasResult added in v2.1.1

func (m Method) HasResult() bool

type Model added in v2.1.1

type Model struct {
	Name        string
	Description string

	// IsParamModel indicate model is top-level method model
	IsParamModel bool
	// ParamName from smd method param name
	ParamName string
	// IsReturnModel indicate is return model
	IsReturnModel bool

	Fields []Value
}

type Namespace added in v2.1.1

type Namespace struct {
	Name    string
	Methods []Method
}

type Schema added in v2.1.1

type Schema struct {
	gen.GeneratorData
	Package    string
	Namespaces []Namespace
}

func NewSchema added in v2.1.1

func NewSchema(schema smd.Schema) Schema

NewSchema convert smd.Schema to Schema

func (Schema) MethodByName added in v2.1.1

func (s Schema) MethodByName(namespace, methodName string) Method

func (Schema) Models added in v2.1.1

func (s Schema) Models() (res []Model)

Models return all models from all methods

func (Schema) NamespaceByName added in v2.1.1

func (s Schema) NamespaceByName(namespace string) Namespace

func (Schema) NamespaceMethodNames added in v2.1.1

func (s Schema) NamespaceMethodNames(namespace string) (res []string)

NamespaceMethodNames return all methodNames by namespace name.

func (Schema) NamespaceNames added in v2.1.1

func (s Schema) NamespaceNames() (res []string)

NamespaceNames return all namespace names.

type Settings added in v2.4.0

type Settings struct {
	Package string
}

type Value added in v2.1.1

type Value struct {
	Name        string
	Type        string
	Optional    bool
	Description string

	ArrayItemType string

	ModelName string
}

func (Value) CommentDescription added in v2.4.1

func (v Value) CommentDescription() string

CommentDescription add to head of all lines two slashes

func (*Value) GoType added in v2.1.1

func (v *Value) GoType() string

GoType convert Value jsType to golang type

func (Value) LocalModelName added in v2.1.5

func (v Value) LocalModelName() string

LocalModelName rename external packages model names: pkg.Model -> PkgModel

Jump to

Keyboard shortcuts

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