templates

package
v0.0.0-...-8a85022 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AllOfTemplate = `
{{- define "allof" -}}
{{template "kind" .Reference }}
{{- end -}}`
View Source
const AnyOfTemplate = `
{{- define "anyof" -}}
{{template "kind" .Reference }}
{{- end -}}`
View Source
const ArrayTemplate = `` /* 131-byte string literal not displayed */
View Source
const BooleanTemplate = `` /* 139-byte string literal not displayed */
View Source
const ConstTemplate = `` /* 197-byte string literal not displayed */
View Source
const DocumentTemplate = `` /* 307-byte string literal not displayed */
View Source
const EnumTemplate = `` /* 225-byte string literal not displayed */
View Source
const IntegerTemplate = `` /* 140-byte string literal not displayed */
View Source
const InterfaceTemplate = `` /* 335-byte string literal not displayed */
View Source
const KindTemplate = `` /* 992-byte string literal not displayed */
View Source
const NumberTemplate = `` /* 141-byte string literal not displayed */
View Source
const OneOfTemplate = `
{{- define "oneof" -}}
{{template "kind" .Reference }}
{{- end -}}`
View Source
const ReferenceTemplate = `` /* 238-byte string literal not displayed */
View Source
const StringTemplate = `` /* 142-byte string literal not displayed */
View Source
const StructTemplate = `` /* 291-byte string literal not displayed */
View Source
const TypeTemplate = `` /* 303-byte string literal not displayed */
View Source
const UnmarshalJSONBodyTemplate = `` /* 933-byte string literal not displayed */

Variables

View Source
var SchemaFuncMap = template.FuncMap{
	"mixedCase":   MixedCase,
	"typename":    Typename,
	"clean":       Clean,
	"title":       strings.Title,
	"isStruct":    IsStruct,
	"isArray":     IsArray,
	"isString":    IsString,
	"isNumber":    IsNumber,
	"isInteger":   IsInteger,
	"isInterface": IsInterface,
	"isBoolean":   IsBoolean,
	"isReference": IsReference,
	"isEnum":      IsEnum,
	"isConst":     IsConst,
	"isMethod":    IsMethod,
	"isAllOf":     IsAllOf,
	"isAnyOf":     IsAnyOf,
	"isOneOf":     IsOneOf,
	"isType":      IsType,
}

Functions

func AddTemplates

func AddTemplates(tmpl *template.Template) (*template.Template, error)

func Clean

func Clean(raw string) string

func DefaultSchemaTemplate

func DefaultSchemaTemplate() (*template.Template, error)

func IsAllOf

func IsAllOf(obj interface{}) bool

func IsAnyOf

func IsAnyOf(obj interface{}) bool

func IsArray

func IsArray(obj interface{}) bool

func IsBoolean

func IsBoolean(obj interface{}) bool

func IsConst

func IsConst(obj interface{}) bool

func IsEnum

func IsEnum(obj interface{}) bool

func IsInteger

func IsInteger(obj interface{}) bool

func IsInterface

func IsInterface(obj interface{}) bool

func IsMethod

func IsMethod(obj interface{}) bool

func IsNumber

func IsNumber(obj interface{}) bool

func IsOneOf

func IsOneOf(obj interface{}) bool

func IsReference

func IsReference(obj interface{}) bool

func IsString

func IsString(obj interface{}) bool

func IsStruct

func IsStruct(obj interface{}) bool

func IsType

func IsType(obj interface{}) bool

func MethodUnmarshalJSON

func MethodUnmarshalJSON(receiver string, references []*Reference) (*parser.Method, error)

func MixedCase

func MixedCase(raw string) string

func Typename

func Typename(raw string) string

Types

type AllOf

type AllOf struct {
	*Reference
}

func (*AllOf) Name

func (s *AllOf) Name() string

type AnyOf

type AnyOf struct {
	*Reference
}

func (*AnyOf) Name

func (s *AnyOf) Name() string

type Array

type Array struct {
	Type string
	// contains filtered or unexported fields
}

func NewArray

func NewArray(name, comment, arrType string) *Array

func (*Array) Comment

func (s *Array) Comment() string

func (*Array) FieldTag

func (s *Array) FieldTag() string

func (*Array) Name

func (s *Array) Name() string

func (*Array) WithFieldTag

func (s *Array) WithFieldTag(tags string) parser.Field

func (*Array) WithReference

func (s *Array) WithReference(bool) parser.Field

type Boolean

type Boolean struct {
	Reference string
	// contains filtered or unexported fields
}

func NewBoolean

func NewBoolean(name, comment string) *Boolean

func (*Boolean) Comment

func (s *Boolean) Comment() string

func (*Boolean) FieldTag

func (s *Boolean) FieldTag() string

func (*Boolean) Name

func (s *Boolean) Name() string

func (*Boolean) WithFieldTag

func (s *Boolean) WithFieldTag(tags string) parser.Field

func (*Boolean) WithReference

func (s *Boolean) WithReference(ref bool) parser.Field

type Const

type Const struct {
	List []*ConstItem
}

func NewConst

func NewConst(list ...*ConstItem) *Const

func (*Const) Name

func (s *Const) Name() string

type ConstItem

type ConstItem struct {
	Name  string
	Type  string
	Value interface{}
}

type Document

type Document struct {
	ID      string
	Package string

	Imports []string
	// contains filtered or unexported fields
}

func NewDocument

func NewDocument(packagename string, schema *jsonschema.Schema) *Document

