parser

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPkgNotFound     = errors.New("pkg not found")
	ErrPkgMod          = errors.New("pkg has no module information")
	ErrNoGoFilesFound  = errors.New("pkg has no Go files")
	ErrMethodFormat    = errors.New("invalid method format. Expected: Method(MethodReq) MethodRes")
	ErrMethodObjParse  = errors.New("cannot parse object for method")
	ErrObjNotStruct    = errors.New("object is not a struct")
	ErrObjNotFound     = errors.New("object not found")
	ErrFieldUnexported = errors.New("filed is unexported")
	ErrFieldIsStruct   = errors.New("filed cannot not be struct")
)

Functions

func Render

func Render(atomikaFS fs.FS, src, dest string, data interface{}) error

Types

type Definition

type Definition struct {
	Package  string            `json:"package"`
	Imports  map[string]string `json:"imports"`
	Services []Service         `json:"services"`
	Objects  []Object          `json:"objects"`
}

Definition will map the contents of service/def dir to an interfaces

func Generate

func Generate(pkgName, defPath string) (*Definition, error)

func (*Definition) MetadataLookup

func (d *Definition) MetadataLookup(keyPath, key string) *MetadataValueDesc

func (*Definition) ObjectLookup

func (d *Definition) ObjectLookup(name string) (*Object, error)

func (*Definition) ToJSON

func (d *Definition) ToJSON() string

type Field

type Field struct {
	Name               string              `json:"name"`
	NameCamelLowerCase string              `json:"nameCamelLowerCase"`
	Type               FieldType           `json:"type"`
	OmitEmpty          bool                `json:"omitEmpty"`
	Tag                string              `json:"tag"`
	ParsedTags         map[string]FieldTag `json:"parsedTags"`
	Comment            string              `json:"comment"`
	Metadata           Metadata            `json:"metadata"`
}

type FieldTag

type FieldTag struct {
	Value   string   `json:"value"`
	Options []string `json:"options"`
}

type FieldType

type FieldType struct {
	TypeID                  string `json:"typeId"`
	TypeName                string `json:"typeName"`
	ObjName                 string `json:"objName"`
	ObjNameToLowerCamelCase string `json:"objNameToLowerCamelCase"`
	Package                 string `json:"package"`
	IsCollection            bool   `json:"isCollection"`
	IsObject                bool   `json:"isObject"`
	JSType                  string `json:"jsType"`
	TSType                  string `json:"tsType"`
	Length                  int    `json:"len"`
}

type MetaKeyResult

type MetaKeyResult struct {
	Exists bool
	Result interface{}
}

type Metadata

type Metadata map[string]MetadataValueDesc

func (Metadata) Get

func (m Metadata) Get(key string) *MetadataValueDesc

type MetadataValueDesc

type MetadataValueDesc struct {
	Value       interface{} `json:"value"`
	Description string      `json:"description,omitempty"`
}

type Method

type Method struct {
	Name               string    `json:"name"`
	NameLowerCaseCamel string    `json:"nameLowerCaseCamel"`
	Params             FieldType `json:"params"`
	Returns            FieldType `json:"returns"`
	Comment            string    `json:"comment"`
	Metadata           Metadata  `json:"metadata"`
}

type Object

type Object struct {
	Name     string   `json:"name"`
	ObjName  string   `json:"objName"`
	TypeID   string   `json:"typeId"`
	Imported bool     `json:"imported"`
	Fields   []Field  `json:"fields"`
	Comment  string   `json:"comment"`
	Metadata Metadata `json:"metadata"`
}

type Parser

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

func NewParser

func NewParser(pkgName string) *Parser

func (*Parser) Parse

func (p *Parser) Parse(pkgPath string) (Definition, error)

type SDK

type SDK struct {
	Go bool
	Js bool
	Ts bool
}

SDK struct is used in parsing services by default parser will generate only the service side if any of sdk is true, an SDK for that programming lang will be generated

type Service

type Service struct {
	Name               string   `json:"name"`
	NameCamelLowerCase string   `json:"nameCamelLowerCase"`
	Methods            []Method `json:"methods"`
	Comment            string   `json:"comment"`
	Metadata           Metadata `json:"metadata"`
}

Jump to

Keyboard shortcuts

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