gen

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConvertTmpl []byte
View Source
var ServiceTmpl []byte
View Source
var Templates = map[string][]byte{
	"Convert": ConvertTmpl,
	"Service": ServiceTmpl,
	"Types":   TypesTmpl,
}
View Source
var TypesTmpl []byte

Functions

func Generate

func Generate(file *protogen.File, protoPackagePath, connectPackagePath string, out io.Writer) error

Generate generates a go code to connect OpenAPI interface with connect service methods.

func GenerateOther

func GenerateOther(name, packageName string, out io.Writer) error

func GenerateWithData

func GenerateWithData(data *TemplateData, out io.Writer) error

Types

type TemplateData

type TemplateData struct {
	PackageName        string
	ProtoPackagePath   string
	ConnectPackagePath string
	Services           []TemplateServiceData
}

func (*TemplateData) FixOrders

func (d *TemplateData) FixOrders()

FixOrders fixes the order of Services by its Name

type TemplateFieldData

type TemplateFieldData struct {
	// Name is name used in proto file
	Name string

	// GoName is name used in Go code
	GoName string

	// GoType is type used in Go code
	GoType string

	// ParamType is where the field is located
	// "query", "path" or "body"
	ParamType string

	// Repeated is true if the field is allowed multiple values
	Repeated bool

	// Optional is true if the field is optional
	Optional bool
}

type TemplateMethodData

type TemplateMethodData struct {
	Name       string
	HTTPMethod string
	HTTPPath   string
	Request    TemplateRequestData
}

type TemplateRequestData

type TemplateRequestData struct {
	Name       string
	ExpectBody bool
	Fields     []TemplateFieldData
}

TempalteRequestData is a data for proto request message

func (*TemplateRequestData) FixOrders

func (d *TemplateRequestData) FixOrders()

FixOrders fixes the order of Fields by its Name

type TemplateServiceData

type TemplateServiceData struct {
	Name string
	// Endpoints []TemplateEndpointData
	Methods []TemplateMethodData
}

func (*TemplateServiceData) FixOrders

func (d *TemplateServiceData) FixOrders()

FixOrders fixes the order of Methods by its Name

Jump to

Keyboard shortcuts

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