exprx

package
v0.0.0-...-55524bd Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultEncoding is default encoding when empty
	DefaultEncoding = consts.DefaultEncoding
	// PolyEncoding is encoding by poly api
	PolyEncoding = consts.PolyEncoding
)
View Source
const (

	// DefaultBufLen is default buffer length
	DefaultBufLen = defaultBufLen
)

Variables

View Source
var (
	// EnumTypesEnum represents enum of enum types
	EnumTypesEnum = newEnumSet(nil)
	EnumNode      = EnumTypesEnum.MustReg(consts.EnumNode)
	EnumValue     = EnumTypesEnum.MustReg(consts.EnumValue)
	EnumOper      = EnumTypesEnum.MustReg(consts.EnumOper)
	EnumCond      = EnumTypesEnum.MustReg(consts.EnumCond)
	EnumCmp       = EnumTypesEnum.MustReg(consts.EnumCmp)
	EnumIn        = EnumTypesEnum.MustReg(consts.EnumIn)
	EnumAuth      = EnumTypesEnum.MustReg(consts.EnumAuth)
)

enum of enum types

View Source
var (
	// ValTypeEnum input value enum set, basic value accept in Input node
	ValTypeEnum = newEnumSet(nil)
	// ValTypeNumber represent value like 123
	ValTypeNumber = ValTypeEnum.MustReg("number")
	// ValTypeString represent value like "xyz"
	ValTypeString = ValTypeEnum.MustReg("string")

	// XValTypeAction represent value like action parameter
	ValTypeAction = ValTypeEnum.MustReg("action")
	// XValTypeTimestamp represent value like timestamp parameter
	ValTypeTimestamp = ValTypeEnum.MustReg("timestamp")

	// ValTypeBoolean represent value like true
	ValTypeBoolean = ValTypeEnum.MustReg("boolean")
	// ValTypeObject represent value like {...}
	ValTypeObject = ValTypeEnum.MustReg("object")
	// ValTypeArray represent value like [...]
	ValTypeArray = ValTypeEnum.MustReg("array")

	// ValTypeArrayString represent value like "foo,bar" => ["foo","bar"]
	ValTypeArrayString = ValTypeEnum.MustReg("array_string")
)

basic types

View Source
var (
	// XValTypeEnum extend value enum set, include ValEnum
	XValTypeEnum = newEnumSet(ValTypeEnum)
	// XValTypeUndefined represent value like undefined
	XValTypeUndefined = XValTypeEnum.MustReg("undefined") // undefined
	// XValTypeNull represent value like null
	XValTypeNull = XValTypeEnum.MustReg("null")
	// XValTypeMergeObj represent value like merged object, {a,b} + {c,d} => {a,b,c,d}
	XValTypeMergeObj = XValTypeEnum.MustReg("mergeobj")
	// XValTypeFilter represent value like use on Object|Array field
	XValTypeFilter = XValTypeEnum.MustReg("filter")

	// ValTypeArrayStringElem represent value like [...] as xxx.n
	XValTypeArrayStringElem = XValTypeEnum.MustReg("array_string_elem")

	// XValTypeField represent value like req.data.userId
	XValTypeField = XValTypeEnum.MustReg("field")
)

extend value type

View Source
var (
	// ExprTypeEnum represents expression type, single expression, eg: const,field
	ExprTypeEnum = newEnumSet(XValTypeEnum)
	// ExprTypeExpr represents expr like (x + y) * 2
	ExprTypeExpr = ExprTypeEnum.MustReg("expr")
	// ExprTypeCmp represents compare expression, eg: a lt b
	ExprTypeCmp = ExprTypeEnum.MustReg("exprcmp")
	// ExprTypeSel represents select expression, eg: cond ? yesVal : noVal
	ExprTypeSel = ExprTypeEnum.MustReg("exprsel")
	// ExprTypeFunc represents // func(...), function call
	ExprTypeFunc = ExprTypeEnum.MustReg("exprfunc")
	// ExprTypeGroup represents group expression, eg: (a + b), (x and y)
	ExprTypeGroup = ExprTypeEnum.MustReg("exprgroup")
	// ExprTypeDirectExpr represents direct expression string, eg: "(req1.a+1)*2"
	ExprTypeDirectExpr = ExprTypeEnum.MustReg("direct_expr")
)

expression types

