templates

package
v0.0.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Args

func Args(vs ...any) []any

Args is a function used to pass arguments to templates.

func ChannelToMessageTypeName

func ChannelToMessageTypeName(ch asyncapi.Channel) string

ChannelToMessageTypeName will convert a channel to a message type name in the form of golang conventional type names.

func CustomTag added in v0.0.5

func CustomTag(customTag string, sentence string) string

func DescribeStruct

func DescribeStruct(st any) string

DescribeStruct will describe a struct in a human readable way using `%+v` format from the standard library.

func GenerateChannelPath

func GenerateChannelPath(ch asyncapi.Channel) string

GenerateChannelPath will generate a channel path with the given channel.

func HasField

func HasField(v any, name string) bool

HasField will check if a struct has a field with the given name.

func IsRequired

func IsRequired(schema asyncapi.Schema, field string) bool

IsRequired will check if a field is required in a asyncapi struct.

func MultiLineComment

func MultiLineComment(comment string) string

MultiLineComment will prefix each line of a comment with "// " in order to make it a valid multiline golang comment.

func Namify

func Namify(sentence string) string

Namify will convert a sentence to a golang conventional type name.

func NamifyWithoutParams

func NamifyWithoutParams(sentence string) string

NamifyWithoutParams will convert a sentence to a golang conventional type name. and will remove all parameters that can appear between '{' and '}'.

func OperationName

func OperationName(channel asyncapi.Channel) string

OperationName returns `operationId` value from Publish or Subscribe operation if any. If no `operationID` exists — return provided default value (`name`).

func ReferenceToStructAttributePath

func ReferenceToStructAttributePath(ref string) string

ReferenceToStructAttributePath will convert a reference to a struct attribute path in the form of "a.b.c" where a, b and c are struct attributes in the form of golang conventional type names.

func ReferenceToTypeName

func ReferenceToTypeName(ref string) string

ReferenceToTypeName will convert a reference to a type name in the form of golang conventional type names.

func SnakeCase

func SnakeCase(sentence string) string

SnakeCase will convert a sentence to snake case.

Types

This section is empty.

Jump to

Keyboard shortcuts

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