func (*Document) AddImport

func (s *Document) AddImport(value string)

func (*Document) Globals

func (s *Document) Globals() map[string]parser.Component

func (*Document) Name

func (s *Document) Name() string

func (*Document) WithPackageName

func (s *Document) WithPackageName(packagename string)

type Enum

type Enum struct {
	Type   string
	Values []string

	Reference string
	Items     []*ConstItem
	Methods   []*parser.Method
	// contains filtered or unexported fields
}

func NewEnum

func NewEnum(name, comment, typename string, values []string, items []*ConstItem) *Enum

func (*Enum) Comment

func (s *Enum) Comment() string

func (*Enum) FieldTag

func (s *Enum) FieldTag() string

func (*Enum) Name

func (s *Enum) Name() string

func (*Enum) WithFieldTag

func (s *Enum) WithFieldTag(tags string) parser.Field

func (*Enum) WithMethods

func (s *Enum) WithMethods(methods ...*parser.Method)

func (*Enum) WithReference

func (s *Enum) WithReference(ref bool) parser.Field

type Integer

type Integer struct {
	Reference string
	// contains filtered or unexported fields
}

func NewInteger

func NewInteger(name, comment string) *Integer

func (*Integer) Comment

func (s *Integer) Comment() string

func (*Integer) FieldTag

func (s *Integer) FieldTag() string

func (*Integer) Name

func (s *Integer) Name() string

func (*Integer) WithFieldTag

func (s *Integer) WithFieldTag(tags string) parser.Field

func (*Integer) WithReference

func (s *Integer) WithReference(ref bool) parser.Field

type Interface

type Interface struct {
	CommentImplementations string

	MethodSignatures []*parser.MethodSignature
	// contains filtered or unexported fields
}

func NewInterface

func NewInterface(typename string) *Interface

func (*Interface) Comment

func (s *Interface) Comment() string

func (*Interface) Name

func (s *Interface) Name() string

func (*Interface) WithMethodSignature

func (s *Interface) WithMethodSignature(methodSignature ...*parser.MethodSignature) *Interface

type List

type List struct {
	Items []parser.Component
}

func (*List) Name

func (s *List) Name() string

type Number

type Number struct {
	Reference string
	// contains filtered or unexported fields
}

func NewNumber

func NewNumber(name, comment string) *Number

func (*Number) Comment

func (s *Number) Comment() string

func (*Number) FieldTag

func (s *Number) FieldTag() string

func (*Number) Name

func (s *Number) Name() string

func (*Number) WithFieldTag

func (s *Number) WithFieldTag(tags string) parser.Field

func (*Number) WithReference

func (s *Number) WithReference(ref bool) parser.Field

type OneOf

type OneOf struct {
	*Reference
}

func (*OneOf) Name

func (s *OneOf) Name() string

type Reference

type Reference struct {
	Types []string
	Type  *parser.Type

	Reference string
	// contains filtered or unexported fields
}

func NewReference

func NewReference(name, comment string, t *parser.Type, typenames ...string) *Reference

func (*Reference) Comment

func (s *Reference) Comment() string

func (*Reference) FieldTag

func (s *Reference) FieldTag() string

func (*Reference) Name

func (s *Reference) Name() string

func (*Reference) WithFieldTag

func (s *Reference) WithFieldTag(tags string) parser.Field

func (*Reference) WithReference

func (s *Reference) WithReference(ref bool) parser.Field

type String

type String struct {
	Methods   []string
	Reference string
	// contains filtered or unexported fields
}

func NewString

func NewString(name, comment string) *String

func (*String) Comment

func (s *String) Comment() string

func (*String) FieldTag

func (s *String) FieldTag() string

func (*String) Name

func (s *String) Name() string

func (*String) WithFieldTag

func (s *String) WithFieldTag(tags string) parser.Field

func (*String) WithReference

func (s *String) WithReference(ref bool) parser.Field

type Struct

type Struct struct {
	Fields []parser.Component

	Reference string
	Methods   []*parser.Method
	// contains filtered or unexported fields
}

func NewStruct

func NewStruct(name, comment string, fields ...parser.Component) *Struct

func (*Struct) Comment

func (s *Struct) Comment() string

func (*Struct) FieldTag

func (s *Struct) FieldTag() string

func (*Struct) Name

func (s *Struct) Name() string

func (*Struct) UnmarshalStructJSON

func (s *Struct) UnmarshalStructJSON() *parser.Method

func (*Struct) WithFieldTag

func (s *Struct) WithFieldTag(tags string) parser.Field

func (*Struct) WithMethods

func (s *Struct) WithMethods(methods ...*parser.Method)

func (*Struct) WithReference

func (s *Struct) WithReference(ref bool) parser.Field

type Test

type Test struct{}

type Type

type Type struct {
	Type parser.Component

	Methods []*parser.Method
	// contains filtered or unexported fields
}

func NewType

func NewType(comment string, t parser.Component) *Type

func (*Type) Comment

func (s *Type) Comment() string

func (*Type) FieldTag

func (s *Type) FieldTag() string

func (*Type) Name

func (s *Type) Name() string

func (*Type) WithFieldTag

func (s *Type) WithFieldTag(fieldTag string) parser.Field

func (*Type) WithMethods

func (s *Type) WithMethods(methods ...*parser.Method)

func (*Type) WithReference

func (s *Type) WithReference(ref bool) parser.Field

Jump to

Keyboard shortcuts

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