View Source
var (
	// OpEnum represents operator enum set
	OpEnum = newEnumSet(nil)
	// OpAdd represents operator +
	OpAdd = OpEnum.MustRegWithContent("add", "+", "")
	// OpSub represents operator -
	OpSub = OpEnum.MustRegWithContent("sub", "-", "")
	// OpMul represents operator *
	OpMul = OpEnum.MustRegWithContent("mul", "*", "")
	// OpDiv represents operator /
	OpDiv = OpEnum.MustRegWithContent("div", "/", "")
)

operator enum set

View Source
var (
	// CondEnum represents condition enum set
	CondEnum = newEnumSet(nil)
	// CondAnd represents logic operator &&
	CondAnd = CondEnum.MustRegWithContent("and", "&&", "") // &&
	// CondOr represents logic operator ||
	CondOr = CondEnum.MustRegWithContent("or", "||", "")
	// CondNot represents logic operator !
	CondNot = CondEnum.MustRegWithContent("not", "!", "")
)

condition enum set

View Source
var (
	// CmpEnum represents compare enum set
	CmpEnum = newEnumSet(nil)
	CmpLT   = CmpEnum.MustRegWithContent("lt", "<", "")
	CmpGT   = CmpEnum.MustRegWithContent("gt", ">", "")
	CmpLE   = CmpEnum.MustRegWithContent("le", "<=", "")
	CmpGE   = CmpEnum.MustRegWithContent("ge", ">=", "")
	CmpEQ   = CmpEnum.MustRegWithContent("eq", "==", "")
	CmpNE   = CmpEnum.MustRegWithContent("ne", "!=", "")
)

compare enum set

View Source
var (
	// EncodingEnum represents encoding format
	EncodingEnum = newEnumSet(nil)
	// EncodingJSON represents encoding JSON
	EncodingJSON = EncodingEnum.MustReg(consts.EncodingJSON)
	// EncodingXML represents encoding XML
	EncodingXML = EncodingEnum.MustReg(consts.EncodingXML)
	// EncodingYAML represents encoding YAML
	EncodingYAML = EncodingEnum.MustReg(consts.EncodingYAML)
)
View Source
var (
	// SchemaEnum represents API scheme
	SchemaEnum = newEnumSet(nil)
	// SchemaHTTP represents API scheme http
	SchemaHTTP = SchemaEnum.MustReg(consts.SchemaHTTP)
	// SchemaHTTPS represents API scheme https
	SchemaHTTPS = SchemaEnum.MustReg(consts.SchemaHTTPS)
)
View Source
var (
	// MethodEnum represents http API methods
	MethodEnum    = newEnumSet(nil)
	MethodGet     = MethodEnum.MustReg(consts.MethodGet)
	MethodPost    = MethodEnum.MustReg(consts.MethodPost)
	MethodPut     = MethodEnum.MustReg(consts.MethodPut)
	MethodDelete  = MethodEnum.MustReg(consts.MethodDelete)
	MethodOPTIONS = MethodEnum.MustReg(consts.MethodOptions)
	MethodHEAD    = MethodEnum.MustReg(consts.MethodHead)
	MethodTRACE   = MethodEnum.MustReg(consts.MethodTrace)
	MethodCONNECT = MethodEnum.MustReg(consts.MethodConnect)
)

http API methods

View Source
var (
	// ParaTypeEnum represents parameter type
	ParaTypeEnum     = newEnumSet(nil)
	ParaTypeHeader   = ParaTypeEnum.MustReg(consts.ParaInHeader)
	ParaTypePath     = ParaTypeEnum.MustReg(consts.ParaInPath)
	ParaTypeBody     = ParaTypeEnum.MustReg(consts.ParaInBody)
	ParaTypeQuery    = ParaTypeEnum.MustReg(consts.ParaInQuery)
	ParaTypeFormData = ParaTypeEnum.MustReg(consts.ParaInFormData)
	// ParaTypeHide represents hide parameter like skey
	ParaTypeHide = ParaTypeEnum.MustReg("hide")
)

parameter type

View Source
var (
	ValTypeForDocEnum = newEnumSet(nil)
)

doc type

Functions

func ConvertOp

func ConvertOp(e string) (string, error)

ConvertOp eq->== and->&& add->+

func FullVarName

func FullVarName(name string) string

FullVarName get the full variable of poly API

func GenLinehead

func GenLinehead(depth int) string

GenLinehead generate line head with depth

func GetFactory

