Documentation ¶
Index ¶
- Constants
- Variables
- func FullVarName(name string) string
- func GetFactory() *factory.FlexObjFactory
- func GetFieldName(f string) string
- type APISampleInput
- type APISampleOutput
- type CreateSampleDataor
- type DelayedJSONDecoder
- type Enum
- func (e Enum) EncodingToMIME() (string, error)
- func (e Enum) IsAction() bool
- func (e Enum) IsBody() bool
- func (e Enum) IsField() bool
- func (e Enum) IsHeader() bool
- func (e Enum) IsHeaderAcceptable() bool
- func (e Enum) IsHide() bool
- func (e Enum) IsNullable() bool
- func (e Enum) IsPath() bool
- func (e Enum) IsPredefineable() bool
- func (e Enum) IsQuery() bool
- func (e Enum) IsStringer() bool
- func (e Enum) IsTimestamp() bool
- func (e Enum) SameIn(o Enum) bool
- func (e Enum) String() string
- type FieldRef
- type FlexJSONObject
- type FmtAPIInOut
- type GenSampler
- type InputNodeDetail
- type InputValue
- func (v InputValue) CreateSampleData(val interface{}, titleFirst bool) value.JSONValue
- func (v *InputValue) DelayedJSONDecode() error
- func (v InputValue) DenyFieldRefer() error
- func (v *InputValue) Empty() bool
- func (v InputValue) GetAsString() string
- func (v InputValue) GetName(titleFirst bool) string
- type NamedType
- type NamedValue
- type OutputNodeDetail
- type RequestArgs
- type Stringer
- type Stringifier
- type SwagConstValue
- type SwagConstValueSet
- type ValAction
- type ValArray
- type ValArrayString
- func (v *ValArrayString) DelayedJSONDecode() error
- func (v ValArrayString) GenSample(val interface{}, titleFirst bool) value.JSONValue
- func (v ValArrayString) MarshalJSON() ([]byte, error)
- func (v *ValArrayString) SetString(s string)
- func (v ValArrayString) String() string
- func (v ValArrayString) TypeName() string
- func (v *ValArrayString) UnmarshalJSON(data []byte) error
- type ValBoolean
- type ValNumber
- type ValObject
- type ValString
- type ValTimestamp
- type Value
- type ValueDefine
- type ValueSet
- func (v *ValueSet) AddExKV(key, value string, kind, in Enum) error
- func (v *ValueSet) AddKV(key, value string, kind, in Enum) error
- func (v *ValueSet) DelayedJSONDecode() error
- func (v ValueSet) GetAction() *SwagConstValue
- func (v ValueSet) PrepareRequest(args *RequestArgs) error
- func (s *ValueSet) ReplacePathArgs(srcURL string, name string) (string, error)
- func (s *ValueSet) ResolvePathArgs(srcURL string, nodeName string) (string, []string, error)
Constants ¶
const ( // DefaultEncoding is default encoding when empty DefaultEncoding = consts.DefaultEncoding // PolyEncoding is encoding by poly api PolyEncoding = consts.PolyEncoding )
Variables ¶
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
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") // XValTypeField represent value like req.data.userId ValTypeField = ValTypeEnum.MustReg("field") ValTypeArrayString = ValTypeEnum.MustReg("array_string") )
basic types
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) )
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) )
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
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
Functions ¶
func FullVarName ¶
FullVarName get the full variable of poly API
func GetFieldName ¶
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"` 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 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 ¶
Enum exports
func (Enum) EncodingToMIME ¶
EncodingToMIME change encoding like JSON to MIME like "application/json"
func (Enum) IsHeaderAcceptable ¶
IsHeaderAcceptable judege if is a header-acceptable parameter
func (Enum) IsNullable ¶
IsNullable judge if the data field is nullable
func (Enum) IsPredefineable ¶
IsPredefineable judge if a value is predefineable
func (Enum) IsStringer ¶
IsStringer judge if a value is able to convert to string
func (Enum) IsTimestamp ¶
IsTimestamp judge if a value type is timestamp
type FieldRef ¶
type FieldRef string
FieldRef is field reference
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 ¶
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 struct { //Value // type of this value: // number|string|boolean|object|array|arrayelem|null|undefined|field| // mergeobj|filter|expr|exprcmp|exprsel|exprgroup Type Enum `json:"type"` Name string `json:"name,omitempty"` // 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 In Enum `json:"in"` // header|path|body }
InputValue represent a const value input
func (InputValue) CreateSampleData ¶
func (v InputValue) CreateSampleData(val interface{}, titleFirst bool) value.JSONValue
CreateSampleData generate a sample JSON value
func (*InputValue) DelayedJSONDecode ¶
func (v *InputValue) DelayedJSONDecode() error
DelayedJSONDecode delay unmarshal flex json object
func (InputValue) DenyFieldRefer ¶
func (v InputValue) DenyFieldRefer() error
DenyFieldRefer assert this value don't refer a field value
func (InputValue) GetAsString ¶
func (v InputValue) GetAsString() string
GetAsString return Value as string if it contains that.
func (InputValue) GetName ¶
func (v InputValue) GetName(titleFirst bool) string
GetName return name of input value
type NamedValue ¶
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 struct { Name string // Name of the request node URL string // URL of a request EncodingPoly string // Content-Type, of poly call EncodingIn string // Content-Type of request api, json/xml/yaml Body []byte // request body Header http.Header // request header Action string // action of this request // contains filtered or unexported fields }
RequestArgs represents a request parament of a request
type Stringer ¶
Stringer define an interface with String()
func NewStringer ¶
NewStringer create a string-like value
type Stringifier ¶
type Stringifier interface {
String() string
}
Stringifier is an interface to convert to string only
type ValAction ¶
type ValAction ValString
ValAction represents action string
func (*ValAction) DelayedJSONDecode ¶
DelayedJSONDecode delay unmarshal flex json object
type ValArray ¶
type ValArray []Value
ValArray represents an array value, [...]
func (*ValArray) DelayedJSONDecode ¶
DelayedJSONDecode delay unmarshal flex json object
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) 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 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) TypeName ¶
func (v ValBoolean) TypeName() string
TypeName returns name of the type
type ValNumber ¶
type ValNumber ValString
ValNumber represents number value, deal as string
func (*ValNumber) DelayedJSONDecode ¶
DelayedJSONDecode delay unmarshal flex json object
type ValObject ¶
type ValObject ValArray
ValObject represents an object value, {...}
func (*ValObject) DelayedJSONDecode ¶
DelayedJSONDecode delay unmarshal flex json object
type ValString ¶
type ValString string
ValString represents string value
func (*ValString) DelayedJSONDecode ¶
DelayedJSONDecode delay unmarshal flex json object
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) 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 ¶
CreateSampleData generate a sample JSON value
func (*Value) DelayedJSONDecode ¶
DelayedJSONDecode delay unmarshal flex json object
func (Value) DenyFieldRefer ¶
DenyFieldRefer assert this value don't refer a field value
func (Value) GetAsString ¶
GetAsString return Value as string if it contains that.
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 []InputValue
ValueSet represents a set of value for input
func (*ValueSet) AddExKV ¶
AddExKV add or update a named string value in this object without type check
func (*ValueSet) DelayedJSONDecode ¶
DelayedJSONDecode delay unmarshal flex json object
func (ValueSet) GetAction ¶
func (v ValueSet) GetAction() *SwagConstValue
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 ¶
ReplacePathArgs replace args in path from the input values