Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidArgName(s string) bool
- func ParseVarTypeExpr(schema *WebRPCSchema, expr string, vt *VarType) error
- type CoreType
- type Error
- type Method
- type MethodArgument
- type Parser
- type Reader
- type Service
- type Type
- type TypeExtra
- type TypeField
- type TypeFieldMeta
- type VarListType
- type VarMapType
- type VarName
- type VarStructType
- type VarType
- type WebRPCSchema
Constants ¶
View Source
const ( TypeKind_Struct = "struct" TypeKind_Enum = "enum" )
View Source
const (
SCHEMA_VERSION = "v1"
)
Variables ¶
View Source
var CoreTypeFromString = map[string]CoreType{ "null": T_Null, "any": T_Any, "byte": T_Byte, "bool": T_Bool, "uint": T_Uint, "uint8": T_Uint8, "uint16": T_Uint16, "uint32": T_Uint32, "uint64": T_Uint64, "int": T_Int, "int8": T_Int8, "int16": T_Int16, "int32": T_Int32, "int64": T_Int64, "float32": T_Float32, "float64": T_Float64, "string": T_String, "timestamp": T_Timestamp, "map": T_Map, "[]": T_List, }
View Source
var CoreTypeToString = map[CoreType]string{ T_Null: "null", T_Any: "any", T_Byte: "byte", T_Bool: "bool", T_Uint: "uint", T_Uint8: "uint8", T_Uint16: "uint16", T_Uint32: "uint32", T_Uint64: "uint64", T_Int: "int", T_Int8: "int8", T_Int16: "int16", T_Int32: "int32", T_Int64: "int64", T_Float32: "float32", T_Float64: "float64", T_String: "string", T_Timestamp: "timestamp", T_Map: "map", T_List: "[]", }
View Source
var NameWhitelistRexp = regexp.MustCompile(`^[a-zA-Z]+[a-zA-Z0-9_]*$`)
Functions ¶
func IsValidArgName ¶
func ParseVarTypeExpr ¶ added in v0.2.0
func ParseVarTypeExpr(schema *WebRPCSchema, expr string, vt *VarType) error
Types ¶
type CoreType ¶ added in v0.9.0
type CoreType int
func (CoreType) MarshalJSON ¶ added in v0.9.0
func (*CoreType) UnmarshalJSON ¶ added in v0.9.0
type Error ¶ added in v0.11.0
type Error struct { Code int `json:"code"` Name string `json:"name"` Message string `json:"message"` HTTPStatus int `json:"httpStatus"` }
func (*Error) Parse ¶ added in v0.11.0
func (s *Error) Parse(schema *WebRPCSchema) error
type Method ¶
type Method struct { Name string `json:"name"` Comments []string `json:"comments"` StreamInput bool `json:"streamInput,omitempty"` StreamOutput bool `json:"streamOutput,omitempty"` Proxy bool `json:"-"` // TODO: actual implementation Inputs []*MethodArgument `json:"inputs"` Outputs []*MethodArgument `json:"outputs"` Service *Service `json:"-"` // denormalize/back-reference }
type MethodArgument ¶
type Parser ¶
type Parser interface {
Parse(schema *WebRPCSchema) error
}
type Reader ¶ added in v0.5.0
type Reader struct { File string // contains filtered or unexported fields }
type Service ¶
type Service struct { Name string `json:"name"` Methods []*Method `json:"methods"` Comments []string `json:"comments"` Schema *WebRPCSchema `json:"-"` // denormalize/back-reference }
func (*Service) Parse ¶
func (s *Service) Parse(schema *WebRPCSchema) error
type Type ¶ added in v0.9.0
type Type struct { Kind string `json:"kind"` Name string `json:"name"` Type *VarType `json:"type,omitempty"` Fields []*TypeField `json:"fields,omitempty"` TypeExtra `json:",omitempty"` Comments []string `json:"comments,omitempty"` }
func (*Type) Parse ¶ added in v0.9.0
func (t *Type) Parse(schema *WebRPCSchema) error
func (*Type) RequiredFields ¶ added in v0.14.2
type TypeExtra ¶ added in v0.9.0
type TypeExtra struct { Optional bool `json:"optional,omitempty"` // used by structs Value string `json:"value,omitempty"` // used by enums // Meta store extra metadata on a field for plugins Meta []TypeFieldMeta `json:"meta,omitempty"` }
type TypeFieldMeta ¶ added in v0.9.0
type TypeFieldMeta map[string]interface{}
type VarListType ¶
type VarListType struct {
Elem *VarType
}
type VarMapType ¶
type VarName ¶
type VarName string
func (VarName) TitleDowncase ¶
TitleDowncase will downcase the first letter of a string, ie. convert a name form 'FirstName' to 'firstName'
func (VarName) TitleUpcase ¶
TitleUpcase will upcase the first letter of a string, ie. convert a name form 'firstName' to 'FirstName'
type VarStructType ¶
type VarType ¶
type VarType struct { Expr string // Type, ie. map<string,map<string,uint32>> or []User Type CoreType // Kind, ie. int, map or struct Comments []string `json:"comments,omitempty"` List *VarListType Map *VarMapType Struct *VarStructType }
func (*VarType) MarshalJSON ¶
func (*VarType) Parse ¶
func (t *VarType) Parse(schema *WebRPCSchema) error
func (*VarType) UnmarshalJSON ¶
type WebRPCSchema ¶
type WebRPCSchema struct { WebrpcVersion string `json:"webrpc"` SchemaName string `json:"name"` SchemaVersion string `json:"version"` Types []*Type `json:"types"` Errors []*Error `json:"errors"` Services []*Service `json:"services"` // Deprecated. Renamed to Types. Keep this field for now, so we can // error out & advise users to migrate to v0.9.0+ schema format. Deprecated_Messages []interface{} `json:"messages,omitempty"` }
schema of webrpc json file, and validations
func ParseSchemaJSON ¶ added in v0.2.0
func ParseSchemaJSON(jsondata []byte) (*WebRPCSchema, error)
func (*WebRPCSchema) GetServiceByName ¶ added in v0.3.0
func (s *WebRPCSchema) GetServiceByName(name string) *Service
func (*WebRPCSchema) GetTypeByName ¶ added in v0.9.0
func (s *WebRPCSchema) GetTypeByName(name string) *Type
func (*WebRPCSchema) SchemaHash ¶ added in v0.4.0
func (s *WebRPCSchema) SchemaHash() (string, error)
func (*WebRPCSchema) ToJSON ¶ added in v0.2.0
func (s *WebRPCSchema) ToJSON() (string, error)
func (*WebRPCSchema) Validate ¶ added in v0.5.0
func (s *WebRPCSchema) Validate() error
Validate validates the schema through the AST, intended to be called after the json has been unmarshalled
Source Files ¶
Click to show internal directories.
Click to hide internal directories.