Documentation ¶
Index ¶
- Constants
- Variables
- func IsBuiltIn(name string) bool
- func NewOpenAPILoader(logger *logrus.Logger, fs afero.Fs) *openapi3.SwaggerLoader
- type Alias
- type Array
- type Endpoint
- type Enum
- type ExternalAlias
- type Field
- type FieldList
- type Format
- type Func
- type ImportedBuiltInAlias
- type Importer
- type IndentWriter
- type MethodEndpoints
- type OpenAPI2Importer
- type OutputData
- type Param
- type Parameters
- type Response
- type Spanner
- type SpannerDir
- type StandardType
- type SyslBuiltIn
- type SyslInfo
- type Type
- type TypeList
- type Union
- type XSDImporter
Constants ¶
const ( StringTypeName = "string" ObjectTypeName = "object" ArrayTypeName = "array" EmptyTypeName = "" BooleanTypeName = "boolean" IntegerTypeName = "integer" NumberTypeName = "number" )
const ( MinOnly maxType = iota MaxSpecified OpenEnded )
const BlankLine = "&& !!"
const CommentLineLength = 80
const PopIndent = "&& <<"
const PushIndent = "&& >>"
Variables ¶
var Avro = Format{ Name: "avro", Signature: "", FileExt: []string{".avsc"}, }
var Formats = []Format{ Grammar, OpenAPI3, Swagger, XSD, Avro, SpannerSQL, SpannerSQLDir, }
var Grammar = Format{ Name: "grammar", Signature: "", FileExt: []string{".g"}, }
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
var SYSL = Format{ Name: "sysl", Signature: "", FileExt: []string{".sysl"}, }
var SpannerSQL = Format{ Name: "spannerSQL", Signature: "", FileExt: []string{".sql"}, }
var SpannerSQLDir = Format{ Name: "spannerSQLdir", Signature: "", FileExt: []string{".up.sql"}, }
var StringAlias = &SyslBuiltIn{name: StringTypeName}
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
var XSD = Format{ Name: "xsd", Signature: ``, FileExt: []string{".xsd", ".xml"}, }
Functions ¶
func NewOpenAPILoader ¶ added in v0.136.0
Types ¶
type Endpoint ¶
type Endpoint struct { Path string Description string Params Parameters Responses []Response }
type ExternalAlias ¶
func (*ExternalAlias) Name ¶
func (s *ExternalAlias) Name() string
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
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 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
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
NewAvroImporter returns a new avroImporter.
type IndentWriter ¶
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 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 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) 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 Spanner ¶ added in v0.208.0
type Spanner struct {
// contains filtered or unexported fields
}
Spanner encapsulates glue code for calling arrai scripts which in turn ingests spanner sql.
func MakeSpannerImporter ¶ added in v0.208.0
MakeSpannerImporter is a factory method for creating new spanner sql importer.
func (*Spanner) LoadFile ¶ added in v0.238.0
LoadFile generates a Sysl spec equivalent to the sum of the statements in the specified SQL file.
func (*Spanner) WithAppName ¶ added in v0.208.0
WithAppName allows the exported Sysl application name to be specified.
func (*Spanner) WithPackage ¶ added in v0.208.0
WithPackage allows the exported Sysl package attribute to be specified.
type SpannerDir ¶ added in v0.238.0
type SpannerDir struct {
// contains filtered or unexported fields
}
SpannerDir encapsulates glue code for calling arrai scripts which in turn ingests spanner sql.
func MakeSpannerDirImporter ¶ added in v0.238.0
func MakeSpannerDirImporter(logger *logrus.Logger) *SpannerDir
MakeSpannerImporter is a factory method for creating new spanner sql importer.
func (*SpannerDir) Load ¶ added in v0.238.0
func (s *SpannerDir) Load(string) (string, error)
Load is not implemented, since SpannerDir importing requires a directory.
func (*SpannerDir) LoadFile ¶ added in v0.238.0
func (s *SpannerDir) LoadFile(path string) (string, error)
LoadFile takes a path to a directory of migration SQL scripts (.up.sql) and generates a Sysl spec representing the sum of statements in those scripts.
func (*SpannerDir) WithAppName ¶ added in v0.238.0
func (s *SpannerDir) WithAppName(appName string) Importer
WithAppName allows the exported Sysl application name to be specified.
func (*SpannerDir) WithPackage ¶ added in v0.238.0
func (s *SpannerDir) WithPackage(packageName string) Importer
WithPackage allows the exported Sysl package attribute to be specified.
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 Union ¶
type Union struct { Options FieldList // contains filtered or unexported fields }
Union represents a union type https://sysl.io/docs/lang-spec#union
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