Version: v2.1.5 Latest Latest

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

Go to latest
Published: Jul 15, 2021 License: MIT Imports: 8 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Error added in v2.1.1

type Error struct {
	Code    int
	Message string

type Generator

type Generator struct {
	// contains filtered or unexported fields

Generator main package structure

func NewClient

func NewClient(schema smd.Schema) *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) 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 {
	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 Value added in v2.1.1

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

	ArrayItemType string

	ModelName string

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
t or T : Toggle theme light dark auto
y or Y : Canonical URL