importer

package
v0.335.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StringTypeName  = "string"
	ObjectTypeName  = "object"
	ArrayTypeName   = "array"
	EmptyTypeName   = ""
	BooleanTypeName = "boolean"
	IntegerTypeName = "integer"
	NumberTypeName  = "number"
)
View Source
const (
	MinOnly maxType = iota
	MaxSpecified
	OpenEnded
)
View Source
const BlankLine = "&& !!"
View Source
const CommentLineLength = 80
View Source
const PopIndent = "&& <<"
View Source
const PushIndent = "&& >>"

Variables

View Source
var Avro = Format{
	Name:      "avro",
	Signature: "",
	FileExt:   []string{".avsc"},
}
View Source
var Grammar = Format{
	Name:      "grammar",
	Signature: "",
	FileExt:   []string{".g"},
}
View Source
var MySQL = Format{
	Name:      "mysql",
	Signature: "",
	FileExt:   []string{".sql"},
}
View Source
var MySQLDir = Format{
	Name:      "mysqlDir",
	Signature: "",
	FileExt:   []string{".up.sql"},
}
View Source
var OpenAPI3 = Format{
	Name:      "openapi3",
	Signature: `openapi:`,
	FileExt:   []string{".yaml", ".json", ".yml"},
}

OpenAPI3 is identified by the openapi header. - The value MUST be "3.x.x". For more details refer to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#oasDocument

View Source
var Postgres = Format{
	Name:      "postgres",
	Signature: "",
	FileExt:   []string{".sql"},
}
View Source
var PostgresDir = Format{
	Name:      "postgresDir",
	Signature: "",
	FileExt:   []string{".up.sql"},
}
View Source
var SYSL = Format{
	Name:      "sysl",
	Signature: "",
	FileExt:   []string{".sysl"},
}
View Source
var SpannerSQL = Format{
	Name:      "spannerSQL",
	Signature: "",
	FileExt:   []string{".sql"},
}
View Source
var SpannerSQLDir = Format{
	Name:      "spannerSQLdir",
	Signature: "",
	FileExt:   []string{".up.sql"},
}
View Source
var StringAlias = &SyslBuiltIn{name: StringTypeName}
View Source
var Swagger = Format{
	Name:      "swagger",
	Signature: `swagger:`,
	FileExt:   []string{".yaml", ".json", ".yml"},
}

Swagger only has 2.0.0 as the single valid format - The value MUST be "2.0". For more details refer to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swaggerObject

View Source
var XSD = Format{
	Name:      "xsd",
	Signature: ``,
	FileExt:   []string{".xsd", ".xml"},
}

Functions

func IsBuiltIn

func IsBuiltIn(name string) bool

func NewOpenAPILoader added in v0.136.0

func NewOpenAPILoader(logger *logrus.Logger, fs afero.Fs) *openapi3.SwaggerLoader

Types

type Alias

type Alias struct {
	Target Type
	Attrs  []string
	// contains filtered or unexported fields
}

!alias type without the EXTERNAL_ prefix

func (*Alias) Name

func (s *Alias) Name() string

type ArraiImporter added in v0.291.0

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

ArraiImporter encapsulates glue code for calling arr.ai scripts to import specs.

func MakeArraiImporterImporter added in v0.291.0

func MakeArraiImporterImporter(asset string, logger *logrus.Logger) *ArraiImporter

MakeArraiImporterImporter returns a new ArraiImporter.

func MakeMySQLDirImporter added in v0.326.0

func MakeMySQLDirImporter(logger *logrus.Logger) *ArraiImporter

MakeMySQLDirImporter is a factory method for creating new PostgreSQL directory importer.

func MakeMySQLImporter added in v0.326.0

func MakeMySQLImporter(logger *logrus.Logger) *ArraiImporter

MakeMySQLImporter is a factory method for creating new MySQL SQL importer.

func MakePostgresqlDirImporter added in v0.291.0

func MakePostgresqlDirImporter(logger *logrus.Logger) *ArraiImporter

MakePostgresqlDirImporter is a factory method for creating new PostgreSQL directory importer.

func MakePostgresqlImporter added in v0.291.0

func MakePostgresqlImporter(logger *logrus.Logger) *ArraiImporter