func GetFactory() *factory.FlexObjFactory

GetFactory return the factory object

func GetFieldName

func GetFieldName(f string) string

GetFieldName return the file name from field ref. eg: req1.data.x => x

Types

type APISampleInput

type APISampleInput struct {
	Header http.Header `json:"header,omitempty"`
	//Path   map[string]string `json:"path,omitempty"` //body._hide{}
	Body json.RawMessage `json:"body,omitempty"`
}

APISampleInput is the sample input of an API

type APISampleOutput

type APISampleOutput struct {
	Header http.Header     `json:"header,omitempty"`
	Resp   json.RawMessage `json:"resp,omitempty"`
}

APISampleOutput is the sample output of an API

type CondExpr

type CondExpr = ValExpr

CondExpr represents a condition expression

type CondExprGroup

type CondExprGroup = ValExprGroup

CondExprGroup represents a condition expression group

type CreateSampleDataor

type CreateSampleDataor interface {
	CreateSampleData(val interface{}, titleFirst bool) value.JSONValue
}

CreateSampleDataor represents value that can generate sample JSON value

type DelayedJSONDecoder

type DelayedJSONDecoder interface {
	DelayedJSONDecode() error //  delay unmarshal flex json object
}

DelayedJSONDecoder define an object that need delay decode JSON

type Enum

type Enum enumset.Enum

Enum exports

func GetDocType

func GetDocType(t Enum) Enum

GetDocType get doc tyle of specify type

func (Enum) EncodingToMIME

func (e Enum) EncodingToMIME() (string, error)

EncodingToMIME change encoding like JSON to MIME like "application/json"

func (Enum) IsAction

func (e Enum) IsAction() bool

IsAction judge if a value type is action

func (Enum) IsArrayElem

func (e Enum) IsArrayElem() bool

IsArrayElem judge if a value type is array show as ary.1=xxx

func (Enum) IsBody

func (e Enum) IsBody() bool

IsBody judege if is a body parameter

func (Enum) IsField

func (e Enum) IsField() bool

IsField judge if a value type is field refer

func (Enum) IsHeader

func (e Enum) IsHeader() bool

IsHeader judege if is a header parameter

func (Enum) IsHeaderAcceptable

func (e Enum) IsHeaderAcceptable() bool

IsHeaderAcceptable judege if is a header-acceptable parameter

func (Enum) IsHide

func (e Enum) IsHide() bool

IsHide judege if is a hide parameter

func (Enum) IsNullable

func (e Enum) IsNullable() bool

IsNullable judge if the data field is nullable

func (Enum) IsPath

func (e Enum) IsPath() bool

IsPath judege if is a path parameter

func (Enum) IsPredefineable

func (e Enum) IsPredefineable() bool

IsPredefineable judge if a value is predefineable

func (Enum) IsQuery

func (e Enum) IsQuery() bool

IsQuery judege if is a query parameter

func (Enum) IsStringer

func (e Enum) IsStringer() bool

IsStringer judge if a value is able to convert to string

func (Enum) IsTimestamp

func (e Enum) IsTimestamp() bool

IsTimestamp judge if a value type is timestamp

func (Enum) SameIn

func (e Enum) SameIn(o Enum) bool

SameIn compare if the parameter from the same input way

func (Enum) String

func (e Enum) String() string

String show enum as string

type Evaler

type Evaler = protocol.Evaler

Evaler exports

type FieldMap

type FieldMap map[string]string

FieldMap represents a object filed mapping

func (FieldMap) ToScript

func (m FieldMap) ToScript(depth int) string

ToScript returns the script of this element represent

type FieldRef

type FieldRef string

FieldRef is field reference

func (FieldRef) Empty

func (v FieldRef) Empty() bool

Empty check if field refer is empty

func (FieldRef) GetName

func (v FieldRef) GetName(titleFirst bool) string

GetName returns Name of the elem

func (*FieldRef) SetString

func (v *FieldRef) SetString(s string)

SetString set a string to Value

func (FieldRef) String

func (v FieldRef) String() string

String convert v to string

func (FieldRef) ToScript

func (v FieldRef) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

type FlexJSONObject

type FlexJSONObject = jsonx.FlexJSONObject

FlexJSONObject exports

type FmtAPIInOut

