templates

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalFunctions = map[string]any{
	"refName":                RefName,
	"mustValidate":           MustValidate,
	"mustValidateRecurse":    MustValidateRecurse,
	"keysReflect":            KeysReflect,
	"httpStatus":             HTTPStatus,
	"newData":                NewData,
	"newDataRequired":        NewDataRequired,
	"recurseData":            RecurseData,
	"recurseDataSetRequired": RecurseDataSetRequired,
	"deref":                  Deref,
}

GlobalFunctions for templates

Functions

func Deref

func Deref(ptr any) any

func HTTPStatus

func HTTPStatus(code int) string

func KeysReflect

func KeysReflect(mp any) ([]string, error)

func Load

func Load(generatorFuncs map[string]any, dir fs.FS, files ...string) (*template.Template, error)

Load takes in funcs to apply to each template, a directory that contains the files, and the file paths relative that directory

func MustValidate

func MustValidate(s *openapi3spec.Schema) bool

MustValidate checks to see if the schema requires any kind of validation

func MustValidateRecurse

func MustValidateRecurse(s *openapi3spec.Schema) bool

MustValidateRecurse checks to see if the current schema, or any sub-schema requires validation

func RefName

func RefName(ref string) string

Types

type TemplateData

type TemplateData struct {
	Spec   *openapi3spec.OpenAPI3
	Params map[string]string

	Imports map[string]struct{}

	Name     string
	Object   any
	Required bool
}

TemplateData for all generators

func NewData

func NewData(old TemplateData, name string, obj any) TemplateData

func NewDataRequired

func NewDataRequired(old TemplateData, name string, obj any, required bool) TemplateData

func NewTemplateData

func NewTemplateData(spec *openapi3spec.OpenAPI3, params map[string]string) *TemplateData

NewTemplateData constructor

func NewTemplateDataWithObject

func NewTemplateDataWithObject(spec *openapi3spec.OpenAPI3, params map[string]string, name string, object any, required bool) *TemplateData

NewTemplateDataWithObject constructor

func RecurseData

func RecurseData(old TemplateData, nextName string, nextObj any) TemplateData

func RecurseDataSetRequired

func RecurseDataSetRequired(old TemplateData, nextName string, nextObj any, required bool) TemplateData

func (TemplateData) Import

func (t TemplateData) Import(importName string) string

Import records the importing of a library

func (TemplateData) TemplateParamEquals

func (t TemplateData) TemplateParamEquals(param, want string) bool

TemplateParamEquals checks for equality of a parameter

func (TemplateData) TemplateParamExists

func (t TemplateData) TemplateParamExists(param string) bool

TemplateParamExists checks for existence of a parameter

Jump to

Keyboard shortcuts

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