schema

package
v1.9.10 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultUIType

func GetDefaultUIType(apiType string, haveOptions bool, subType string, haveSub bool) string

GetDefaultUIType Set the default mapping for API Schema Type

Types

type Condition

type Condition struct {
	// JSONKey specifies the path of the field, support the peer and subordinate fields.
	JSONKey string `json:"jsonKey"`
	// Op options includes `==` 、`!=` and `in`, default is `==`
	// +optional
	Op string `json:"op,omitempty"`
	// Value specifies the prospective value.
	Value interface{} `json:"value"`
	// Action options includes `enable` or `disable`, default is `enable`
	// +optional
	Action string `json:"action,omitempty"`
}

Condition control whether fields are enabled or disabled by certain conditions.

func (Condition) Validate

func (c Condition) Validate() error

Validate check the validity of condition

type GroupOption

type GroupOption struct {
	Label string   `json:"label"`
	Keys  []string `json:"keys"`
}

GroupOption define multiple data structure composition options.

type Option

type Option struct {
	Label string      `json:"label"`
	Value interface{} `json:"value"`
}

Option select option

type Style

type Style struct {
	// ColSpan the width of a responsive layout
	ColSpan int `json:"colSpan"`
}

Style ui style

type UIParameter

type UIParameter struct {
	Sort        uint      `json:"sort"`
	Label       string    `json:"label"`
	Description string    `json:"description"`
	Validate    *Validate `json:"validate,omitempty"`
	JSONKey     string    `json:"jsonKey"`
	UIType      string    `json:"uiType"`
	Style       *Style    `json:"style,omitempty"`
	// means disable parameter in ui
	Disable *bool `json:"disable,omitempty"`
	// Conditions: control whether fields are enabled or disabled by certain conditions.
	// Rules:
	// if all conditions are not matching, the parameter will be disabled
	// if there are no conditions, and disable==false the parameter will be enabled.
	// if one disable action condition is matched, the parameter will be disabled.
	// if all enable actions conditions are matched, the parameter will be enabled.
	// +optional
	Conditions              []Condition    `json:"conditions,omitempty"`
	SubParameterGroupOption []GroupOption  `json:"subParameterGroupOption,omitempty"`
	SubParameters           []*UIParameter `json:"subParameters,omitempty"`
	AdditionalParameter     *UIParameter   `json:"additionalParameter,omitempty"`
	Additional              *bool          `json:"additional,omitempty"`
}

UIParameter Structured import table simple UI model

type UISchema

type UISchema []*UIParameter

UISchema ui schema

func (UISchema) Validate

func (u UISchema) Validate() error

Validate check the ui schema

type Validate

type Validate struct {
	Required     bool        `json:"required,omitempty"`
	Max          *float64    `json:"max,omitempty"`
	MaxLength    *uint64     `json:"maxLength,omitempty"`
	Min          *float64    `json:"min,omitempty"`
	MinLength    uint64      `json:"minLength,omitempty"`
	Pattern      string      `json:"pattern,omitempty"`
	Options      []Option    `json:"options,omitempty"`
	DefaultValue interface{} `json:"defaultValue,omitempty"`
	// the parameter cannot be changed twice.
	Immutable bool `json:"immutable"`
}

Validate parameter validate rule

Jump to

Keyboard shortcuts

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