type FmtAPIInOut struct {
	Method    string             `json:"method"`
	URL       string             `json:"url"`
	Input     InputNodeDetail    `json:"input"`
	Output    OutputNodeDetail   `json:"output"`
	SampleIn  [2]APISampleInput  `json:"sampleInput"`  // [0]normal [1]tilteFirst
	SampleOut [2]APISampleOutput `json:"sampleOutput"` // [0]normal [1]tilteFirst
}

FmtAPIInOut is the formated API input and output

func (*FmtAPIInOut) DelayedJSONDecode

func (d *FmtAPIInOut) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (*FmtAPIInOut) SetAccessURL

func (d *FmtAPIInOut) SetAccessURL(apiPath string)

SetAccessURL update the api access path

type GenSampler

type GenSampler interface {
	GenSample(val interface{}, titleFirst bool) value.JSONValue
}

GenSampler represents value that can generate sample JSON value

type InputNodeDetail

type InputNodeDetail struct {
	Inputs []ValueDefine `json:"inputs,omitempty"` // input from header, path, body or uri(GET)
	Consts ValueSet      `json:"consts,omitempty"` // const values provide by arrange
}

InputNodeDetail represents the detail of an input node.

func (*InputNodeDetail) DelayedJSONDecode

func (d *InputNodeDetail) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

type InputValue

type InputValue = expr.InputValue

InputValue represent a const value input

type NamedScriptElem

type NamedScriptElem interface {
	ScriptElem
	NamedValue
}

NamedScriptElem define a script element with name

type NamedType

type NamedType = factory.NamedType

NamedType exports

type NamedValue

type NamedValue interface {
	GetName(titleFirst bool) string // get name of this element
}

NamedValue define a value with name

type OutputNodeDetail

type OutputNodeDetail struct {
	Header ValueSet      `json:"header,omitempty"` // output from header
	Body   Value         `json:"body,omitempty"`   // output from body
	Doc    []ValueDefine `json:"doc,omitempty"`    // output from body, for doc only
}

OutputNodeDetail represents detail of an output node

func (*OutputNodeDetail) DelayedJSONDecode

func (d *OutputNodeDetail) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

type RequestArgs

type RequestArgs = expr.RequestArgs

RequestArgs represents a request parament of a request

type ScriptElem

type ScriptElem interface {
	ToScript(depth int, e Evaler) (string, error) // element to script
}

ScriptElem define a script element

type Stringer

type Stringer interface {
	String() string
	SetString(s string)
}

Stringer define an interface with String()

func NewStringer

func NewStringer(v string, kind Enum) Stringer

NewStringer create a string-like value

type StringerWithError

type StringerWithError interface {
	Validate() error
	SetStringWithError(s string) error
}

StringerWithError define an interface with SetStringWithError()

type Stringifier

type Stringifier interface {
	String() string
}

Stringifier is an interface to convert to string only

type SwagConstValue

type SwagConstValue = XInputValue

SwagConstValue is predef value

type SwagConstValueSet

type SwagConstValueSet = ValueSet

SwagConstValueSet is predef value set

type ValAction

type ValAction ValString

ValAction represents action string

func (*ValAction) DelayedJSONDecode

func (v *ValAction) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (*ValAction) SetString

func (v *ValAction) SetString(s string)

SetString set a string to Value

func (ValAction) String

func (v ValAction) String() string

String convert v to string

func (ValAction) ToScript

func (v ValAction) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValAction) TypeName

func (v ValAction) TypeName() string

TypeName returns name of the type

type ValArray

type ValArray []Value

ValArray represents an array value, [...]

func (*ValArray) DelayedJSONDecode

func (v *ValArray) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValArray) GenSample

func (v ValArray) GenSample(val interface{}, titleFirst bool) value.JSONValue

GenSample generate a sample JSON value

func (ValArray) ToScript

func (v ValArray) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValArray) TypeName

func (v ValArray) TypeName() string

TypeName returns name of the type

type ValArrayString

type ValArrayString []string

ValArrayString enable parse a single string as string array

func (*ValArrayString) DelayedJSONDecode

func (v *ValArrayString) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValArrayString) GenSample

func (v ValArrayString) GenSample(val interface{}, titleFirst bool) value.JSONValue

GenSample generate a sample JSON value

func (ValArrayString) MarshalJSON

func (v ValArrayString) MarshalJSON() ([]byte, error)

MarshalJSON encoding array as single string

func (*ValArrayString) SetString

func (v *ValArrayString) SetString(s string)

SetString decode string as ValArrayString

