enum_spec

package
v0.0.0-...-13bf8c3 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeInteger = "integer"
	TypeString  = "string"
)
View Source
const Version = "1.0.0"

Variables

This section is empty.

Functions

func ReadFromHTTP

func ReadFromHTTP(cl *http.Client, url string) ([]byte, error)

Types

type Contact

type Contact struct {
	Name  string `json:"name,omitempty" yaml:"name,omitempty"`
	Url   string `json:"url,omitempty" yaml:"url,omitempty"`
	Email string `json:"email,omitempty" yaml:"email,omitempty"`
}

type Enumerate

type Enumerate struct {
	Type        string            `json:"type"`        // 枚举数据类型, string, integer
	Format      string            `json:"format"`      // 枚举类型真实类型, string: 就是string, integer: 真实的整数类型,
	Description string            `json:"description"` // 枚举注释
	Explain     string            `json:"explain"`     // 枚举详细解释
	Oneof       []*EnumerateValue `json:"oneof"`       // 枚举项
}

type EnumerateValue

type EnumerateValue struct {
	GoName   string `json:"goName"` // 枚举项定义名称
	Name     string `json:"name"`   // 枚举项名称, 已去掉枚举项定义名称的前缀
	Const    string `json:"const"`  // 枚举项值, string: unquote string.
	Label    string `json:"label"`  // 枚举项的标签
	RawValue string `json:"value"`  // 枚举项的原始值, string: quote string.
}

type EnumerateValueSlices

type EnumerateValueSlices []*EnumerateValue

func (EnumerateValueSlices) Explain

func (vs EnumerateValueSlices) Explain() string

Explain convert to explain string format [0:aaa,1:bbb,3:ccc]

type Enums

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

func NewEnums

func NewEnums() *Enums

func (*Enums) All

func (e *Enums) All() iter.Seq2[string, *Enumerate]

func (*Enums) Keys

func (e *Enums) Keys() []string

func (*Enums) Len

func (e *Enums) Len() int

func (*Enums) Maps

func (e *Enums) Maps() map[string]*Enumerate

func (*Enums) MarshalJSON

func (e *Enums) MarshalJSON() ([]byte, error)

func (*Enums) Set

func (e *Enums) Set(key string, value *Enumerate) *Enums

func (*Enums) UnmarshalJSON

func (e *Enums) UnmarshalJSON(data []byte) error

func (*Enums) Value

func (e *Enums) Value(key string) *Enumerate

func (*Enums) Values

func (e *Enums) Values() iter.Seq[*Enumerate]

type Info

type Info struct {
	Version     string   `json:"version,omitempty" yaml:"version,omitempty"`
	Title       string   `json:"title,omitempty" yaml:"title,omitempty"`
	Summary     string   `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description string   `json:"description,omitempty" yaml:"description,omitempty"`
	Contact     *Contact `json:"contact,omitempty" yaml:"contact,omitempty"`
}

type Loader

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

func NewLoader

func NewLoader() *Loader

func (*Loader) LoadFromData

func (l *Loader) LoadFromData(data []byte) (*T, error)

func (*Loader) LoadFromFile

func (l *Loader) LoadFromFile(filename string) (*T, error)

func (*Loader) LoadFromReader

func (l *Loader) LoadFromReader(r io.Reader) (*T, error)

func (*Loader) LoadFromURL

func (l *Loader) LoadFromURL(url string) (*T, error)

func (*Loader) SetHTTPClient

func (l *Loader) SetHTTPClient(cl *http.Client) *Loader

type T

type T struct {
	Version string `json:"version,omitempty" yaml:"version,omitempty"` // Required
	Info    *Info  `json:"info,omitempty" yaml:"info,omitempty"`
	Enums   *Enums `json:"enums,omitempty" yaml:"enums,omitempty"`
}

Jump to

Keyboard shortcuts

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