Skip to content

Struct Tags Complete Reference

Complete reference for struct tags used in TinySystems component schemas.

Overview

Struct tags control how Go structs are converted to JSON Schema and rendered in the UI.

go
type Example struct {
    Field string `json:"field" required:"true" title:"Field Name" description:"Help text"`
}

JSON Tags

json

Maps Go field to JSON property name.

Syntax: json:"name" or json:"name,omitempty"

Examples:

go
UserName string `json:"userName"`       // camelCase
user_id  string `json:"user_id"`        // snake_case
Data     string `json:"data,omitempty"` // omit if empty

Notes:

  • Required for all exported fields
  • Use json:"-" to exclude from schema

Validation Tags

required

Marks field as required.

Syntax: required:"true"

Example:

go
Email string `json:"email" required:"true"`

Effect: Field must be provided; UI shows required indicator.


minimum / maximum

Sets numeric range constraints.

Syntax: minimum:"value" maximum:"value"

Examples:

go
Age       int     `json:"age" minimum:"0" maximum:"150"`
Percentage float64 `json:"percentage" minimum:"0" maximum:"100"`
Port      int     `json:"port" minimum:"1" maximum:"65535"`

minLength / maxLength

Sets string length constraints.

Syntax: minLength:"value" maxLength:"value"

Examples:

go
Username string `json:"username" minLength:"3" maxLength:"50"`
Code     string `json:"code" minLength:"6" maxLength:"6"`

minItems / maxItems

Sets array size constraints.

Syntax: minItems:"value" maxItems:"value"

Examples:

go
Tags    []string `json:"tags" minItems:"1" maxItems:"10"`
Choices []string `json:"choices" minItems:"2"`

pattern

Sets regex pattern constraint.

Syntax: pattern:"regex"

Examples:

go
Email  string `json:"email" pattern:"^[^@]+@[^@]+\\.[^@]+$"`
Phone  string `json:"phone" pattern:"^\\+?[0-9]{10,14}$"`
Slug   string `json:"slug" pattern:"^[a-z0-9-]+$"`

enum

Restricts to specific values.

Syntax: enum:"value1,value2,value3"

Examples:

go
Status   string `json:"status" enum:"pending,active,completed"`
Priority string `json:"priority" enum:"low,medium,high"`

Display Tags

title

Sets display label.

Syntax: title:"Label"

Examples:

go
UserID    string `json:"userId" title:"User ID"`
MaxRetries int   `json:"maxRetries" title:"Maximum Retries"`

description

Sets help text / tooltip.

Syntax: description:"Help text"

Examples:

go
Timeout string `json:"timeout" description:"Duration to wait before timing out (e.g., 30s, 1m)"`
APIKey  string `json:"apiKey" description:"Your API key from the dashboard"`

default

Sets default value.

Syntax: default:"value"

Examples:

go
Timeout    string `json:"timeout" default:"30s"`
MaxRetries int    `json:"maxRetries" default:"3"`
Enabled    bool   `json:"enabled" default:"true"`

Notes:

  • Value is string; converted to appropriate type
  • Used as initial value in UI

readonly

Makes field read-only in UI.

Syntax: readonly:"true"

Examples:

go
ID        string `json:"id" readonly:"true"`
CreatedAt string `json:"createdAt" readonly:"true"`

UI Layout Tags

format

Specifies special rendering format.

Syntax: format:"formatName"

Formats:

FormatDescription
textareaMulti-line text input
passwordMasked input
emailEmail input with validation
uriURL input
dateDate picker
timeTime picker
date-timeDate and time picker
buttonRender as clickable button
codeCode editor

Examples:

go
Bio       string `json:"bio" format:"textarea"`
Password  string `json:"password" format:"password"`
Email     string `json:"email" format:"email"`
Endpoint  string `json:"endpoint" format:"uri"`
BirthDate string `json:"birthDate" format:"date"`
Start     bool   `json:"start" format:"button" title:"Start"`
Config    string `json:"config" format:"code"`

tab

Groups fields into tabs.

Syntax: tab:"Tab Name"

Examples:

go
type Settings struct {
    // Basic tab
    Name    string `json:"name" tab:"Basic" title:"Name"`
    Email   string `json:"email" tab:"Basic" title:"Email"`

    // Advanced tab
    Timeout string `json:"timeout" tab:"Advanced" title:"Timeout"`
    Debug   bool   `json:"debug" tab:"Advanced" title:"Debug Mode"`
}

colSpan

Controls column width in grid layout.

Syntax: colSpan:"col-span-N" where N is 1-12

Examples:

go
Title       string `json:"title" colSpan:"col-span-12"`     // Full width
FirstName   string `json:"firstName" colSpan:"col-span-6"`  // Half width
LastName    string `json:"lastName" colSpan:"col-span-6"`   // Half width
Description string `json:"description" colSpan:"col-span-8"` // Two-thirds

