api_type

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MemberTypeJson    = "json"
	MemberTypeNonBody = "!json"
	MemberTypeForm    = "form"
	MemberTypeAll     = ""
)

Variables

This section is empty.

Functions

func ApiType

func ApiType(typ reflect.Type) (string, bool, error)

自定义类型

func ApiTypeCustomList

func ApiTypeCustomList(typeList []reflect.Type) ([]string, error)

自定义类型

func ExpectedType

func ExpectedType(t reflect.Type) bool

func GenMemberType

func GenMemberType(m reflect.Type, lang string) (string, error)

func GetObjectMap

func GetObjectMap(ob *ObjectMap, types []reflect.Type, lang, memberType string) error

func GetTyp

func GetTyp(typ reflect.Type) reflect.Type

func ToTypeScriptType

func ToTypeScriptType(typ reflect.Type) (string, error)

func TsPrimitiveType

func TsPrimitiveType(typeName string) (string, error)

func TsRawType

func TsRawType(typeName string) (string, error)

func TsType

func TsType(typeName string) string

Types

type Member

type Member struct {
	Type     string   `yaml:"type"`
	Name     string   `yaml:"name"`
	Comment  string   `yaml:"comment"`
	JsonName string   `yaml:"jsonName"`
	FormName string   `yaml:"formName"`
	Options  []string `yaml:"options"`
	NotMust  bool     `yaml:"notMust"`
}

func GetMembers

func GetMembers(list *ObjectMap, tp reflect.Type, lang, memberType string) ([]Member, []reflect.Type, error)

memberType json:带有json标签的body字段 !json:除了json标签的其他字段 form:带有form标签的表单字段 为空表示所有字段

type Object

type Object struct {
	Name     string   `yaml:"name"`
	JsonName string   `yaml:"jsonName"`
	Comment  string   `yaml:"comment"`
	Members  []Member `yaml:"fields"`
}

type ObjectMap

type ObjectMap map[string]Object

func (*ObjectMap) Delete

func (o *ObjectMap) Delete(key string)

func (*ObjectMap) Deletes

func (o *ObjectMap) Deletes(keys []string)

func (*ObjectMap) Get

func (o *ObjectMap) Get(key string) (Object, bool)

func (*ObjectMap) IsExistMember

func (o *ObjectMap) IsExistMember(name string) bool

func (*ObjectMap) Len

func (o *ObjectMap) Len() int

func (*ObjectMap) NoPrimMembers

func (o *ObjectMap) NoPrimMembers(lang string) []string

func (*ObjectMap) ToList

func (o *ObjectMap) ToList() []Object

func (*ObjectMap) ToTypeScript

func (o *ObjectMap) ToTypeScript()

type Types

type Types []reflect.Type

func (*Types) GetType

func (a *Types) GetType(typeName string) reflect.Type

func (*Types) GetTypes

func (a *Types) GetTypes(typeNameList []string) Types

Jump to

Keyboard shortcuts

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