func (ValArrayString) String

func (v ValArrayString) String() string

String encode ValArrayString as string

func (ValArrayString) ToScript

func (v ValArrayString) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValArrayString) TypeName

func (v ValArrayString) TypeName() string

TypeName returns name of the type

func (*ValArrayString) UnmarshalJSON

func (v *ValArrayString) UnmarshalJSON(data []byte) error

UnmarshalJSON splist data as string array

type ValArrayStringElem

type ValArrayStringElem struct {
	Name  string         `json:"name"`
	Array ValArrayString `json:"array"`
}

ValArrayStringElem enable parse a single string as string array that output as ary.1=xxx

func (*ValArrayStringElem) DelayedJSONDecode

func (v *ValArrayStringElem) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValArrayStringElem) GenSample

func (v ValArrayStringElem) GenSample(val interface{}, titleFirst bool) value.JSONValue

GenSample generate a sample JSON value

func (ValArrayStringElem) GetName

func (v ValArrayStringElem) GetName(titleFirst bool) string

GetName returns Name of the value.

func (ValArrayStringElem) ToScript

func (v ValArrayStringElem) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValArrayStringElem) TypeName

func (v ValArrayStringElem) TypeName() string

TypeName returns name of the type

type ValBoolean

type ValBoolean ValString

ValBoolean represents boolean value

func (*ValBoolean) DelayedJSONDecode

func (v *ValBoolean) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValBoolean) GenSample

func (v ValBoolean) GenSample(val interface{}, titleFirst bool) value.JSONValue

GenSample generate a sample JSON value

func (*ValBoolean) SetString

func (v *ValBoolean) SetString(s string)

SetString set a string to Value

func (ValBoolean) String

func (v ValBoolean) String() string

String convert v to string

func (ValBoolean) ToScript

func (v ValBoolean) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValBoolean) TypeName

func (v ValBoolean) TypeName() string

TypeName returns name of the type

type ValDirectExpr

type ValDirectExpr ValString // direct expression string

ValDirectExpr represents an direct JS expression

func (*ValDirectExpr) DelayedJSONDecode

func (v *ValDirectExpr) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (*ValDirectExpr) SetString

func (v *ValDirectExpr) SetString(s string)

SetString set a string to Value

func (*ValDirectExpr) SetStringWithError

func (v *ValDirectExpr) SetStringWithError(s string) error

SetStringWithError set a string to Value with format check

func (ValDirectExpr) String

func (v ValDirectExpr) String() string

String convert v to string

func (ValDirectExpr) ToScript

func (v ValDirectExpr) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValDirectExpr) TypeName

func (v ValDirectExpr) TypeName() string

TypeName returns name of the type

func (ValDirectExpr) Validate

func (v ValDirectExpr) Validate() error

Validate verify the value of object

type ValExpr

type ValExpr struct {
	Op string `json:"op"` // operation, and|or|not add|sub|mul|div
	Value
}

ValExpr represents an expression, eg: a.x + (b.y + c.z) * 2

func (ValExpr) TypeName

func (v ValExpr) TypeName() string

TypeName returns name of the type

type ValExprCmp

type ValExprCmp struct {
	LValue Value  `json:"lvalue"` // Left value
	Cmp    string `json:"cmp"`    // ""|lt|gt|le|ge|eq|ne
	RValue Value  `json:"rvalue"` // Right value
}

ValExprCmp represents a compare expression, eg: a eq b

func (*ValExprCmp) DelayedJSONDecode

func (v *ValExprCmp) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValExprCmp) ToScript

func (v ValExprCmp) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValExprCmp) TypeName

func (v ValExprCmp) TypeName() string

TypeName returns name of the type

type ValExprFunc

type ValExprFunc struct {
	Func  string  `json:"func"`  // function name
	Paras []Value `json:"paras"` // parameters
}

ValExprFunc represents a value of function call

func (*ValExprFunc) DelayedJSONDecode

func (v *ValExprFunc) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValExprFunc) ToScript

func (v ValExprFunc) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValExprFunc) TypeName

func (v ValExprFunc) TypeName() string

TypeName returns name of the type

type ValExprGroup

type ValExprGroup []ValExpr

ValExprGroup represents expression group, eg: (b+c)

func (*ValExprGroup) DelayedJSONDecode

func (v *ValExprGroup) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValExprGroup) ToScript