propertyOrder

Controls field display order.

Syntax: propertyOrder:"N"

Examples:

go
type Form struct {
    Email    string `json:"email" propertyOrder:"2"`
    Name     string `json:"name" propertyOrder:"1"`
    Comments string `json:"comments" propertyOrder:"3"`
}
// Displayed: Name, Email, Comments

Special Tags

configurable

Marks field as user-configurable.

Syntax: configurable:"true"

Example:

go
type Input struct {
    Data   string `json:"data" configurable:"true"`    // User can set
    Source string `json:"source" configurable:"false"` // Set by system
}

shared

Makes field available for referencing by other components.

Syntax: shared:"true"

Example:

go
type Output struct {
    Result string `json:"result" shared:"true"` // Can be referenced
}

configRef

Enables secret/configmap reference.

Syntax: Use the ConfigRef type

Example:

go
type Settings struct {
    APIKey ConfigRef `json:"apiKey" title:"API Key"`
}

type ConfigRef struct {
    Value     string `json:"value,omitempty"`
    ConfigRef *struct {
        Name string `json:"name"`
        Key  string `json:"key"`
    } `json:"configRef,omitempty"`
}

Type-Specific Tags

For Strings

TagPurposeExample
minLengthMin charactersminLength:"1"
maxLengthMax charactersmaxLength:"255"
patternRegex validationpattern:"^[a-z]+$"
formatInput typeformat:"email"
enumAllowed valuesenum:"a,b,c"

For Numbers

TagPurposeExample
minimumMin valueminimum:"0"
maximumMax valuemaximum:"100"
defaultDefault valuedefault:"10"

For Arrays

TagPurposeExample
minItemsMin elementsminItems:"1"
maxItemsMax elementsmaxItems:"10"

For Booleans

TagPurposeExample
defaultDefault valuedefault:"true"
formatRender as buttonformat:"button"

Complete Example

go
type ServerSettings struct {
    // Basic Settings Tab
    Name string `json:"name" required:"true" title:"Server Name"
        description:"Unique identifier for this server"
        minLength:"1" maxLength:"64"
        tab:"Basic" propertyOrder:"1"`

    Host string `json:"host" required:"true" title:"Host"
        description:"Hostname or IP address"
        default:"0.0.0.0"
        tab:"Basic" propertyOrder:"2"
        colSpan:"col-span-8"`

    Port int `json:"port" required:"true" title:"Port"
        description:"Port number (1-65535)"
        minimum:"1" maximum:"65535" default:"8080"
        tab:"Basic" propertyOrder:"3"
        colSpan:"col-span-4"`

    // Security Tab
    TLSEnabled bool `json:"tlsEnabled" title:"Enable TLS"
        description:"Use HTTPS instead of HTTP"
        default:"false"
        tab:"Security"`

    APIKey ConfigRef `json:"apiKey" title:"API Key"
        description:"Secret API key for authentication"
        tab:"Security"`

    // Advanced Tab
    Timeout string `json:"timeout" title:"Request Timeout"
        description:"Maximum time to wait for requests"
        default:"30s"
        tab:"Advanced"`

    MaxConnections int `json:"maxConnections" title:"Max Connections"
        description:"Maximum concurrent connections"
        minimum:"1" maximum:"10000" default:"100"
        tab:"Advanced"`

    Debug bool `json:"debug" title:"Debug Mode"
        description:"Enable verbose logging"
        default:"false"
        tab:"Advanced"`

    // Control (Button)
    Start bool `json:"start" format:"button" title:"Start Server"
        description:"Click to start the server"`
}

Quick Reference Table

TagPurposeExample
jsonJSON field namejson:"fieldName"
requiredMark requiredrequired:"true"
titleDisplay labeltitle:"Field Label"
descriptionHelp textdescription:"Help"
defaultDefault valuedefault:"value"
readonlyRead-onlyreadonly:"true"
minimumMin numberminimum:"0"
maximumMax numbermaximum:"100"
minLengthMin string lengthminLength:"1"
maxLengthMax string lengthmaxLength:"255"
minItemsMin array itemsminItems:"1"
maxItemsMax array itemsmaxItems:"10"
patternRegex patternpattern:"^[a-z]+$"
enumAllowed valuesenum:"a,b,c"
formatSpecial formatformat:"textarea"
tabGroup in tabtab:"Advanced"
colSpanColumn widthcolSpan:"col-span-6"
propertyOrderDisplay orderpropertyOrder:"1"
configurableUser editableconfigurable:"true"
sharedShare for referenceshared:"true"

Build flow-based applications on Kubernetes