templates

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package templates export a TemplateContext structure which is the object that every template receives as context when executed.

This file also gathers all context API related to this object.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(options *Options) (*template.Templates, error)

Types

type Import

type Import struct {
	InternalName string
	Name         string

	// Templates holds the names of all template files that must import this
	// package.
	Templates []string
}

func (Import) IsRequiredFor

func (i Import) IsRequiredFor(templateName string) bool

IsRequiredFor checks if the object is required for a specific template.

type Options

type Options struct {
	Path        string
	ServiceName string
	PackageName string
	Plugin      *protogen.Plugin
	Entity      *protogen.File
	Settings    *protogen.File
	Api         *protogen.File
}

type TemplateContext

type TemplateContext struct {
	PackageName string
	ServiceName string
	Imports     map[string][]Import
	Entities    []*parser.Message
	Messages    []*parser.Message
	Enums       []parser.Enum
	Methods     []*parser.Method
	Settings    []*parser.Message
}

func NewTemplateContext

func NewTemplateContext(options *Options) (*TemplateContext, error)

func (*TemplateContext) AllMessages

func (t *TemplateContext) AllMessages() []*parser.Message

func (*TemplateContext) Extension

func (t *TemplateContext) Extension() string

func (*TemplateContext) GetTemplateImports

func (t *TemplateContext) GetTemplateImports(tplName string) []Import

func (*TemplateContext) HasBodyToDecode

func (t *TemplateContext) HasBodyToDecode() bool

func (*TemplateContext) HasEnumField

func (t *TemplateContext) HasEnumField() bool

func (*TemplateContext) HasEnumPathField

func (t *TemplateContext) HasEnumPathField() bool

func (*TemplateContext) HasImportFor

func (t *TemplateContext) HasImportFor(tplName string) bool

func (*TemplateContext) HasMultipartFormDataMethod

func (t *TemplateContext) HasMultipartFormDataMethod() bool

func (*TemplateContext) HasParametersToDecode

func (t *TemplateContext) HasParametersToDecode() bool

func (*TemplateContext) HasRequiredBody

func (t *TemplateContext) HasRequiredBody() bool

func (*TemplateContext) IsHTTPService

func (t *TemplateContext) IsHTTPService() bool

IsHTTPService checks if the service is using HTTP endpoint in its methods.

func (*TemplateContext) MessagesToValidate

func (t *TemplateContext) MessagesToValidate() []*parser.Message

MessagesToValidate gives back only the messages that should have the Validator interface implemented.

func (*TemplateContext) ModelEntities

func (t *TemplateContext) ModelEntities() []*parser.Message

func (*TemplateContext) ResponseMessages

func (t *TemplateContext) ResponseMessages() []*parser.Message

ResponseMessages returns all messages that are response types without repeating.

func (*TemplateContext) Validate

func (t *TemplateContext) Validate() error

func (*TemplateContext) ValidateForExecute

func (t *TemplateContext) ValidateForExecute() map[string]template.TemplateValidator

Jump to

Keyboard shortcuts

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