func (v ValExprGroup) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValExprGroup) TypeName

func (v ValExprGroup) TypeName() string

TypeName returns name of the type

type ValExprSel

type ValExprSel struct {
	Cond CondExpr `json:"cond"` // check condition
	Yes  Value    `json:"yes"`  // yes value
	No   Value    `json:"no"`   // no value
}

ValExprSel represents a select expression, eg: cond ? yesVal : noVal

func (*ValExprSel) DelayedJSONDecode

func (v *ValExprSel) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValExprSel) ToScript

func (v ValExprSel) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValExprSel) TypeName

func (v ValExprSel) TypeName() string

TypeName returns name of the type

type ValFiltObj

type ValFiltObj struct {
	Source FieldRef `json:"source"` // field of object or array type
	White  FieldMap `json:"white"`  // white list of field name mapping, oldName->newName
	Black  FieldMap `json:"black"`  // black list of field name mapping
	Filter CondExpr `json:"filter"` // data fielter for an array
	// contains filtered or unexported fields
}

ValFiltObj represents data filter expression

func (*ValFiltObj) DelayedJSONDecode

func (v *ValFiltObj) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValFiltObj) GetName

func (v ValFiltObj) GetName(titleFirst bool) string

GetName returns Name of the elem

func (ValFiltObj) ToScript

func (v ValFiltObj) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValFiltObj) TypeName

func (v ValFiltObj) TypeName() string

TypeName returns name of the type

type ValMergeObj

type ValMergeObj []Value

ValMergeObj merge multi objects as one. eg: {a,b}+{c,d} => {a,b,c,d}

func (*ValMergeObj) DelayedJSONDecode

func (v *ValMergeObj) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValMergeObj) ToScript

func (v ValMergeObj) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValMergeObj) TypeName

func (v ValMergeObj) TypeName() string

TypeName returns name of the type

type ValNumber

type ValNumber ValString

ValNumber represents number value, deal as string

func (*ValNumber) DelayedJSONDecode

func (v *ValNumber) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValNumber) GenSample

func (v ValNumber) GenSample(val interface{}, titleFirst bool) value.JSONValue

GenSample generate a sample JSON value

func (*ValNumber) SetString

func (v *ValNumber) SetString(s string)

SetString set a string to Value

func (ValNumber) String

func (v ValNumber) String() string

String convert v to string

func (ValNumber) ToScript

func (v ValNumber) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValNumber) TypeName

func (v ValNumber) TypeName() string

TypeName returns name of the type

type ValObject

type ValObject ValArray

ValObject represents an object value, {...}

func (*ValObject) DelayedJSONDecode

func (v *ValObject) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValObject) GenSample

func (v ValObject) GenSample(val interface{}, titleFirst bool) value.JSONValue

GenSample generate a sample JSON value

func (ValObject) ToScript

func (v ValObject) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValObject) TypeName

func (v ValObject) TypeName() string

TypeName returns name of the type

type ValString

type ValString string

ValString represents string value

func (*ValString) DelayedJSONDecode

func (v *ValString) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValString) GenSample

func (v ValString) GenSample(val interface{}, titleFirst bool) value.JSONValue

GenSample generate a sample JSON value

func (*ValString) SetString

func (v *ValString) SetString(s string)

SetString set a string to Value

func (ValString) String

func (v ValString) String() string

String convert v to string

func (ValString) ToScript

func (v ValString) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValString) TypeName

func (v ValString) TypeName() string

TypeName returns name of the type

type ValTimestamp

type ValTimestamp ValString

ValTimestamp represents timestamp value

func (*ValTimestamp) DelayedJSONDecode

func (v *ValTimestamp) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValTimestamp) GenSample

func (v ValTimestamp) GenSample(val interface{}, titleFirst bool) value.JSONValue

GenSample generate a sample JSON value

func (*ValTimestamp) SetString

func (v *ValTimestamp) SetString(s string)

SetString set a string to Value

func (ValTimestamp) String

func (v ValTimestamp) String() string

String convert v to string

func (ValTimestamp) ToScript

func (v ValTimestamp) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

func (ValTimestamp) TypeName

func (v ValTimestamp) TypeName() string

TypeName returns name of the type

type Value

