smithy

package
v1.6.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const SmithyVersion = "1.0"
View Source
const UnspecifiedNamespace = "example"
View Source
const UnspecifiedVersion = "0.0"

Variables

View Source
var StringValuesNeverEnum bool = false

set to true to prevent enum traits that have only values from ever becoming actul enum objects.

Functions

func AllTypeRefs

func AllTypeRefs(model *sadl.Model) map[string]bool

func EnsureNamespaced

func EnsureNamespaced(ns, name string) string

func Export

func Export(model *sadl.Model, out string, conf *sadl.Data, exportAst bool) error

func Import

func Import(paths []string, conf *sadl.Data) (*sadl.Model, error)

func IsValidFile

func IsValidFile(path string) bool

func WithAnnotation

func WithAnnotation(annos map[string]string, key string, value string) map[string]string

Types

type AST

type AST struct {
	Smithy   string                 `json:"smithy"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
	Shapes   map[string]*Shape      `json:"shapes,omitempty"`
}

func FromSADL

func FromSADL(model *sadl.Model, ns string) (*AST, error)

func (*AST) IDL

func (ast *AST) IDL(namespace string) string

Generate Smithy IDL to describe the Smithy model

func (*AST) NamespaceAndServiceVersion

func (ast *AST) NamespaceAndServiceVersion() (string, string, string)

type IdlWriter

type IdlWriter struct {
	// contains filtered or unexported fields
}

func (*IdlWriter) Begin

func (w *IdlWriter) Begin()

func (*IdlWriter) Emit

func (w *IdlWriter) Emit(format string, args ...interface{})

func (*IdlWriter) EmitBlobShape

func (w *IdlWriter) EmitBlobShape(name string, shape *Shape)

func (*IdlWriter) EmitBooleanShape

func (w *IdlWriter) EmitBooleanShape(name string, shape *Shape)

func (*IdlWriter) EmitBooleanTrait

func (w *IdlWriter) EmitBooleanTrait(b bool, tname, indent string)

func (*IdlWriter) EmitCollectionShape

func (w *IdlWriter) EmitCollectionShape(shapeName, name string, shape *Shape)

func (*IdlWriter) EmitDeprecatedTrait

func (w *IdlWriter) EmitDeprecatedTrait(v interface{}, indent string)

func (*IdlWriter) EmitDocumentation

func (w *IdlWriter) EmitDocumentation(doc, indent string)

func (*IdlWriter) EmitEnumTrait

func (w *IdlWriter) EmitEnumTrait(v interface{}, indent string)

func (*IdlWriter) EmitExamplesTrait added in v1.4.2

func (w *IdlWriter) EmitExamplesTrait(opname string, raw interface{})

func (*IdlWriter) EmitHttpErrorTrait

func (w *IdlWriter) EmitHttpErrorTrait(rv interface{}, indent string)

func (*IdlWriter) EmitHttpTrait

func (w *IdlWriter) EmitHttpTrait(rv interface{}, indent string)

func (*IdlWriter) EmitLengthTrait

func (w *IdlWriter) EmitLengthTrait(v interface{}, indent string)

func (*IdlWriter) EmitMapShape

func (w *IdlWriter) EmitMapShape(name string, shape *Shape)

func (*IdlWriter) EmitNumericShape

func (w *IdlWriter) EmitNumericShape(shapeName, name string, shape *Shape)

func (*IdlWriter) EmitOperationShape

func (w *IdlWriter) EmitOperationShape(name string, shape *Shape)

func (*IdlWriter) EmitPaginatedTrait added in v1.6.6

func (w *IdlWriter) EmitPaginatedTrait(d interface{})

func (*IdlWriter) EmitRangeTrait

func (w *IdlWriter) EmitRangeTrait(v interface{}, indent string)

func (*IdlWriter) EmitResourceShape

func (w *IdlWriter) EmitResourceShape(name string, shape *Shape)

func (*IdlWriter) EmitServiceShape

func (w *IdlWriter) EmitServiceShape(name string, shape *Shape)

func (*IdlWriter) EmitShape

func (w *IdlWriter) EmitShape(name string, shape *Shape)

func (*IdlWriter) EmitSimpleShape

func (w *IdlWriter) EmitSimpleShape(shapeName, name string)

func (*IdlWriter) EmitStringShape

func (w *IdlWriter) EmitStringShape(name string, shape *Shape)

func (*IdlWriter) EmitStringTrait

func (w *IdlWriter) EmitStringTrait(v, tname, indent string)

func (*IdlWriter) EmitStructureShape

func (w *IdlWriter) EmitStructureShape(name string, shape *Shape)

func (*IdlWriter) EmitTagsTrait

func (w *IdlWriter) EmitTagsTrait(v interface{}, indent string)

func (*IdlWriter) EmitTimestampShape

func (w *IdlWriter) EmitTimestampShape(name string, shape *Shape)

func (*IdlWriter) EmitTraits

func (w *IdlWriter) EmitTraits(traits map[string]interface{}, indent string)

func (*IdlWriter) EmitUnionShape

func (w *IdlWriter) EmitUnionShape(name string, shape *Shape)

func (*IdlWriter) End

func (w *IdlWriter) End() string

type Member

type Member struct {
	Target string                 `json:"target"`
	Traits map[string]interface{} `json:"traits,omitempty"`
}

type Model

type Model struct {
	// contains filtered or unexported fields
}

func NewModel

func NewModel(ast *AST) *Model

func (*Model) Merge

func (model *Model) Merge(another *Model) error

maybe filter by tag top include only parts?

func (*Model) ToSadl

func (model *Model) ToSadl(conf *sadl.Data) (*sadl.Model, error)

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func (*Parser) EndOfFileError

func (p *Parser) EndOfFileError() error

func (*Parser) Error

func (p *Parser) Error(msg string) error

func (*Parser) ExpectIdentifier

func (p *Parser) ExpectIdentifier() (string, error)

func (*Parser) ExpectIdentifierArray

func (p *Parser) ExpectIdentifierArray() ([]string, error)

func (*Parser) ExpectIdentifierMap

func (p *Parser) ExpectIdentifierMap() (map[string]string, error)

func (*Parser) ExpectInt

func (p *Parser) ExpectInt() (int, error)

func (*Parser) ExpectNumber

func (p *Parser) ExpectNumber() (*sadl.Decimal, error)

func (*Parser) ExpectString

func (p *Parser) ExpectString() (string, error)

func (*Parser) ExpectStringArray

func (p *Parser) ExpectStringArray() ([]string, error)

func (*Parser) GetToken

func (p *Parser) GetToken() *sadl.Token

func (*Parser) MergeComment

func (p *Parser) MergeComment(comment1 string, comment2 string) string

func (*Parser) Parse

func (p *Parser) Parse() error

func (*Parser) SyntaxError

func (p *Parser) SyntaxError() error

func (*Parser) UngetToken

func (p *Parser) UngetToken()

type Shape

type Shape struct {
	Type   string                 `json:"type"`
	Traits map[string]interface{} `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"`
	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"`
}

type ShapeRef

type ShapeRef struct {
	Target string `json:"target"`
}

Jump to

Keyboard shortcuts

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