spec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package spec parses and validates go-backend-kit resource specifications.

Index

Constants

View Source
const SchemaVersion = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name       string    `json:"name"`
	GoName     string    `json:"go_name"`
	Column     string    `json:"column"`
	Type       FieldType `json:"type"`
	Required   bool      `json:"required"`
	Nullable   bool      `json:"nullable"`
	HasDefault bool      `json:"has_default"`
	Default    any       `json:"default,omitempty"`
	Unique     bool      `json:"unique"`
	Index      bool      `json:"index"`
	Enum       []string  `json:"enum,omitempty"`
	Min        *float64  `json:"min,omitempty"`
	Max        *float64  `json:"max,omitempty"`
	MaxLength  *int      `json:"max_length,omitempty"`
	Searchable bool      `json:"searchable"`
	Filterable bool      `json:"filterable"`
	Sortable   bool      `json:"sortable"`
}

type FieldType

type FieldType string
const (
	TypeString  FieldType = "string"
	TypeText    FieldType = "text"
	TypeBool    FieldType = "bool"
	TypeInt32   FieldType = "int32"
	TypeInt64   FieldType = "int64"
	TypeFloat64 FieldType = "float64"
	TypeDecimal FieldType = "decimal"
	TypeTime    FieldType = "time"
	TypeUUID    FieldType = "uuid"
	TypeJSON    FieldType = "json"
)

type Resource

type Resource struct {
	SchemaVersion int     `json:"schema_version"`
	Name          string  `json:"name"`
	Package       string  `json:"package"`
	Table         string  `json:"table"`
	Route         string  `json:"route"`
	Fields        []Field `json:"fields"`
}

Resource is the normalized representation used by every generator.

func Parse

func Parse(data []byte) (Resource, error)

Parse decodes one strict Schema v1 YAML document and returns its normalized form.

func (Resource) Fingerprint

func (r Resource) Fingerprint() string

Fingerprint is a stable digest of the normalized specification.

Jump to

Keyboard shortcuts

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