Documentation ¶
Overview ¶
Decimal is a big.Float equivalent that marshals to/from JSON.
Index ¶
- Constants
- Variables
- func AnnotationsAsString(annos map[string]string) string
- func AsArray(v interface{}) []interface{}
- func AsBool(v interface{}) bool
- func AsFloat64(v interface{}) float64
- func AsInt(v interface{}) int
- func AsInt64(v interface{}) int64
- func AsMap(v interface{}) map[string]interface{}
- func AsString(v interface{}) string
- func AsStringArray(v interface{}) []string
- func BaseFileName(path string) string
- func Capitalize(s string) string
- func DataToFile(data *Data, path string) error
- func Debug(args ...interface{})
- func DecompileSadl(model *Model) string
- func Equivalent(obj1 interface{}, obj2 interface{}) bool
- func FormatComment(indent, prefix, comment string, maxcol int, extraPad bool) string
- func Get(m map[string]interface{}, key string) interface{}
- func GetAnnotation(annos map[string]string, key string) string
- func GetArray(m map[string]interface{}, key string) []interface{}
- func GetBool(m map[string]interface{}, key string) bool
- func GetInt(m map[string]interface{}, key string) int
- func GetInt64(m map[string]interface{}, key string) int64
- func GetMap(m map[string]interface{}, key string) map[string]interface{}
- func GetString(m map[string]interface{}, key string) string
- func GetStringArray(m map[string]interface{}, key string) []string
- func IsDigit(ch rune) bool
- func IsLetter(ch rune) bool
- func IsLowercaseLetter(ch rune) bool
- func IsSymbol(s string) bool
- func IsSymbolChar(ch rune, first bool) bool
- func IsUppercaseLetter(ch rune) bool
- func IsValidFile(path string) bool
- func IsWhitespace(ch rune) bool
- func Kind(v interface{}) string
- func Pretty(obj interface{}) string
- func ToString(obj interface{}) string
- func Uncapitalize(s string) string
- type Data
- func (data *Data) AsMap() map[string]interface{}
- func (data *Data) Get(keys ...string) interface{}
- func (data *Data) GetArray(keys ...string) []interface{}
- func (data *Data) GetBool(keys ...string) bool
- func (data *Data) GetData(keys ...string) *Data
- func (data *Data) GetDecimal(keys ...string) *Decimal
- func (data *Data) GetFloat64(keys ...string) float64
- func (data *Data) GetInt(keys ...string) int
- func (data *Data) GetInt64(keys ...string) int64
- func (data *Data) GetMap(keys ...string) map[string]interface{}
- func (data *Data) GetString(keys ...string) string
- func (data *Data) GetStringArray(keys ...string) []string
- func (data *Data) Has(keys ...string) bool
- func (data *Data) IsNil() bool
- func (d Data) MarshalJSON() ([]byte, error)
- func (data *Data) Put(key string, value interface{})
- func (data *Data) String() string
- func (d *Data) UnmarshalJSON(b []byte) error
- type Decimal
- type EnumElementDef
- type ExampleDef
- type Extension
- type Generator
- func (gen *Generator) Begin()
- func (gen *Generator) Capitalize(s string) string
- func (gen *Generator) Emit(s string)
- func (gen *Generator) EmitTemplate(name string, tmplSource string, data interface{}, funcMap template.FuncMap)
- func (gen *Generator) End() string
- func (gen *Generator) FileExists(path string) bool
- func (gen *Generator) FormatComment(indent, comment string, maxcol int, extraPad bool) string
- func (gen *Generator) GetConfigBool(k string, defaultValue bool) bool
- func (gen *Generator) GetConfigInt(k string, defaultValue int) int
- func (gen *Generator) GetConfigString(k string, defaultValue string) string
- func (gen *Generator) Uncapitalize(s string) string
- func (gen *Generator) WriteFile(path string, content string)
- type HttpDef
- type HttpExceptionSpec
- type HttpExpectedSpec
- type HttpParamSpec
- type Model
- func (model *Model) ConvertInlineEnums() error
- func (model *Model) EquivalentTypes(ts1, ts2 *TypeSpec) bool
- func (model *Model) EquivalentTypesByName(tname1, tname2 string) bool
- func (model *Model) FindExampleType(ex *ExampleDef) (*TypeSpec, error)
- func (model *Model) FindHttp(name string) *HttpDef
- func (model *Model) FindType(name string) *TypeDef
- func (model *Model) IsNumericType(td *TypeSpec) bool
- func (model *Model) IsStructField(ts *TypeSpec, name string) bool
- func (model *Model) Validate(context string, typename string, value interface{}) error
- func (model *Model) ValidateAgainstTypeSpec(context string, td *TypeSpec, value interface{}) error
- func (model *Model) ValidateArray(context string, td *TypeSpec, value interface{}) error
- func (model *Model) ValidateBool(context string, td *TypeSpec, value interface{}) error
- func (model *Model) ValidateEnum(context string, td *TypeSpec, value interface{}) error
- func (model *Model) ValidateMap(context string, td *TypeSpec, value interface{}) error
- func (model *Model) ValidateNumber(context string, td *TypeSpec, value interface{}) error
- func (model *Model) ValidateString(context string, td *TypeSpec, val interface{}) error
- func (model *Model) ValidateStruct(context string, td *TypeSpec, value interface{}) error
- func (model *Model) ValidateTimestamp(tname string, td *TypeSpec, val interface{}) error
- func (model *Model) ValidateUUID(context string, td *TypeSpec, value interface{}) error
- func (model *Model) ValidateUnitValue(context string, td *TypeSpec, value interface{}) error
- type OperationDef
- type OperationInput
- type OperationOutput
- type Options
- type Parser
- func (p *Parser) CurrentComment() string
- func (p *Parser) EndOfFileError() error
- func (p *Parser) EndOfStatement(comment string) (string, error)
- func (p *Parser) Error(msg string) error
- func (p *Parser) ExpectCompoundIdentifier() (string, error)
- func (p *Parser) ExpectIdentifier() (string, error)
- func (p *Parser) ExpectString() (string, error)
- func (p *Parser) GetToken() *scanner.Token
- func (p *Parser) IsBlockDone(comment string) (bool, string, error)
- func (p *Parser) MergeComment(comment1 string, comment2 string) string
- func (p *Parser) Model() *Model
- func (p *Parser) Parse(extensions []Extension) (*Model, error)
- func (p *Parser) ParseNoValidate(extensions []Extension) error
- func (p *Parser) ParseOptions(typeName string, acceptable []string) (*Options, error)
- func (p *Parser) ParseTrailingComment(comment string) string
- func (p *Parser) ParseTypeSpec(comment string) (*TypeSpec, *Options, string, error)
- func (p *Parser) ParseTypeSpecElements() (string, []string, []*StructFieldDef, []*EnumElementDef, *Options, string, ...)
- func (p *Parser) Source() string
- func (p *Parser) SyntaxError() error
- func (p *Parser) UngetToken()
- func (p *Parser) Validate() (*Model, error)
- type SadlGenerator
- type Schema
- type StructFieldDef
- type Timestamp
- type TypeDef
- type TypeSpec
- type UUID
- type UnionVariantDef
- type UnitValue
Constants ¶
View Source
const DecimalPrecision = uint(250)
we establish this "reasonable" max precision
View Source
const Length = 36
View Source
const RFC3339Milli = "%d-%02d-%02dT%02d:%02d:%02d.%03dZ"
View Source
const RegExUUID = "([a-f0-9]{8}(-[a-f0-9]{4}){4}[a-f0-9]{8})"
Variables ¶
View Source
var BaseTypes = []string{
"Bool",
"Int8",
"Int16",
"Int32",
"Int64",
"Float32",
"Float64",
"Decimal",
"Bytes",
"String",
"Timestamp",
"UnitValue",
"UUID",
"Array",
"Map",
"Struct",
"Enum",
"Union",
"Any",
}
View Source
var Verbose bool
View Source
var Version string = "development version"
Functions ¶
func AnnotationsAsString ¶ added in v1.8.1
func AsStringArray ¶
func AsStringArray(v interface{}) []string
func BaseFileName ¶
func Capitalize ¶
func DataToFile ¶
func DecompileSadl ¶
func Equivalent ¶
func Equivalent(obj1 interface{}, obj2 interface{}) bool
func FormatComment ¶
func GetStringArray ¶
func IsLowercaseLetter ¶
func IsSymbolChar ¶
func IsUppercaseLetter ¶
func IsValidFile ¶
func IsWhitespace ¶
func Uncapitalize ¶
Types ¶
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
func DataFromFile ¶
func DataFromJsonString ¶
func (*Data) GetDecimal ¶
func (*Data) GetFloat64 ¶ added in v1.7.1
func (*Data) GetStringArray ¶ added in v1.7.1
func (Data) MarshalJSON ¶
func (*Data) UnmarshalJSON ¶
type Decimal ¶
func DecimalValue ¶
func GetDecimal ¶
func NewDecimal ¶
func ParseDecimal ¶
func (*Decimal) AsBigFloat ¶
func (Decimal) MarshalJSON ¶
Encode as a JSON number. The JSON spec allows for arbitrary precision, so this is the correct thing to do.
func (*Decimal) UnmarshalJSON ¶
type EnumElementDef ¶
type ExampleDef ¶
type Generator ¶
type Generator struct { Config *Data OutDir string Err error // contains filtered or unexported fields }
func (*Generator) Capitalize ¶
func (*Generator) EmitTemplate ¶
func (*Generator) FileExists ¶
func (*Generator) FormatComment ¶
func (*Generator) GetConfigBool ¶
func (*Generator) GetConfigString ¶
func (*Generator) Uncapitalize ¶
type HttpDef ¶
type HttpDef struct { Name string `json:"name,omitempty"` Resource string `json:"resource,omitempty"` Comment string `json:"comment,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` Method string `json:"method"` Path string `json:"path"` Inputs []*HttpParamSpec `json:"inputs,omitempty"` Expected *HttpExpectedSpec `json:"expected,omitempty"` Exceptions []*HttpExceptionSpec `json:"exceptions,omitempty"` }
type HttpExceptionSpec ¶
type HttpExpectedSpec ¶
type HttpExpectedSpec struct { Outputs []*HttpParamSpec `json:"outputs,omitempty"` Status int32 `json:"status"` Comment string `json:"comment,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` }
type HttpParamSpec ¶
type HttpParamSpec struct { Header string `json:"header,omitempty"` Query string `json:"query,omitempty"` Path bool `json:"path,omitempty"` StructFieldDef }
type Model ¶
type Model struct { Schema Extensions map[string]interface{} `json:"extensions,omitempty"` // contains filtered or unexported fields }
func ParseSadlFile ¶
func ParseSadlString ¶
func (*Model) ConvertInlineEnums ¶
for every typedef and action parameter that has an inline enum def, create a toplevel enum def and refer to it instead. This reduces duplicate definitions. This produces an error if name conflicts cannot be resolved.
func (*Model) EquivalentTypes ¶
func (*Model) EquivalentTypesByName ¶
func (*Model) FindExampleType ¶
func (model *Model) FindExampleType(ex *ExampleDef) (*TypeSpec, error)
func (*Model) IsNumericType ¶
func (*Model) ValidateAgainstTypeSpec ¶
func (*Model) ValidateArray ¶
func (*Model) ValidateBool ¶
func (*Model) ValidateEnum ¶
func (*Model) ValidateMap ¶
func (*Model) ValidateNumber ¶
func (*Model) ValidateString ¶
func (*Model) ValidateStruct ¶
func (*Model) ValidateTimestamp ¶
func (*Model) ValidateUUID ¶
type OperationDef ¶ added in v1.8.0
type OperationDef struct { Name string `json:"name,omitempty"` Comment string `json:"comment,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` Inputs []*OperationInput `json:"inputs,omitempty"` Outputs []*OperationOutput `json:"outputs,omitempty"` Exceptions []string `json:"exceptions,omitempty"` }
type OperationInput ¶ added in v1.8.0
type OperationInput struct {
StructFieldDef
}
type OperationOutput ¶ added in v1.8.0
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) CurrentComment ¶
func (*Parser) EndOfFileError ¶
func (*Parser) ExpectCompoundIdentifier ¶
func (*Parser) ExpectIdentifier ¶
func (*Parser) ExpectString ¶
func (*Parser) MergeComment ¶
func (*Parser) ParseNoValidate ¶
func (*Parser) ParseOptions ¶
func (*Parser) ParseTrailingComment ¶
func (*Parser) ParseTypeSpec ¶
func (*Parser) ParseTypeSpecElements ¶
func (p *Parser) ParseTypeSpecElements() (string, []string, []*StructFieldDef, []*EnumElementDef, *Options, string, error)
func (*Parser) SyntaxError ¶
func (*Parser) UngetToken ¶
func (p *Parser) UngetToken()
type SadlGenerator ¶
func NewGenerator ¶
func NewGenerator(model *Model, outdir string) *SadlGenerator
func (*SadlGenerator) CreateSadlSource ¶
func (g *SadlGenerator) CreateSadlSource()
func (*SadlGenerator) Generate ¶
func (g *SadlGenerator) Generate() string
type Schema ¶
type Schema struct { Sadl string `json:"sadl"` Name string `json:"name"` Namespace string `json:"namespace,omitempty"` Version string `json:"version,omitempty"` Comment string `json:"comment,omitempty"` Types []*TypeDef `json:"types,omitempty"` Examples []*ExampleDef `json:"examples,omitempty"` Operations []*OperationDef `json:"operations,omitempty"` Http []*HttpDef `json:"http,omitempty"` Base string `json:"base,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` }
type StructFieldDef ¶
type Timestamp ¶
func ParseTimestamp ¶
func (Timestamp) MarshalJSON ¶
func (*Timestamp) UnmarshalJSON ¶
type TypeSpec ¶
type TypeSpec struct { Type string `json:"type"` Pattern string `json:"pattern,omitempty"` Values []string `json:"values,omitempty"` MinSize *int64 `json:"minSize,omitempty"` MaxSize *int64 `json:"maxSize,omitempty"` Fields []*StructFieldDef `json:"fields,omitempty"` Elements []*EnumElementDef `json:"elements,omitempty"` Min *Decimal `json:"min,string,omitempty"` Max *Decimal `json:"max,string,omitempty"` Items string `json:"items,omitempty"` Keys string `json:"keys,omitempty"` Variants []*UnionVariantDef `json:"variants,omitempty"` //FIXME: a variant element, so comments/annotations can be attached Unit string `json:"unit,omitempty"` Value string `json:"value,omitempty"` Reference string `json:"reference,omitempty"` }
type UnionVariantDef ¶
type UnitValue ¶
func NewUnitValue ¶
func ParseUnitValue ¶
func (*UnitValue) MarshalJSON ¶
func (*UnitValue) UnmarshalJSON ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.