openapi

package
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Extension for walrus.
	ExtWalrusKey = "x-walrus"
	// ExtWalrusVersionKey is a string, for walrus version constraint.
	ExtWalrusVersionKey = "version"
)
View Source
const (
	// ExtOriginalKey for original value.
	ExtOriginalKey = "x-walrus-original"
)
View Source
const (
	// Extension for UI.
	ExtUIKey = "x-walrus-ui"
)
View Source
const OpenAPIVersion = "3.0.3"
View Source
const (
	UIWidgetYamlEditor = "YamlEditor"
)
View Source
const WalrusContextVariableName = "context"

Variables

This section is empty.

Functions

func GenSchemaDefaultPatch added in v0.5.0

func GenSchemaDefaultPatch(ctx context.Context, schema *openapi3.Schema) ([]byte, error)

GenSchemaDefaultPatch generates the default patch for the variable schema. The input root schema type should be object.

func GetExtWalrusVersion

func GetExtWalrusVersion(e map[string]any) string

func IntersectSchema

func IntersectSchema(s1, s2 *openapi3.Schema) *openapi3.Schema

IntersectSchema generates a openapi3.Schema with properties intersection of s1 and s2.

func IsSchemaRefEmpty

func IsSchemaRefEmpty(s *openapi3.SchemaRef) bool

func MustSchemaEqual

func MustSchemaEqual(s1, s2 *openapi3.Schema) bool

MustSchemaEqual checks if s1 and s2 are equal, just log the error.

func RemoveExt

func RemoveExt(key string, s *openapi3.Schema) *openapi3.Schema

func RemoveExtOriginal

func RemoveExtOriginal(s *openapi3.Schema) *openapi3.Schema

func RemoveExtUI

func RemoveExtUI(s *openapi3.Schema) *openapi3.Schema

func RemoveVariableContext added in v0.5.0

func RemoveVariableContext(s *openapi3.Schema) *openapi3.Schema

func SchemaEqual

func SchemaEqual(s1, s2 *openapi3.Schema) (bool, error)

SchemaEqual checks if s1 and s2 are equal.

func UnionSchema

func UnionSchema(s1, s2 *openapi3.Schema) (*openapi3.Schema, error)

UnionSchema generates a openapi3.Schema union of s1 and s2, for the same key s2 will overwrite s1's.

Types

type DefaultPatchNode added in v0.5.0

type DefaultPatchNode struct {
	*openapi3.Schema
	// contains filtered or unexported fields
}

DefaultPatchNode is a implement of Node to generate default value tree.

func (*DefaultPatchNode) Children added in v0.5.0

func (n *DefaultPatchNode) Children() []Node

Children returns the children of the node.

func (*DefaultPatchNode) GetDefault added in v0.5.0

func (n *DefaultPatchNode) GetDefault() any

GetDefault returns the default value of the node.

func (*DefaultPatchNode) GetID added in v0.5.0

func (n *DefaultPatchNode) GetID() string

GetID returns the id of the node.

func (*DefaultPatchNode) GetParentID added in v0.5.0

func (n *DefaultPatchNode) GetParentID() string

GetParentID returns the id of the ancestor nodes.

type Ext

type Ext struct {
	ExtUI
	ExtOriginal
}

Ext is a struct wrap the extension.

func NewExt

func NewExt() *Ext

NewExt creates a new Ext.

func NewExtFromMap

func NewExtFromMap(m map[string]any) *Ext

NewExtFromMap creates a new Ext from extension map.

func (*Ext) Export

func (e *Ext) Export() map[string]any

func (*Ext) WithOriginal

func (e *Ext) WithOriginal(origin any) *Ext

func (*Ext) WithOriginalType

func (e *Ext) WithOriginalType(ty any) *Ext

func (*Ext) WithOriginalValueExpression

func (e *Ext) WithOriginalValueExpression(ve []byte) *Ext

func (*Ext) WithOriginalVariablesSequence

