Documentation ¶
Index ¶
- Constants
- Variables
- func NewOpenAPI3Loader(logger *logrus.Logger, fs afero.Fs) *openapi3.SwaggerLoader
- type Alias
- type ArraiImporter
- 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 OpenAPI3Importer
- type OpenAPIFormat
- type OutputData
- type Param
- type Parameters
- func (p *Parameters) Add(param Param)
- func (p Parameters) BodyParams() []Param
- func (p Parameters) CookieParams() []Param
- func (p *Parameters) Extend(others Parameters) Parameters
- func (p Parameters) HeaderParams() []Param
- func (p Parameters) PathParams() []Param
- func (p Parameters) QueryParams() []Param
- type Response
- type StandardType
- type SyslBuiltIn
- type SyslInfo
- type TransformImporter
- type Type
- type TypeList
- type Union
- type XSDImporter
Constants ¶
const ( OpenAPI_EMPTY = "" OpenAPI_STRING = "string" OpenAPI_OBJECT = "object" OpenAPI_ARRAY = "array" OpenAPI_BOOLEAN = "boolean" OpenAPI_INTEGER = "integer" OpenAPI_NUMBER = "number" )
OpenAPI Data Types: https://swagger.io/docs/specification/data-models/data-types/ nolint:revive,stylecheck
const ( MinOnly maxType = iota MaxSpecified OpenEnded )
const ArraiImporterDir = "pkg/importer"
const BlankLine = "&& !!"
const CommentLineLength = 80
const PopIndent = "&& <<"
const PushIndent = "&& >>"
Variables ¶
var ( XSD_BOOLEAN = strings.ToLower(xsd.Boolean.String()) XSD_BYTE = strings.ToLower(xsd.Byte.String()) XSD_DATE = strings.ToLower(xsd.Date.String()) XSD_DATETIME = strings.ToLower(xsd.DateTime.String()) XSD_DECIMAL = strings.ToLower(xsd.Decimal.String()) XSD_INT = strings.ToLower(xsd.Int.String()) XSD_INTEGER = strings.ToLower(xsd.Integer.String()) XSD_STRING = strings.ToLower(xsd.String.String()) XSD_TIME = strings.ToLower(xsd.Time.String()) XSD_NMTOKEN = strings.ToLower(xsd.NMTOKEN.String()) )
nolint:revive,stylecheck
var Avro = Format{ Name: "avro", Signature: "", FileExt: []string{".avsc"}, }
var BigQuery = Format{ Name: "bigquery", Signature: "", FileExt: []string{".sql"}, }
var Formats = []Format{ Grammar, OpenAPI3, OpenAPI2, XSD, Avro, SpannerSQL, SpannerSQLDir, Postgres, PostgresDir, MySQL, MySQLDir, BigQuery, JSONSchema, }
Formats lists all supported import formats TODO: Add all transform imports dynamically
var Grammar = Format{ Name: "grammar", Signature: "", FileExt: []string{".g"}, }
var JSONSchema = Format{ Name: "jsonschema", Signature: "$schema", FileExt: []string{".json"}, }
var MySQL = Format{ Name: "mysql", Signature: "", FileExt: []string{".sql"}, }
var MySQLDir = Format{ Name: "mysqlDir", Signature: "", FileExt: []string{".up.sql"}, }
var OpenAPI2 = Format{ Name: "swagger", Signature: `swagger:`, FileExt: []string{".yaml", ".json", ".yml"}, }
OpenAPI2 only has swagger 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 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 OpenAPIFormats = []OpenAPIFormat{ OpenAPIFormat_INT32, OpenAPIFormat_INT64, OpenAPIFormat_FLOAT, OpenAPIFormat_DOUBLE, OpenAPIFormat_DATE, OpenAPIFormat_DATETIME, OpenAPIFormat_BYTE, OpenAPIFormat_BINARY, OpenAPIFormat_UUID, }
OpenAPI string formats: https://swagger.io/docs/specification/data-models/data-types/ -> String Formats nolint:gochecknoglobals,revive,stylecheck
var Postgres = Format{ Name: "postgres", Signature: "", FileExt: []string{".sql"}, }
var PostgresDir = Format{ Name: "postgresDir", Signature: "", FileExt: []string{".up.sql"}, }
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: syslutil.Type_STRING}
var XSD = Format{ Name: "xsd", Signature: ``, FileExt: []string{".xsd", ".xml"}, }
Functions ¶
func NewOpenAPI3Loader ¶ added in v0.344.0
Types ¶
type Alias ¶
type Alias struct { Target Type // contains filtered or unexported fields }
!alias type without the EXTERNAL_ prefix
func (*Alias) AddAttributes ¶ added in v0.397.0
func (*Alias) Attributes ¶ added in v0.397.0
func (s *Alias) Attributes() []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 MakeSQLImporter ¶ added in v0.360.0
func MakeSQLImporter(logger *logrus.Logger) *ArraiImporter
MakeSQLImporter is a factory method for creating new 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.
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 // contains filtered or unexported fields }
func (*Array) AddAttributes ¶ added in v0.397.0
func (*Array) Attributes ¶ added in v0.397.0
func (s *Array) Attributes() []string
type Endpoint ¶
type Endpoint struct { Path string Description string Params Parameters Responses []Response }
type Enum ¶
type Enum struct {
// contains filtered or unexported fields
}
func (*Enum) AddAttributes ¶ added in v0.397.0
func (*Enum) Attributes ¶ added in v0.397.0
func (s *Enum) Attributes() []string
type ExternalAlias ¶
type ExternalAlias struct { Target Type // contains filtered or unexported fields }
func (*ExternalAlias) AddAttributes ¶ added in v0.397.0
func (*ExternalAlias) Attributes ¶ added in v0.397.0
func (s *ExternalAlias) Attributes() []string
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) AddAttributes ¶ added in v0.397.0
func (*ImportedBuiltInAlias) Attributes ¶ added in v0.397.0
func (s *ImportedBuiltInAlias) Attributes() []string
type Importer ¶ added in v0.124.0
type Importer interface { // LoadFile 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(content string) (string, error) // WithAppName allows the imported Sysl application name to be specified. WithAppName(appName string) Importer // WithPackage allows the imported 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, formatName 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
NewAvroImporter returns a new avroImporter.
func NewLegacyOpenAPIV3Importer ¶ added in v0.434.0
func NewOpenAPIV3Importer ¶ added in v0.136.0
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 ¶
func (MethodEndpoints) Sort ¶ added in v0.397.0
func (me MethodEndpoints) Sort()
type OpenAPI2Importer ¶ added in v0.124.0
type OpenAPI2Importer struct { *OpenAPI3Importer // 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 OpenAPI3Importer ¶ added in v0.124.0
type OpenAPI3Importer struct {
// contains filtered or unexported fields
}
func (*OpenAPI3Importer) Load ¶ added in v0.124.0
func (o *OpenAPI3Importer) Load(file string) (string, error)
func (*OpenAPI3Importer) LoadFile ¶ added in v0.344.0
func (o *OpenAPI3Importer) LoadFile(path string) (string, error)
func (*OpenAPI3Importer) WithAppName ¶ added in v0.124.0
func (o *OpenAPI3Importer) WithAppName(appName string) Importer
func (*OpenAPI3Importer) WithPackage ¶ added in v0.124.0
func (o *OpenAPI3Importer) WithPackage(packageName string) Importer
type OpenAPIFormat ¶ added in v0.344.0
type OpenAPIFormat = string
const ( OpenAPIFormat_INT32 OpenAPIFormat = "int32" OpenAPIFormat_INT64 OpenAPIFormat = "int64" OpenAPIFormat_FLOAT OpenAPIFormat = "float" OpenAPIFormat_DOUBLE OpenAPIFormat = "double" OpenAPIFormat_DATE OpenAPIFormat = "date" OpenAPIFormat_DATETIME OpenAPIFormat = "date-time" OpenAPIFormat_BYTE OpenAPIFormat = "byte" OpenAPIFormat_BINARY OpenAPIFormat = "binary" OpenAPIFormat_UUID OpenAPIFormat = "uuid" OpenAPIFormat_URI OpenAPIFormat = "uri" )
nolint:revive,stylecheck
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) 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 StandardType ¶
type StandardType struct { Properties FieldList // contains filtered or unexported fields }
func (*StandardType) AddAttributes ¶ added in v0.397.0
func (*StandardType) Attributes ¶
func (s *StandardType) Attributes() []string
type SyslBuiltIn ¶
type SyslBuiltIn struct {
// contains filtered or unexported fields
}
func (*SyslBuiltIn) AddAttributes ¶ added in v0.397.0
func (*SyslBuiltIn) Attributes ¶ added in v0.397.0
func (s *SyslBuiltIn) Attributes() []string
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 TransformImporter ¶ added in v0.431.0
type TransformImporter struct {
// contains filtered or unexported fields
}
TransformImporter enables importing from various formats by running embedded arr.ai transform scripts that convert data into Sysl.
func MakeTransformImporter ¶ added in v0.431.0
func MakeTransformImporter(logger *logrus.Logger, transformName string) *TransformImporter
func (*TransformImporter) Load ¶ added in v0.431.0
func (i *TransformImporter) Load(content string) (string, error)
Load generates a Sysl spec given the content of an input file.
func (*TransformImporter) LoadFile ¶ added in v0.431.0
func (i *TransformImporter) LoadFile(path string) (string, error)
LoadFile generates a Sysl spec by invoking the arr.ai transform.
func (*TransformImporter) WithAppName ¶ added in v0.431.0
func (i *TransformImporter) WithAppName(appName string) Importer
WithAppName allows the imported Sysl application name to be specified.
func (*TransformImporter) WithPackage ¶ added in v0.431.0
func (i *TransformImporter) WithPackage(_ string) Importer
WithPackage allows the imported Sysl package attribute to be specified.
type Type ¶
func NewStringAlias ¶
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) AddAttributes ¶ added in v0.397.0
func (*Union) Attributes ¶ added in v0.397.0
func (s *Union) Attributes() []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