Documentation ¶
Index ¶
- Constants
- func BaseName(fullname string) (baseName string)
- func FindStrArrayCommonPrefix(arr []string, reliability float64) (prefix string)
- func FormatPathFnByFormatIn(format string, src string, item *JsonschemalineItem) (path string)
- func FormatPathFnByFormatOut(format string, src string, item *JsonschemalineItem) (path string)
- func GetJsonSchemaSchema() (schema string)
- func IsMetaLine(lineTags kvstruct.KVS) bool
- func MergeDefault(data string, defaul string) (merge string, err error)
- func MergeLineschema(first string, second string, reliability float64) (merged string, err error)
- func Namespace(fullname string) (namespace string)
- func ReplacePathSpecalChar(path string) (newPath string)
- func Similarity(s string, set []string, prefix string) (out string, ok bool)
- type DefaultJson
- type Instruct
- type InstructTpl
- type InstructTpls
- type Instructs
- type JsonSchemaFormFiledOut
- type JsonSchemaFormFiledOutMore
- type Jsonschemaline
- func Json2lineSchema(jsonStr string) (out *Jsonschemaline, err error)
- func JsonSchema2LineSchema(jsonschema string) (lineschema *Jsonschemaline, err error)
- func MatchLineschema(target Jsonschemaline, set []Jsonschemaline) (matched []Jsonschemaline)
- func ParseJsonschemaline(lineschema string) (jsonline *Jsonschemaline, err error)
- func (l *Jsonschemaline) BaseNames() (names []string)
- func (l *Jsonschemaline) DefaultJson() (defaultJson *DefaultJson, err error)
- func (l *Jsonschemaline) GjsonPath(ignoreID bool, ...) (gjsonPath string)
- func (l *Jsonschemaline) GjsonPathWithDefaultFormat(ignoreID bool) (gjsonPath string)
- func (l *Jsonschemaline) JsonExample() (jsonExample string, err error)
- func (l *Jsonschemaline) JsonSchema() (jsonschemaByte []byte, err error)
- func (l *Jsonschemaline) String() string
- func (l *Jsonschemaline) ToSturct() (structs Structs)
- type JsonschemalineItem
- type JsonschemalineItems
- type Meta
- type NameMatch
- type NameMatchs
- type StaticLineschema
- type StaticLineschemas
- type Struct
- type StructAttr
- type Structs
- func (s *Structs) AddIngore(structs ...*Struct)
- func (s *Structs) AddNameprefix(nameprefix string)
- func (s Structs) Copy() (newStructs Structs)
- func (s *Structs) Get(name string) (struc *Struct, exists bool)
- func (s *Structs) GetRoot() (struc *Struct, exists bool)
- func (s *Structs) Json() (str string)
Constants ¶
View Source
const ( LINE_SCHEMA_DIRECTION_OUT = "out" // 出参 LINE_SCHEMA_DIRECTION_IN = "in" // 入参 LINE_SCHEMA_DIRECTION_CONVERT = "convert" // 内部转换 )
View Source
const ( TOKEN_BEGIN = ',' TOKEN_END = '=' EOF = "\n" )
View Source
const ( //jsonschema 本身支持的格式描述(后台表单经常用到) JsonSchemaLineSchema = `` /* 2278-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func FindStrArrayCommonPrefix ¶ added in v0.0.43
FindStrArrayCommonPrefix 找到数字中字符串的最长前缀(并符合指定比率)
func FormatPathFnByFormatIn ¶ added in v0.0.34
func FormatPathFnByFormatIn(format string, src string, item *JsonschemalineItem) (path string)
使用format 属性格式化转换后的路径
func FormatPathFnByFormatOut ¶ added in v0.0.34
func FormatPathFnByFormatOut(format string, src string, item *JsonschemalineItem) (path string)
使用format 属性格式化转换后的路径
func GetJsonSchemaSchema ¶ added in v0.0.38
func GetJsonSchemaSchema() (schema string)
GetJsonSchemaScheme 返回jsonschema本身的schema
func IsMetaLine ¶
func MergeDefault ¶ added in v0.0.48
func MergeLineschema ¶ added in v0.0.43
MergeLineschema 合并2个同方向的lineschema,取第一个的fullname,第二个的dst或者src reliability为比率,最大为1.0
func ReplacePathSpecalChar ¶ added in v0.0.27
Types ¶
type DefaultJson ¶
type Instruct ¶
type Instruct struct { ID string // 唯一标识 Cmd string Src string Dst string Tpl string ExtraEndTpl []string // 一个元素代表一个模板命令,方便去重 ExtraStartTpl []string // 一个元素代表一个模板命令,方便去重 }
func FormatOutputInstruct ¶ added in v0.0.5
type InstructTpl ¶
func FormatOutputTplInstruct ¶ added in v0.0.5
func FormatOutputTplInstruct(instructTpl InstructTpl) (newInstructTpl InstructTpl)
func ParseInstructTp ¶
func ParseInstructTp(lineschema Jsonschemaline) (instructTpl *InstructTpl)
func (*InstructTpl) String ¶
func (instructTpl *InstructTpl) String() string
type InstructTpls ¶
type InstructTpls []*InstructTpl
func (InstructTpls) GetByID ¶
func (instructTpls InstructTpls) GetByID(id string) *InstructTpl
type JsonSchemaFormFiledOut ¶ added in v0.0.39
type JsonSchemaFormFiledOut struct { Fullname string `json:"fullname"` // 名称/全称 Type string `json:"type"` // 类型 枚举值 Title string `json:"title"` // 标题 Description string `json:"description"` // 描述 Format string `json:"format"` // 类型格式 More JsonSchemaFormFiledOutMore `json:"more"` }
func GetJsonSchemaFormFileds ¶ added in v0.0.39
func GetJsonSchemaFormFileds() (formFields []JsonSchemaFormFiledOut)
GetJsonSchemaFormFileds jsonschema 表单字段
type JsonSchemaFormFiledOutMore ¶ added in v0.0.39
type JsonSchemaFormFiledOutMore struct { Enum []string `json:"enum"` // 枚举值 EnumNames []string `json:"enumNames"` // 枚举值标题 Comment string `json:"comment"` // 备注 Const string `json:"const"` // 常量 MultipleOf int `json:"multipleOf"` // 多值 Maximum int `json:"maximum"` // 最大值 ExclusiveMaximum bool `json:"exclusiveMaximum"` // 是否包含最大值 Minimum int `json:"minimum"` // 最小值 ExclusiveMinimum bool `json:"exclusiveMinimum"` // 是否包含最小值 MaxLength int `json:"maxLength"` // 最大长度 MinLength int `json:"minLength"` // 最小长度 Pattern string `json:"pattern"` // 匹配格式 MaxItems int `json:"maxItems"` // 最大项数 MinItems int `json:"minItems"` // 最小项数 UniqueItems bool `json:"uniqueItems"` // 数组唯一 MaxContains uint `json:"maxContains"` // 符合Contains规则最大数量 MinContains uint `json:"minContains"` // 符合Contains规则最小数量 MaxProperties int `json:"maxProperties"` // 对象最多属性个数 MinProperties int `json:"minProperties"` // 对象最少属性个数 Required bool `json:"required"` // 是否必须 ContentEncoding string `json:"contentEncoding"` // 内容编码 ContentMediaType string `json:"contentMediaType"` // 内容格式 Default string `json:"default"` // 默认值 Deprecated bool `json:"deprecated"` // 是否弃用 ReadOnly bool `json:"readOnly"` // 只读 WriteOnly bool `json:"writeOnly"` // 只写 Example string `json:"example"` // 案例 Examples string `json:"examples"` // 案例集合 AllowEmptyValue bool `json:"allowEmptyValue"` // 是否可以为空 }
type Jsonschemaline ¶
type Jsonschemaline struct { Meta *Meta Items JsonschemalineItems }
func Json2lineSchema ¶
func Json2lineSchema(jsonStr string) (out *Jsonschemaline, err error)
Json2lineSchema
func JsonSchema2LineSchema ¶
func JsonSchema2LineSchema(jsonschema string) (lineschema *Jsonschemaline, err error)
func MatchLineschema ¶ added in v0.0.43
func MatchLineschema(target Jsonschemaline, set []Jsonschemaline) (matched []Jsonschemaline)
MatchLineschema 根据输入输出schema,从集合中匹配下游输入输出
func ParseJsonschemaline ¶
func ParseJsonschemaline(lineschema string) (jsonline *Jsonschemaline, err error)
ParseJsonschemaline 解析lineschema
func (*Jsonschemaline) BaseNames ¶ added in v0.0.43
func (l *Jsonschemaline) BaseNames() (names []string)
BaseNames 获取所有基础名称
func (*Jsonschemaline) DefaultJson ¶ added in v0.0.29
func (l *Jsonschemaline) DefaultJson() (defaultJson *DefaultJson, err error)
func (*Jsonschemaline) GjsonPath ¶ added in v0.0.8
func (l *Jsonschemaline) GjsonPath(ignoreID bool, formatPath func(format string, src string, item *JsonschemalineItem) (path string)) (gjsonPath string)
func (*Jsonschemaline) GjsonPathWithDefaultFormat ¶ added in v0.0.31
func (l *Jsonschemaline) GjsonPathWithDefaultFormat(ignoreID bool) (gjsonPath string)
GjsonPathWithDefaultFormat 生成格式化的jsonpath,用来重新格式化数据,比如入参字段类型全为字符串,在format中标记了实际类型,可以通过该方法获取转换数据的gjson path,从入参中提取数据后,对应字段类型就以format为准,此处仅仅提供有创意的案例,更多可以依据该思路扩展
func (*Jsonschemaline) JsonExample ¶ added in v0.0.19
func (l *Jsonschemaline) JsonExample() (jsonExample string, err error)
func (*Jsonschemaline) JsonSchema ¶ added in v0.0.2
func (l *Jsonschemaline) JsonSchema() (jsonschemaByte []byte, err error)
func (*Jsonschemaline) String ¶
func (l *Jsonschemaline) String() string
func (*Jsonschemaline) ToSturct ¶ added in v0.0.21
func (l *Jsonschemaline) ToSturct() (structs Structs)
type JsonschemalineItem ¶
type JsonschemalineItem struct { Comments string `json:"comment,omitempty"` // section 8.3 Type string `json:"type,omitempty"` // section 6.1.1 Enum string `json:"enum,omitempty"` // section 6.1.2 EnumNames string `json:"enumNames,omitempty"` // section 6.1.2 Const string `json:"const,omitempty"` // section 6.1.3 MultipleOf int `json:"multipleOf,omitempty,string"` // section 6.2.1 Maximum int `json:"maximum,omitempty,string"` // section 6.2.2 ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty,string"` // section 6.2.3 Minimum int `json:"minimum,omitempty,string"` // section 6.2.4 ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty,string"` // section 6.2.5 MaxLength int `json:"maxLength,omitempty,string"` // section 6.3.1 MinLength int `json:"minLength,omitempty,string"` // section 6.3.2 Pattern string `json:"pattern,omitempty"` // section 6.3.3 MaxItems int `json:"maxItems,omitempty,string"` // section 6.4.1 MinItems int `json:"minItems,omitempty,string"` // section 6.4.2 UniqueItems bool `json:"uniqueItems,omitempty,string"` // section 6.4.3 MaxContains uint `json:"maxContains,omitempty,string"` // section 6.4.4 MinContains uint `json:"minContains,omitempty,string"` // section 6.4.5 MaxProperties int `json:"maxProperties,omitempty,string"` // section 6.5.1 MinProperties int `json:"minProperties,omitempty,string"` // section 6.5.2 Required bool `json:"required,omitempty,string"` // section 6.5.3 // RFC draft-bhutton-json-schema-validation-00, section 7 Format string `json:"format,omitempty"` // RFC draft-bhutton-json-schema-validation-00, section 8 ContentEncoding string `json:"contentEncoding,omitempty"` // section 8.3 ContentMediaType string `json:"contentMediaType,omitempty"` // section 8.4 Title string `json:"title,omitempty"` // section 9.1 Description string `json:"description,omitempty"` // section 9.1 Default string `json:"default,omitempty"` // section 9.2 Deprecated bool `json:"deprecated,omitempty,string"` // section 9.3 ReadOnly bool `json:"readOnly,omitempty,string"` // section 9.4 WriteOnly bool `json:"writeOnly,omitempty,string"` // section 9.4 Example string `json:"example,omitempty"` // section 9.5 Examples string `json:"examples,omitempty"` // section 9.5 Src string `json:"src,omitempty"` Dst string `json:"dst,omitempty"` Fullname string `json:"fullname,omitempty"` AllowEmptyValue bool `json:"allowEmptyValue,omitempty,string"` TagLineKVpair kvstruct.KVS `json:"-"` Lineschema *Jsonschemaline `json:"-"` }
func (JsonschemalineItem) String ¶ added in v0.0.42
func (jItem JsonschemalineItem) String() (jsonStr string)
func (JsonschemalineItem) ToJsonSchemaKVS ¶ added in v0.0.16
func (jItem JsonschemalineItem) ToJsonSchemaKVS() (kvs kvstruct.KVS, err error)
type JsonschemalineItems ¶ added in v0.0.51
type JsonschemalineItems []*JsonschemalineItem
func (JsonschemalineItems) Unique ¶ added in v0.0.51
func (jsonItems JsonschemalineItems) Unique() (uniqItems JsonschemalineItems)
type NameMatch ¶ added in v0.0.43
type NameMatch struct { Name string Lineschema *Jsonschemaline Match *Jsonschemaline Possible NameMatchs }
type NameMatchs ¶ added in v0.0.43
type NameMatchs []*NameMatch
func (*NameMatchs) Add ¶ added in v0.0.43
func (ns *NameMatchs) Add(nameMatchs ...*NameMatch)
func (NameMatchs) Mach ¶ added in v0.0.43
func (ns NameMatchs) Mach(setNameMatches NameMatchs) NameMatchs
func (NameMatchs) Names ¶ added in v0.0.43
func (ns NameMatchs) Names() (names []string)
type StaticLineschema ¶ added in v0.0.43
type StaticLineschema struct { Count int Lineschema *Jsonschemaline }
type StaticLineschemas ¶ added in v0.0.43
type StaticLineschemas []StaticLineschema
func (StaticLineschemas) Len ¶ added in v0.0.43
func (a StaticLineschemas) Len() int
func (StaticLineschemas) Less ¶ added in v0.0.43
func (a StaticLineschemas) Less(i, j int) bool
func (StaticLineschemas) Swap ¶ added in v0.0.43
func (a StaticLineschemas) Swap(i, j int)
type Struct ¶ added in v0.0.21
type Struct struct { IsRoot bool Name string Lineschema string Attrs []*StructAttr Type string }
jsonschemaline 生成go 结构体工具
func (*Struct) AddAttrIgnore ¶ added in v0.0.21
func (s *Struct) AddAttrIgnore(attrs ...StructAttr)
AddAttrIgnore 已经存在则跳过
func (*Struct) AddAttrReplace ¶ added in v0.0.21
func (s *Struct) AddAttrReplace(attrs ...StructAttr)
AddAttrReplace 增加或者替换
type StructAttr ¶ added in v0.0.21
Click to show internal directories.
Click to hide internal directories.