Documentation
¶
Overview ¶
Decimal is a big.Float equivalent that marshals to/from JSON.
Index ¶
- Constants
- Variables
- 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 Debug(args ...interface{})
- func Equivalent(obj1 interface{}, obj2 interface{}) bool
- func FormatComment(indent, prefix, comment string, maxcol int, extraPad bool) string
- func FormattedAnnotation(filename string, source string, prefix string, msg string, tok *Token, ...) string
- func Get(m map[string]interface{}, key string) interface{}
- 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 IsPreludeType(name string) bool
- func IsSymbolChar(ch rune, first bool) bool
- func IsUppercaseLetter(ch rune) bool
- func IsWhitespace(ch rune) bool
- func Json(obj interface{}) string
- func Kind(v interface{}) string
- func Pretty(obj interface{}) string
- func StripNamespace(target string) string
- func ToString(obj interface{}) string
- func Uncapitalize(s string) string
- type AST
- func (ast *AST) ExternalRefs(ns string) []string
- func (ast *AST) GetShape(id string) *Shape
- func (ast *AST) IDL(ns string) string
- func (ast *AST) Merge(src *AST) error
- func (ast *AST) NamespaceAndServiceVersion() (string, string, string)
- func (ast *AST) PutShape(id string, shape *Shape)
- func (ast *AST) Validate() error
- type AstGenerator
- type BaseGenerator
- type Decimal
- func (d *Decimal) AsBigFloat() *big.Float
- func (d *Decimal) AsFloat64() float64
- func (d *Decimal) AsInt() int
- func (d *Decimal) AsInt32() int32
- func (d *Decimal) AsInt64() int64
- func (d Decimal) MarshalJSON() ([]byte, error)
- func (d *Decimal) String() string
- func (d *Decimal) UnmarshalJSON(b []byte) error
- type Generator
- type IdlGenerator
- type IdlWriter
- func (w *IdlWriter) Begin()
- func (w *IdlWriter) Emit(format string, args ...interface{})
- func (w *IdlWriter) EmitBlobShape(name string, shape *Shape)
- func (w *IdlWriter) EmitBooleanShape(name string, shape *Shape)
- func (w *IdlWriter) EmitBooleanTrait(b bool, tname, indent string)
- func (w *IdlWriter) EmitCollectionShape(shapeName, name string, shape *Shape)
- func (w *IdlWriter) EmitCustomTrait(k string, v interface{}, indent string)
- func (w *IdlWriter) EmitDeprecatedTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitDocumentation(doc, indent string)
- func (w *IdlWriter) EmitEnumTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitExamplesTrait(opname string, raw interface{})
- func (w *IdlWriter) EmitHttpErrorTrait(rv interface{}, indent string)
- func (w *IdlWriter) EmitHttpTrait(rv interface{}, indent string)
- func (w *IdlWriter) EmitLengthTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitMapShape(name string, shape *Shape)
- func (w *IdlWriter) EmitNumericShape(shapeName, name string, shape *Shape)
- func (w *IdlWriter) EmitOperationShape(name string, shape *Shape)
- func (w *IdlWriter) EmitPaginatedTrait(d interface{})
- func (w *IdlWriter) EmitRangeTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitResourceShape(name string, shape *Shape)
- func (w *IdlWriter) EmitServiceShape(name string, shape *Shape)
- func (w *IdlWriter) EmitShape(name string, shape *Shape)
- func (w *IdlWriter) EmitSimpleShape(shapeName, name string)
- func (w *IdlWriter) EmitStringShape(name string, shape *Shape)
- func (w *IdlWriter) EmitStringTrait(v, tname, indent string)
- func (w *IdlWriter) EmitStructureShape(name string, shape *Shape)
- func (w *IdlWriter) EmitTagsTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitTimestampShape(name string, shape *Shape)
- func (w *IdlWriter) EmitTraitTrait(v interface{})
- func (w *IdlWriter) EmitTraits(traits *Struct, indent string)
- func (w *IdlWriter) EmitUnionShape(name string, shape *Shape)
- func (w *IdlWriter) End() string
- type Member
- type Model
- type Parser
- func (p *Parser) EndOfFileError() error
- func (p *Parser) Error(msg string) error
- func (p *Parser) ExpectIdentifier() (string, error)
- func (p *Parser) ExpectIdentifierArray() ([]string, error)
- func (p *Parser) ExpectIdentifierMap() (map[string]string, error)
- func (p *Parser) ExpectInt() (int, error)
- func (p *Parser) ExpectNumber() (*Decimal, error)
- func (p *Parser) ExpectString() (string, error)
- func (p *Parser) ExpectStringArray() ([]string, error)
- func (p *Parser) GetToken() *Token
- func (p *Parser) MergeComment(comment1 string, comment2 string) string
- func (p *Parser) Parse() error
- func (p *Parser) SyntaxError() error
- func (p *Parser) UngetToken()
- type Scanner
- type Shape
- type ShapeRef
- type Shapes
- type Struct
- func (s *Struct) Get(key string) interface{}
- func (s *Struct) Has(key string) bool
- func (s *Struct) Keys() []string
- func (s *Struct) Length() int
- func (s Struct) MarshalJSON() ([]byte, error)
- func (s *Struct) Put(key string, val interface{})
- func (s *Struct) String() string
- func (s *Struct) UnmarshalJSON(data []byte) error
- type Token
- type TokenType
Constants ¶
const BLACK = "\033[0;0m"
const BLUE = "\033[94m"
const DecimalPrecision = uint(250)
we establish this "reasonable" max precision
const GREEN = "\033[92m"
const IndentAmount = " "
Fix me: the unparser needs to unparse to a set of files, not a single file. One file for each namespace. When generating to stdio, these files should be concatenated, one per
const RED = "\033[0;31m"
const SmithyVersion = "1.0"
const UnspecifiedNamespace = "example"
const UnspecifiedVersion = "0.0"
const YELLOW = "\033[0;33m"
Variables ¶
var ImportFileExtensions = map[string][]string{ ".smithy": []string{"smithy"}, ".json": []string{"smithy"}, }
var ImportFormats = []string{
"smithy",
}
var ToolVersion string = "development version"
var Verbose bool
Functions ¶
func AsStringArray ¶
func AsStringArray(v interface{}) []string
func BaseFileName ¶
func Capitalize ¶
func Equivalent ¶
func Equivalent(obj1 interface{}, obj2 interface{}) bool
func FormatComment ¶
func FormattedAnnotation ¶
func GetStringArray ¶
func IsLowercaseLetter ¶
func IsPreludeType ¶
func IsSymbolChar ¶
func IsUppercaseLetter ¶
func IsWhitespace ¶
func StripNamespace ¶
func Uncapitalize ¶
Types ¶
type AST ¶
type AST struct {
Smithy string `json:"smithy"`
Metadata *Struct `json:"metadata,omitempty"`
Shapes *Shapes `json:"shapes,omitempty"`
}
func (*AST) ExternalRefs ¶
func (*AST) NamespaceAndServiceVersion ¶
ASTs don't have a preferred namespac, but IDL files do. When going back to IDL, getting the preferred namespace is desirable This project's parser emits metadata for the preferred namespace, but if that is missing, we have to guess. The algorithm here is to prefer the first service's namespace, if present, or the first non-non-smithy, non-aws namespace encountered.
type AstGenerator ¶
type AstGenerator struct {
BaseGenerator
}
type BaseGenerator ¶
type BaseGenerator struct {
Model *Model
OutDir string
ForceOverwrite bool
Err error
// contains filtered or unexported fields
}
func (*BaseGenerator) FileExists ¶
func (gen *BaseGenerator) FileExists(path string) bool
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 IdlGenerator ¶
type IdlGenerator struct {
BaseGenerator
}
type IdlWriter ¶
type IdlWriter struct {
// contains filtered or unexported fields
}
func (*IdlWriter) EmitBlobShape ¶
func (*IdlWriter) EmitBooleanShape ¶
func (*IdlWriter) EmitBooleanTrait ¶
func (*IdlWriter) EmitCollectionShape ¶
func (*IdlWriter) EmitCustomTrait ¶
func (*IdlWriter) EmitDeprecatedTrait ¶
func (*IdlWriter) EmitDocumentation ¶
func (*IdlWriter) EmitEnumTrait ¶
func (*IdlWriter) EmitExamplesTrait ¶
func (*IdlWriter) EmitHttpErrorTrait ¶
func (*IdlWriter) EmitHttpTrait ¶
func (*IdlWriter) EmitLengthTrait ¶
func (*IdlWriter) EmitMapShape ¶
func (*IdlWriter) EmitNumericShape ¶
func (*IdlWriter) EmitOperationShape ¶
func (*IdlWriter) EmitPaginatedTrait ¶
func (w *IdlWriter) EmitPaginatedTrait(d interface{})
func (*IdlWriter) EmitRangeTrait ¶
func (*IdlWriter) EmitResourceShape ¶
func (*IdlWriter) EmitServiceShape ¶
func (*IdlWriter) EmitSimpleShape ¶
func (*IdlWriter) EmitStringShape ¶
func (*IdlWriter) EmitStringTrait ¶
func (*IdlWriter) EmitStructureShape ¶
func (*IdlWriter) EmitTagsTrait ¶
func (*IdlWriter) EmitTimestampShape ¶
func (*IdlWriter) EmitTraitTrait ¶
func (w *IdlWriter) EmitTraitTrait(v interface{})
func (*IdlWriter) EmitTraits ¶
func (*IdlWriter) EmitUnionShape ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func AssembleModel ¶
func (*Model) Namespaces ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) EndOfFileError ¶
func (*Parser) ExpectIdentifier ¶
func (*Parser) ExpectIdentifierArray ¶
func (*Parser) ExpectIdentifierMap ¶
func (*Parser) ExpectNumber ¶
func (*Parser) ExpectString ¶
func (*Parser) ExpectStringArray ¶
func (*Parser) MergeComment ¶
func (*Parser) SyntaxError ¶
func (*Parser) UngetToken ¶
func (p *Parser) UngetToken()
type Shape ¶
type Shape struct {
Type string `json:"type"`
Traits *Struct `json:"traits,omitempty"` //service, resource, operation, apply
//List and Set
Member *Member `json:"member,omitempty"`
//Map
Key *Member `json:"key,omitempty"`
Value *Member `json:"value,omitempty"`
//Structure and Union
Members map[string]*Member `json:"members,omitempty"` //keys must be case-insensitively unique. For union, len(Members) > 0,
//Resource
Identifiers map[string]*ShapeRef `json:"identifiers,omitempty"`
//FIXME preserve resource identifier order?
Create *ShapeRef `json:"create,omitempty"`
Put *ShapeRef `json:"put,omitempty"`
Read *ShapeRef `json:"read,omitempty"`
Update *ShapeRef `json:"update,omitempty"`
Delete *ShapeRef `json:"delete,omitempty"`
List *ShapeRef `json:"list,omitempty"`
CollectionOperations []*ShapeRef `json:"collectionOperations,omitempty"`
//Resource and Service
Operations []*ShapeRef `json:"operations,omitempty"`
Resources []*ShapeRef `json:"resources,omitempty"`
//Operation
Input *ShapeRef `json:"input,omitempty"`
Output *ShapeRef `json:"output,omitempty"`
// Errors []*Member `json:"errors,omitempty"`
Errors []*ShapeRef `json:"errors,omitempty"`
//Service
Version string `json:"version,omitempty"`
// contains filtered or unexported fields
}
type Shapes ¶
type Shapes struct {
// contains filtered or unexported fields
}
a Shapes object is a map from Shape ID to *Shape. It preserves the order of its keys, unlike a Go map
func (Shapes) MarshalJSON ¶
func (*Shapes) UnmarshalJSON ¶
type Struct ¶
type Struct struct {
Bindings map[string]interface{}
// contains filtered or unexported fields
}