schema

package
v0.4.24 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyTitle  = "title"
	KeyPlural = "plural"
)
View Source
const (
	LevelInfo = iota
	LevelWarn
	LevelError
)

Variables

View Source
var (
	OriginMySQL      = Origin{Key: "mysql", Title: "MySQL", Icon: "database", Description: "MySQL database schema"}
	OriginPostgres   = Origin{Key: "postgres", Title: "PostgreSQL", Icon: "database", Description: "PostgreSQL database schema"}
	OriginSQLite     = Origin{Key: "sqlite", Title: "SQLite", Icon: "database", Description: "SQLite database schema"}
	OriginSQLServer  = Origin{Key: "sqlserver", Title: "SQL Server", Icon: "database", Description: "SQL Server database schema"}
	OriginGraphQL    = Origin{Key: "graphql", Title: "GraphQL", Icon: "star", Description: "GraphQL schema and queries"}
	OriginProtobuf   = Origin{Key: "protobuf", Title: "Protobuf", Icon: "star", Description: "File describing proto3 definitions"}
	OriginJSONSchema = Origin{Key: "jsonschema", Title: "JSON Schema", Icon: "star", Description: "JSON Schema definition files"}
	OriginMock       = Origin{Key: "mock", Title: "Mock", Icon: "star", Description: "Simple type that returns mock data"}
	OriginUnknown    = Origin{Key: "unknown", Title: "Unknown", Icon: "star", Description: "Not quite sure what this is"}
)

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Description string   `json:"description,omitempty"`
	Comments    []string `json:"comments,omitempty"`
	Origin      *Origin  `json:"origin,omitempty"`
	Source      string   `json:"source,omitempty"`
	Line        int      `json:"line,omitempty"`
	Column      int      `json:"column,omitempty"`
}

type Origin

type Origin struct {
	Key         string `json:"key"`
	Title       string `json:"title,omitempty"`
	Icon        string `json:"icon,omitempty"`
	Description string `json:"description,omitempty"`
}

func OriginFromString

func OriginFromString(key string) Origin

func (*Origin) MarshalText added in v0.2.16

func (t *Origin) MarshalText() ([]byte, error)

func (*Origin) String

func (t *Origin) String() string

func (*Origin) UnmarshalText added in v0.2.16

func (t *Origin) UnmarshalText(data []byte) error

type Origins added in v0.4.4

type Origins []Origin

func (Origins) Get added in v0.4.4

func (o Origins) Get(key string) Origin

func (Origins) Keys added in v0.4.4

func (o Origins) Keys() []string

func (Origins) Titles added in v0.4.4

func (o Origins) Titles() []string

type Override

type Override struct {
	Type string   `json:"type,omitempty"`
	Path util.Pkg `json:"path,omitempty"`
	Prop string   `json:"prop,omitempty"`
	Val  any      `json:"val,omitempty"`
}

func NewOverride

func NewOverride(typ string, path util.Pkg, prop string, val any) *Override

func (*Override) ApplyTo

func (o *Override) ApplyTo(s *Schema) error

func (Override) String

func (o Override) String() string

type Overrides

type Overrides []*Override

func (Overrides) Purge

func (o Overrides) Purge(path util.Pkg) Overrides

func (Overrides) Sort

func (o Overrides) Sort()

type Scalar

type Scalar struct {
	Pkg         util.Pkg  `json:"pkg,omitempty"`
	Key         string    `json:"key"`
	Type        string    `json:"type"`
	Description string    `json:"description,omitempty"`
	Metadata    *Metadata `json:"metadata,omitempty"`
}

type Scalars

type Scalars []*Scalar

func (Scalars) Get

func (s Scalars) Get(pkg util.Pkg, key string) *Scalar

type Schema

type Schema struct {
	Paths    []string     `json:"paths,omitempty"`
	Scalars  Scalars      `json:"scalars,omitempty"`
	Models   model.Models `json:"models,omitempty"`
	Metadata *Metadata    `json:"metadata,omitempty"`
	// contains filtered or unexported fields
}

func (*Schema) AddModel

func (s *Schema) AddModel(m *model.Model) error

func (*Schema) AddPath

func (s *Schema) AddPath(path string) bool

func (*Schema) AddScalar

func (s *Schema) AddScalar(sc *Scalar) error

func (*Schema) CreateReferences

func (s *Schema) CreateReferences() error

func (*Schema) ModelsByPackage

func (s *Schema) ModelsByPackage() *model.Package

func (*Schema) Validate

func (s *Schema) Validate(n string) *ValidationResult

func (*Schema) ValidateModel

func (s *Schema) ValidateModel(sch string, m *model.Model) *ValidationResult

type Schemata

type Schemata map[string]*Schema

func (Schemata) Get

func (s Schemata) Get(key string) *Schema

func (Schemata) GetWithError

func (s Schemata) GetWithError(key string) (*Schema, error)

type ValidationMessage

type ValidationMessage struct {
	Category string `json:"category,omitempty"`
	ModelKey string `json:"modelKey,omitempty"`
	Message  string `json:"message,omitempty"`
	Level    int    `json:"level,omitempty"`
}

type ValidationResult

type ValidationResult struct {
	Schema   string              `json:"schema,omitempty"`
	Messages []ValidationMessage `json:"messages,omitempty"`
	Duration int64               `json:"duration,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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