MakePostgresqlImporter is a factory method for creating new PostgreSQL importer.

func MakeSpannerDirImporter added in v0.238.0

func MakeSpannerDirImporter(logger *logrus.Logger) *ArraiImporter

MakeSpannerDirImporter is a factory method for creating new Spanner SQL directory importer.

func MakeSpannerImporter added in v0.208.0

func MakeSpannerImporter(logger *logrus.Logger) *ArraiImporter

MakeSpannerImporter is a factory method for creating new Spanner SQL importer.

func (*ArraiImporter) Load added in v0.291.0

func (i *ArraiImporter) Load(content string) (string, error)

Load generates a Sysl spec given the content of an input file. This is not implemented.

func (*ArraiImporter) LoadFile added in v0.291.0

func (i *ArraiImporter) LoadFile(path string) (string, error)

LoadFile generates a Sysl spec be invoking the arr.ai script.

func (*ArraiImporter) WithAppName added in v0.291.0

func (i *ArraiImporter) WithAppName(appName string) Importer

WithAppName allows the exported Sysl application name to be specified.

func (*ArraiImporter) WithPackage added in v0.291.0

func (i *ArraiImporter) WithPackage(packageName string) Importer

WithPackage allows the exported Sysl package attribute to be specified.

type Array

type Array struct {
	Items Type
	Attrs []string
	// contains filtered or unexported fields
}

func (*Array) Name

func (s *Array) Name() string

type Endpoint

type Endpoint struct {
	Path        string
	Description string

	Params Parameters

	Responses []Response
}

type Enum

type Enum struct {
	Attrs []string
	// contains filtered or unexported fields
}

func (*Enum) Name

func (s *Enum) Name() string

type ExternalAlias

type ExternalAlias struct {
	Target Type
	Attrs  []string
	// contains filtered or unexported fields
}

func (*ExternalAlias) Name

func (s *ExternalAlias) Name() string

type Field

type Field struct {
	Name       string
	Type       Type
	Optional   bool
	Attributes []string
	SizeSpec   *sizeSpec
}

type FieldList

type FieldList []Field

type Format added in v0.124.0

type Format struct {
	Name      string   // Name of the format
	Signature string   // This is a string which can be used to uniquely identify the format
	FileExt   []string // The file extension of the format
}

Format represents a format that can be imported into Sysl

func GuessFileType added in v0.124.0

func GuessFileType(path string, isDir bool, content []byte, validFormats []Format) (Format, error)

GuessFileType detects the file based on the filename extension and the file itself. It returns the detected format if successful, or an error if not. It first tries to match the file extensions before checking the files for signatures such as `swagger: "2.0"`.

type Func

type Func func(args OutputData, text string, logger *logrus.Logger) (out string, err error)

type ImportedBuiltInAlias

type ImportedBuiltInAlias struct {
	Target Type
	// contains filtered or unexported fields
}

func (*ImportedBuiltInAlias) Name

func (s *ImportedBuiltInAlias) Name() string

type Importer added in v0.124.0

type Importer interface {
	// Load reads in a file from path and returns the generated Sysl.
	LoadFile(path string) (string, error)
	// Load takes in a string in a format supported by an the importer
	// It returns the converted Sysl as a string.
	Load(file string) (string, error)
	// WithAppName allows the exported Sysl application name to be specified.
	WithAppName(appName string) Importer
	// WithPackage allows the exported Sysl package attribute to be specified.
	WithPackage(packageName string) Importer
}

Importer is an interface implemented by all sysl importers

func Factory added in v0.124.0

func Factory(path string, isDir bool, format string, content []byte, logger *logrus.Logger) (Importer, error)

Factory takes in an absolute path and its contents (if path is a file) and returns an importer for the detected file type.

func NewAvroImporter added in v0.217.0

func NewAvroImporter(logger *logrus.Logger) Importer

NewAvroImporter returns a new avroImporter.

func NewOpenAPIV3Importer added in v0.136.0

func NewOpenAPIV3Importer(logger *logrus.Logger, fs afero.Fs) Importer

type IndentWriter

type IndentWriter struct {
	io.Writer
	// contains filtered or unexported fields
}

func NewIndentWriter

func NewIndentWriter(text string, out io.Writer) *IndentWriter