type Value struct {
	// type of this value:
	// number|string|boolean|object|array|array_elem|array_string_elem|array_string|
	// undefined|null|mergeobj|filter|path|header|skey|action|signature|timestamp|
	// field|expr|exprcmp|exprsel|exprfunc|exprgroup|direct_expr
	Type  Enum   `json:"type"`
	Name  string `json:"name"` // new name of this value
	Title string `json:"title,omitempty"`
	Desc  string `json:"desc,omitempty"` // description of this value

	Appendix bool `json:"$appendix$,omitempty"` // NOTE: Appendix value, platform only
	Required bool `json:"required,omitempty"`   // required

	Field FieldRef       `json:"field,omitempty"` // field refer for this value, eg: "req1.data.x"
	Data  FlexJSONObject `json:"data,omitempty"`  // specific value for non-field content
}

Value represents a value with given type It use Field value firstly.

func (Value) CreateSampleData

func (v Value) CreateSampleData(val interface{}, titleFirst bool) value.JSONValue

CreateSampleData generate a sample JSON value

func (*Value) DelayedJSONDecode

func (v *Value) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (Value) DenyFieldRefer

func (v Value) DenyFieldRefer() error

DenyFieldRefer assert this value don't refer a field value

func (Value) Empty

func (v Value) Empty() bool

Empty check if the value is empty

func (Value) GetAsString

func (v Value) GetAsString() string

GetAsString return Value as string if it contains that.

func (Value) GetName

func (v Value) GetName(titleFirst bool) string

GetName returns Name of the value. It returns field name if it is a filed value and Nanme not set.

func (Value) ToScript

func (v Value) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

type ValueDefine

type ValueDefine struct {
	InputValue          //value
	Key        bool     `json:"key,omitempty"`     // key field, for name check of referenced
	Default    string   `json:"default,omitempty"` // default value
	Mock       string   `json:"mock,omitempty"`    // mock value
	Enums      []string `json:"enums,omitempty"`   // valid value enum of this input
	Ranges     []string `json:"ranges,omitempty"`  // valid value ranges [min,max)[min,max)... of this input
}

ValueDefine represents the value of an input.

type ValueSet

type ValueSet expr.ValueSet

ValueSet represents a set of value for input

func (*ValueSet) AddExKV

func (v *ValueSet) AddExKV(key, value string, kind, in Enum) error

AddExKV add or update a named string value in this object without type check

func (*ValueSet) AddKV

func (v *ValueSet) AddKV(key, value string, kind, in Enum) error

AddKV add or update a named string value in this object

func (*ValueSet) DelayedJSONDecode

func (v *ValueSet) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (ValueSet) GetAction

func (v ValueSet) GetAction() *expr.InputValue

GetAction return the action predef value

func (ValueSet) PrepareRequest

func (v ValueSet) PrepareRequest(args *RequestArgs) error

PrepareRequest solve the input parameters from predefined values

func (*ValueSet) ReplacePathArgs

func (s *ValueSet) ReplacePathArgs(srcURL string, name string) (string, error)

ReplacePathArgs replace args in path from the input values

func (*ValueSet) ResolvePathArgs

func (s *ValueSet) ResolvePathArgs(srcURL string, nodeName string) (string, []string, error)

ResolvePathArgs repalce the path with fmt string and return it's fmt args. eg: "/api/:x" => ("/api/%v", ["$x"])

func (ValueSet) ToScript

func (v ValueSet) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

type XInputValue

type XInputValue expr.InputValue

XInputValue is entended InputValue

func (XInputValue) CreateSampleData

func (v XInputValue) CreateSampleData(val interface{}, titleFirst bool) value.JSONValue

CreateSampleData generate a sample JSON value

func (*XInputValue) DelayedJSONDecode

func (v *XInputValue) DelayedJSONDecode() error

DelayedJSONDecode delay unmarshal flex json object

func (XInputValue) DenyFieldRefer

func (v XInputValue) DenyFieldRefer() error

DenyFieldRefer assert this value don't refer a field value

func (*XInputValue) Empty

func (v *XInputValue) Empty() bool

Empty check if the value is empty

func (XInputValue) GetAsString

func (v XInputValue) GetAsString() string

GetAsString return Value as string if it contains that.

func (XInputValue) GetName

func (v XInputValue) GetName(titleFirst bool) string

GetName return name of input value

func (XInputValue) ToScript

func (v XInputValue) ToScript(depth int, e Evaler) (string, error)

ToScript returns the script of this element represent

Jump to

Keyboard shortcuts

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