func (e *Ext) WithOriginalVariablesSequence(vq []string) *Ext

func (*Ext) WithUIColSpan

func (e *Ext) WithUIColSpan(cs int) *Ext

func (*Ext) WithUIGroup

func (e *Ext) WithUIGroup(gp string) *Ext

func (*Ext) WithUIGroupOrder

func (e *Ext) WithUIGroupOrder(grd ...string) *Ext

func (*Ext) WithUIHidden

func (e *Ext) WithUIHidden() *Ext

func (*Ext) WithUIImmutable

func (e *Ext) WithUIImmutable() *Ext

func (*Ext) WithUIOrder

func (e *Ext) WithUIOrder(order int) *Ext

func (*Ext) WithUIShowIf

func (e *Ext) WithUIShowIf(showIf string) *Ext

func (*Ext) WithUIWidget

func (e *Ext) WithUIWidget(widget string) *Ext

type ExtOriginal

type ExtOriginal struct {
	// Type is a string, for original type.
	Type any `json:"type,omitempty" yaml:"type,omitempty"`
	// ValueExpression is a string, for original value expression.
	ValueExpression []byte `json:"value-expression,omitempty" yaml:"value-expression,omitempty"`
	// VariablesSequence is a list, for original variables sequence.
	VariablesSequence []string `json:"sequence,omitempty" yaml:"sequence,omitempty"`
}

ExtOriginal is a struct wrap the original extension.

func GetExtOriginal

func GetExtOriginal(e map[string]any) ExtOriginal

func (ExtOriginal) IsEmpty

func (e ExtOriginal) IsEmpty() bool

IsEmpty reports if the extension is empty.

type ExtUI

type ExtUI struct {
	// Group is a string, for grouping the properties.
	Group string `json:"group,omitempty" yaml:"group,omitempty"`
	// GroupOrder is a list, for ordering the group in the UI.
	GroupOrder []string `json:"groupOrder,omitempty" yaml:"groupOrder,omitempty"`
	// ShowIf is a string, for showing the property.
	ShowIf string `json:"showIf,omitempty" yaml:"showIf,omitempty"`
	// Hidden is a boolean, for hiding the property.
	Hidden bool `json:"hidden,omitempty" yaml:"hidden,omitempty"`
	// Immutable is a boolean, for making the property immutable.
	Immutable bool `json:"immutable,omitempty" yaml:"immutable,omitempty"`
	// Widget is a string, for customizing the UI widget.
	Widget string `json:"widget,omitempty" yaml:"widget,omitempty"`
	// Order is a number, for ordering the properties in the UI.
	Order int `json:"order,omitempty" yaml:"order,omitempty"`
	// ColSpan is a number between 1 and 12, for typical 12-column grid systems.
	ColSpan int `json:"colSpan,omitempty" yaml:"colSpan,omitempty"`
}

ExtUI is a struct wrap the UI extension.

func GetExtUI

func GetExtUI(e map[string]any) ExtUI

func (ExtUI) IsEmpty

func (e ExtUI) IsEmpty() bool

IsEmpty reports if the extension is empty.

type Node added in v0.5.0

type Node interface {
	GetID() string
	GetParentID() string
	Children() []Node
	GetDefault() any
}

Node is a node in the tree.

func PreorderTraversal added in v0.5.0

func PreorderTraversal(root Node) []Node

PreorderTraversal traverses the tree in preorder.

type Stack added in v0.5.0

type Stack struct {
	// contains filtered or unexported fields
}

Stack is a stack of nodes.

func (*Stack) Len added in v0.5.0

func (s *Stack) Len() int

Len return the current item length in stack.

func (*Stack) Pop added in v0.5.0

func (s *Stack) Pop() Node

Pop pops a node from the stack.

func (*Stack) Push added in v0.5.0

func (s *Stack) Push(node Node)

Push pushes a node to the stack.

Jump to

Keyboard shortcuts

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