func (*IndentWriter) CurrentIndentLen

func (i *IndentWriter) CurrentIndentLen() int

func (*IndentWriter) Pop

func (i *IndentWriter) Pop()

func (*IndentWriter) Push

func (i *IndentWriter) Push()

func (*IndentWriter) Write

func (i *IndentWriter) Write() error

type MethodEndpoints

type MethodEndpoints struct {
	Method    string // one of GET, POST, PUT, OPTION, etc
	Endpoints []Endpoint
}

type OpenAPI2Importer added in v0.124.0

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

func MakeOpenAPI2Importer added in v0.124.0

func MakeOpenAPI2Importer(logger *logrus.Logger, basePath string, filePath string) *OpenAPI2Importer

func (*OpenAPI2Importer) Load added in v0.124.0

func (l *OpenAPI2Importer) Load(oas2spec string) (string, error)

func (*OpenAPI2Importer) LoadFile added in v0.238.0

func (l *OpenAPI2Importer) LoadFile(path string) (string, error)

func (*OpenAPI2Importer) WithAppName added in v0.124.0

func (l *OpenAPI2Importer) WithAppName(appName string) Importer

Set the AppName of the imported app

func (*OpenAPI2Importer) WithPackage added in v0.124.0

func (l *OpenAPI2Importer) WithPackage(pkg string) Importer

Set the package attribute of the imported app

type OutputData

type OutputData struct {
	AppName     string
	Package     string
	SwaggerRoot string
	Mode        string
}

type Param

type Param struct {
	Field
	In string
}

type Parameters

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

func (*Parameters) Add

func (p *Parameters) Add(param Param)

func (Parameters) BodyParams

func (p Parameters) BodyParams() []Param

func (Parameters) CookieParams added in v0.314.0

func (p Parameters) CookieParams() []Param

func (*Parameters) Extend added in v0.5.0

func (p *Parameters) Extend(others Parameters) Parameters

func (Parameters) HeaderParams

func (p Parameters) HeaderParams() []Param

func (Parameters) PathParams

func (p Parameters) PathParams() []Param

func (Parameters) QueryParams

func (p Parameters) QueryParams() []Param

type Response

type Response struct {
	Text string
	Type Type
}

Response is either going to be freetext or a type

type StandardType

type StandardType struct {
	Properties FieldList
	Attributes []string
	// contains filtered or unexported fields
}

func (*StandardType) Name

func (s *StandardType) Name() string

type SyslBuiltIn

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

func (*SyslBuiltIn) Name

func (s *SyslBuiltIn) Name() string

type SyslInfo

type SyslInfo struct {
	OutputData

	Title       string
	Description string
	OtherFields []string // Ordered key, val pair
}

type Type

type Type interface {
	Name() string
}

func NewStringAlias

func NewStringAlias(name string, attrs ...string) Type

type TypeList

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

func (*TypeList) Add

func (t *TypeList) Add(item ...Type)

func (*TypeList) AddAndRet added in v0.5.0

func (t *TypeList) AddAndRet(item Type) Type

func (TypeList) Find

func (t TypeList) Find(name string) (Type, bool)

func (TypeList) Items

func (t TypeList) Items() []Type

func (TypeList) Sort

func (t TypeList) Sort()

type Union

type Union struct {
	Options FieldList
	// contains filtered or unexported fields
}

Union represents a union type https://sysl.io/docs/lang-spec#union

func (*Union) Name

func (u *Union) Name() string

type XSDImporter added in v0.124.0

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

func MakeXSDImporter added in v0.124.0

func MakeXSDImporter(logger *logrus.Logger) *XSDImporter

func (*XSDImporter) Load added in v0.124.0

func (i *XSDImporter) Load(input string) (string, error)

func (*XSDImporter) LoadFile added in v0.238.0

func (i *XSDImporter) LoadFile(path string) (string, error)

func (*XSDImporter) WithAppName added in v0.124.0

func (i *XSDImporter) WithAppName(appName string) Importer

Set the AppName of the imported app

func (*XSDImporter) WithPackage added in v0.124.0

func (i *XSDImporter) WithPackage(pkg string) Importer

Set the package attribute of the imported app

Jump to

Keyboard shortcuts

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