templates

package
v0.0.0-...-da2a1ef Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChiReceiverTemplates = map[string]ReceiverTemplate{
	"receiver": {
		Name: "receiver",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
		},
		Template: "server/chi/receiver.go.tmpl",
	},
}

ChiReceiverTemplates contains receiver templates for Chi servers.

View Source
var ChiServerTemplates = map[string]ServerTemplate{
	"interface": {
		Name: "interface",
		Imports: []Import{
			{Path: "net/http"},
		},
		Template: "server/chi/interface.go.tmpl",
	},
	"handler": {
		Name: "handler",
		Imports: []Import{
			{Path: "net/http"},
			{Path: "github.com/go-chi/chi/v5"},
		},
		Template: "server/chi/handler.go.tmpl",
	},
	"wrapper": {
		Name: "wrapper",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/go-chi/chi/v5"},
		},
		Template: "server/chi/wrapper.go.tmpl",
	},
}

ChiServerTemplates contains templates for Chi server generation.

View Source
var ClientTemplates = map[string]ClientTemplate{
	"base": {
		Name: "base",
		Imports: []Import{
			{Path: "context"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "strings"},
		},
		Template: "client/base.go.tmpl",
	},
}

ClientTemplates contains the base template for client generation. The shared sender templates (interface, methods, request_builders, simple) are in SenderTemplates and used by both client and initiator generators.

View Source
var EchoReceiverTemplates = map[string]ReceiverTemplate{
	"receiver": {
		Name: "receiver",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/labstack/echo/v5"},
		},
		Template: "server/echo/receiver.go.tmpl",
	},
}

EchoReceiverTemplates contains receiver templates for Echo v5 servers.

View Source
var EchoServerTemplates = map[string]ServerTemplate{
	"interface": {
		Name: "interface",
		Imports: []Import{
			{Path: "net/http"},
			{Path: "github.com/labstack/echo/v5"},
		},
		Template: "server/echo/interface.go.tmpl",
	},
	"handler": {
		Name: "handler",
		Imports: []Import{
			{Path: "github.com/labstack/echo/v5"},
		},
		Template: "server/echo/handler.go.tmpl",
	},
	"wrapper": {
		Name: "wrapper",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/labstack/echo/v5"},
		},
		Template: "server/echo/wrapper.go.tmpl",
	},
}

EchoServerTemplates contains templates for Echo v5 server generation.

View Source
var EchoV4ReceiverTemplates = map[string]ReceiverTemplate{
	"receiver": {
		Name: "receiver",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/labstack/echo/v4"},
		},
		Template: "server/echo-v4/receiver.go.tmpl",
	},
}

EchoV4ReceiverTemplates contains receiver templates for Echo v4 servers.

View Source
var EchoV4ServerTemplates = map[string]ServerTemplate{
	"interface": {
		Name: "interface",
		Imports: []Import{
			{Path: "net/http"},
			{Path: "github.com/labstack/echo/v4"},
		},
		Template: "server/echo-v4/interface.go.tmpl",
	},
	"handler": {
		Name: "handler",
		Imports: []Import{
			{Path: "github.com/labstack/echo/v4"},
		},
		Template: "server/echo-v4/handler.go.tmpl",
	},
	"wrapper": {
		Name: "wrapper",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/labstack/echo/v4"},
		},
		Template: "server/echo-v4/wrapper.go.tmpl",
	},
}

EchoV4ServerTemplates contains templates for Echo v4 server generation.

View Source
var FiberReceiverTemplates = map[string]ReceiverTemplate{
	"receiver": {
		Name: "receiver",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/gofiber/fiber/v3"},
		},
		Template: "server/fiber/receiver.go.tmpl",
	},
}

FiberReceiverTemplates contains receiver templates for Fiber servers.

View Source
var FiberServerTemplates = map[string]ServerTemplate{
	"interface": {
		Name: "interface",
		Imports: []Import{
			{Path: "github.com/gofiber/fiber/v3"},
		},
		Template: "server/fiber/interface.go.tmpl",
	},
	"handler": {
		Name: "handler",
		Imports: []Import{
			{Path: "github.com/gofiber/fiber/v3"},
		},
		Template: "server/fiber/handler.go.tmpl",
	},
	"wrapper": {
		Name: "wrapper",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/gofiber/fiber/v3"},
		},
		Template: "server/fiber/wrapper.go.tmpl",
	},
}

FiberServerTemplates contains templates for Fiber server generation.

View Source
var GinReceiverTemplates = map[string]ReceiverTemplate{
	"receiver": {
		Name: "receiver",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/gin-gonic/gin"},
		},
		Template: "server/gin/receiver.go.tmpl",
	},
}

GinReceiverTemplates contains receiver templates for Gin servers.

View Source
var GinServerTemplates = map[string]ServerTemplate{
	"interface": {
		Name: "interface",
		Imports: []Import{
			{Path: "net/http"},
			{Path: "github.com/gin-gonic/gin"},
		},
		Template: "server/gin/interface.go.tmpl",
	},
	"handler": {
		Name: "handler",
		Imports: []Import{
			{Path: "github.com/gin-gonic/gin"},
		},
		Template: "server/gin/handler.go.tmpl",
	},
	"wrapper": {
		Name: "wrapper",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/gin-gonic/gin"},
		},
		Template: "server/gin/wrapper.go.tmpl",
	},
}

GinServerTemplates contains templates for Gin server generation.

View Source
var GorillaReceiverTemplates = map[string]ReceiverTemplate{
	"receiver": {
		Name: "receiver",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
		},
		Template: "server/gorilla/receiver.go.tmpl",
	},
}

GorillaReceiverTemplates contains receiver templates for Gorilla servers.

View Source
var GorillaServerTemplates = map[string]ServerTemplate{
	"interface": {
		Name: "interface",
		Imports: []Import{
			{Path: "net/http"},
		},
		Template: "server/gorilla/interface.go.tmpl",
	},
	"handler": {
		Name: "handler",
		Imports: []Import{
			{Path: "net/http"},
			{Path: "github.com/gorilla/mux"},
		},
		Template: "server/gorilla/handler.go.tmpl",
	},
	"wrapper": {
		Name: "wrapper",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/gorilla/mux"},
		},
		Template: "server/gorilla/wrapper.go.tmpl",
	},
}

GorillaServerTemplates contains templates for Gorilla server generation.

View Source
var InitiatorTemplates = map[string]InitiatorTemplate{
	"initiator_base": {
		Name: "initiator_base",
		Imports: []Import{
			{Path: "context"},
			{Path: "net/http"},
		},
		Template: "initiator/base.go.tmpl",
	},
}

InitiatorTemplates contains the base template for initiator generation. The shared sender templates (interface, methods, request_builders, simple) are in SenderTemplates and used by both client and initiator generators.

View Source
var IrisReceiverTemplates = map[string]ReceiverTemplate{
	"receiver": {
		Name: "receiver",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/kataras/iris/v12"},
		},
		Template: "server/iris/receiver.go.tmpl",
	},
}

IrisReceiverTemplates contains receiver templates for Iris servers.

View Source
var IrisServerTemplates = map[string]ServerTemplate{
	"interface": {
		Name: "interface",
		Imports: []Import{
			{Path: "net/http"},
			{Path: "github.com/kataras/iris/v12"},
		},
		Template: "server/iris/interface.go.tmpl",
	},
	"handler": {
		Name: "handler",
		Imports: []Import{
			{Path: "github.com/kataras/iris/v12"},
		},
		Template: "server/iris/handler.go.tmpl",
	},
	"wrapper": {
		Name: "wrapper",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "github.com/kataras/iris/v12"},
		},
		Template: "server/iris/wrapper.go.tmpl",
	},
}

IrisServerTemplates contains templates for Iris server generation.

View Source
var MarshalFormHelperTemplate = HelperTemplate{
	Name: "marshal_form",
	Imports: []Import{
		{Path: "errors"},
		{Path: "fmt"},
		{Path: "net/url"},
		{Path: "reflect"},
		{Path: "strings"},
	},
	Template: "helpers/marshal_form.go.tmpl",
}

MarshalFormHelperTemplate is the template for the marshalForm helper function. This is included when any operation has a form-encoded typed request body.

View Source
var ParamHelpersTemplate = ParamTemplate{
	Name: "helpers",
	Imports: []Import{
		{Path: "bytes"},
		{Path: "encoding"},
		{Path: "encoding/json"},
		{Path: "errors"},
		{Path: "fmt"},
		{Path: "net/url"},
		{Path: "reflect"},
		{Path: "sort"},
		{Path: "strconv"},
		{Path: "strings"},
		{Path: "time"},
		{Path: "github.com/google/uuid"},
	},
	Template: "params/helpers.go.tmpl",
}

ParamHelpersTemplate is the template for shared helper functions. This is included whenever any param function is used.

View Source
var ParamTemplates = map[string]ParamTemplate{

	"style_simple": {
		Name: "StyleSimpleParam",
		Imports: []Import{
			{Path: "bytes"},
			{Path: "encoding"},
			{Path: "encoding/json"},
			{Path: "errors"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_simple.go.tmpl",
	},
	"style_simple_explode": {
		Name: "StyleSimpleExplodeParam",
		Imports: []Import{
			{Path: "bytes"},
			{Path: "encoding"},
			{Path: "encoding/json"},
			{Path: "errors"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_simple_explode.go.tmpl",
	},
	"style_label": {
		Name: "StyleLabelParam",
		Imports: []Import{
			{Path: "bytes"},
			{Path: "encoding"},
			{Path: "encoding/json"},
			{Path: "errors"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_label.go.tmpl",
	},
	"style_label_explode": {
		Name: "StyleLabelExplodeParam",
		Imports: []Import{
			{Path: "bytes"},
			{Path: "encoding"},
			{Path: "encoding/json"},
			{Path: "errors"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_label_explode.go.tmpl",
	},
	"style_matrix": {
		Name: "StyleMatrixParam",
		Imports: []Import{
			{Path: "bytes"},
			{Path: "encoding"},
			{Path: "encoding/json"},
			{Path: "errors"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_matrix.go.tmpl",
	},
	"style_matrix_explode": {
		Name: "StyleMatrixExplodeParam",
		Imports: []Import{
			{Path: "bytes"},
			{Path: "encoding"},
			{Path: "encoding/json"},
			{Path: "errors"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_matrix_explode.go.tmpl",
	},
	"style_form": {
		Name: "StyleFormParam",
		Imports: []Import{
			{Path: "bytes"},
			{Path: "encoding"},
			{Path: "encoding/json"},
			{Path: "errors"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_form.go.tmpl",
	},
	"style_form_explode": {
		Name: "StyleFormExplodeParam",
		Imports: []Import{
			{Path: "bytes"},
			{Path: "encoding"},
			{Path: "encoding/json"},
			{Path: "errors"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_form_explode.go.tmpl",
	},
	"style_spaceDelimited": {
		Name: "StyleSpaceDelimitedParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_space_delimited.go.tmpl",
	},
	"style_spaceDelimited_explode": {
		Name: "StyleSpaceDelimitedExplodeParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_space_delimited_explode.go.tmpl",
	},
	"style_pipeDelimited": {
		Name: "StylePipeDelimitedParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_pipe_delimited.go.tmpl",
	},
	"style_pipeDelimited_explode": {
		Name: "StylePipeDelimitedExplodeParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/style_pipe_delimited_explode.go.tmpl",
	},
	"style_deepObject": {
		Name: "StyleDeepObjectParam",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "sort"},
			{Path: "strconv"},
			{Path: "strings"},
		},
		Template: "params/style_deep_object.go.tmpl",
	},

	"bind_simple": {
		Name: "BindSimpleParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
		},
		Template: "params/bind_simple.go.tmpl",
	},
	"bind_simple_explode": {
		Name: "BindSimpleExplodeParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
		},
		Template: "params/bind_simple_explode.go.tmpl",
	},
	"bind_label": {
		Name: "BindLabelParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
		},
		Template: "params/bind_label.go.tmpl",
	},
	"bind_label_explode": {
		Name: "BindLabelExplodeParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
		},
		Template: "params/bind_label_explode.go.tmpl",
	},
	"bind_matrix": {
		Name: "BindMatrixParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
		},
		Template: "params/bind_matrix.go.tmpl",
	},
	"bind_matrix_explode": {
		Name: "BindMatrixExplodeParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
		},
		Template: "params/bind_matrix_explode.go.tmpl",
	},
	"bind_form": {
		Name: "BindFormParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
		},
		Template: "params/bind_form.go.tmpl",
	},
	"bind_form_explode": {
		Name: "BindFormExplodeParam",
		Imports: []Import{
			{Path: "fmt"},
			{Path: "net/url"},
			{Path: "reflect"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/bind_form_explode.go.tmpl",
	},
	"bind_spaceDelimited": {
		Name: "BindSpaceDelimitedParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
		},
		Template: "params/bind_space_delimited.go.tmpl",
	},
	"bind_spaceDelimited_explode": {
		Name: "BindSpaceDelimitedExplodeParam",
		Imports: []Import{
			{Path: "net/url"},
		},
		Template: "params/bind_space_delimited_explode.go.tmpl",
	},
	"bind_pipeDelimited": {
		Name: "BindPipeDelimitedParam",
		Imports: []Import{
			{Path: "encoding"},
			{Path: "fmt"},
			{Path: "reflect"},
			{Path: "strings"},
		},
		Template: "params/bind_pipe_delimited.go.tmpl",
	},
	"bind_pipeDelimited_explode": {
		Name: "BindPipeDelimitedExplodeParam",
		Imports: []Import{
			{Path: "net/url"},
		},
		Template: "params/bind_pipe_delimited_explode.go.tmpl",
	},
	"bind_deepObject": {
		Name: "BindDeepObjectParam",
		Imports: []Import{
			{Path: "errors"},
			{Path: "fmt"},
			{Path: "net/url"},
			{Path: "reflect"},
			{Path: "sort"},
			{Path: "strconv"},
			{Path: "strings"},
			{Path: "time"},
		},
		Template: "params/bind_deep_object.go.tmpl",
	},
}

ParamTemplates maps style/explode combinations to their template definitions. Keys follow the pattern: "style_{style}" or "style_{style}_explode" for styling, and "bind_{style}" or "bind_{style}_explode" for binding.

View Source
var SenderTemplates = map[string]SenderTemplate{
	"sender_interface": {
		Name: "sender_interface",
		Imports: []Import{
			{Path: "context"},
			{Path: "io"},
			{Path: "net/http"},
		},
		Template: "sender/interface.go.tmpl",
	},
	"sender_methods": {
		Name: "sender_methods",
		Imports: []Import{
			{Path: "context"},
			{Path: "io"},
			{Path: "net/http"},
		},
		Template: "sender/methods.go.tmpl",
	},
	"sender_request_builders": {
		Name: "sender_request_builders",
		Imports: []Import{
			{Path: "bytes"},
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "io"},
			{Path: "net/http"},
			{Path: "net/url"},
			{Path: "strings"},
		},
		Template: "sender/request_builders.go.tmpl",
	},
	"sender_simple": {
		Name: "sender_simple",
		Imports: []Import{
			{Path: "context"},
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "io"},
			{Path: "net/http"},
		},
		Template: "sender/simple.go.tmpl",
	},
}

SenderTemplates contains templates shared between client and initiator generators. These templates accept SenderTemplateData and use {{if .IsClient}} to branch on the few points where client and initiator logic diverges.

View Source
var SharedServerTemplates = map[string]ServerTemplate{
	"errors": {
		Name: "errors",
		Imports: []Import{
			{Path: "fmt"},
		},
		Template: "server/errors.go.tmpl",
	},
	"param_types": {
		Name:     "param_types",
		Imports:  []Import{},
		Template: "server/param_types.go.tmpl",
	},
}

SharedServerTemplates contains templates shared across all server implementations.

View Source
var StdHTTPReceiverTemplates = map[string]ReceiverTemplate{
	"receiver": {
		Name: "receiver",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
		},
		Template: "server/stdhttp/receiver.go.tmpl",
	},
}

StdHTTPReceiverTemplates contains receiver templates for StdHTTP servers.

View Source
var StdHTTPServerTemplates = map[string]ServerTemplate{
	"interface": {
		Name: "interface",
		Imports: []Import{
			{Path: "net/http"},
		},
		Template: "server/stdhttp/interface.go.tmpl",
	},
	"handler": {
		Name: "handler",
		Imports: []Import{
			{Path: "net/http"},
		},
		Template: "server/stdhttp/handler.go.tmpl",
	},
	"wrapper": {
		Name: "wrapper",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "fmt"},
			{Path: "net/http"},
			{Path: "net/url"},
		},
		Template: "server/stdhttp/wrapper.go.tmpl",
	},
}

StdHTTPServerTemplates contains templates for StdHTTP server generation.

View Source
var TemplateFS embed.FS

TemplateFS contains all embedded template files. The files/* pattern recursively includes all files in subdirectories.

View Source
var TypeTemplates = map[string]TypeTemplate{
	"Email": {
		Name: "Email",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "errors"},
			{Path: "regexp"},
		},
		Template: "types/email.tmpl",
	},
	"Date": {
		Name: "Date",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "time"},
		},
		Template: "types/date.tmpl",
	},
	"UUID": {
		Name: "UUID",
		Imports: []Import{
			{Path: "github.com/google/uuid"},
		},
		Template: "types/uuid.tmpl",
	},
	"File": {
		Name: "File",
		Imports: []Import{
			{Path: "bytes"},
			{Path: "encoding/json"},
			{Path: "io"},
			{Path: "mime/multipart"},
		},
		Template: "types/file.tmpl",
	},
	"Nullable": {
		Name: "Nullable",
		Imports: []Import{
			{Path: "encoding/json"},
			{Path: "errors"},
		},
		Template: "types/nullable.tmpl",
	},
}

TypeTemplates maps type names to their template definitions.

Functions

func Funcs

func Funcs() template.FuncMap

Funcs returns the template function map for server templates.

func ParamStyleKey

func ParamStyleKey(prefix, style string, explode bool) string

ParamStyleKey returns the registry key for a style/explode combination. The prefix should be "style_" for serialization or "bind_" for binding.

func PathToChiPattern

func PathToChiPattern(path string) string

PathToChiPattern converts an OpenAPI path template to a Chi-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Chi: /users/{user_id}/posts/{post_id}

func PathToEchoPattern

func PathToEchoPattern(path string) string

PathToEchoPattern converts an OpenAPI path template to an Echo-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Echo: /users/:user_id/posts/:post_id

func PathToFiberPattern

func PathToFiberPattern(path string) string

PathToFiberPattern converts an OpenAPI path template to a Fiber-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Fiber: /users/:user_id/posts/:post_id

func PathToGinPattern

func PathToGinPattern(path string) string

PathToGinPattern converts an OpenAPI path template to a Gin-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Gin: /users/:user_id/posts/:post_id

func PathToGorillaPattern

func PathToGorillaPattern(path string) string

PathToGorillaPattern converts an OpenAPI path template to a Gorilla Mux-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Gorilla: /users/{user_id}/posts/{post_id}

func PathToIrisPattern

func PathToIrisPattern(path string) string

PathToIrisPattern converts an OpenAPI path template to an Iris-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Iris: /users/:user_id/posts/:post_id

func PathToStdHTTPPattern

func PathToStdHTTPPattern(path string) string

PathToStdHTTPPattern converts an OpenAPI path template to a Go 1.22+ std http pattern. OpenAPI: /users/{user_id}/posts/{post_id} StdHTTP: /users/{user_id}/posts/{post_id} Special case: "/" becomes "/{$}" to match only the root path.

func ToGoIdentifier

func ToGoIdentifier(s string) string

ToGoIdentifier converts a string to a valid Go identifier. This is a simple version for template usage.

Types

type ClientTemplate

type ClientTemplate struct {
	Name     string   // Template name (e.g., "base")
	Imports  []Import // Required imports for this template
	Template string   // Template path in embedded FS
}

ClientTemplate defines a template for client generation.

type HelperTemplate

type HelperTemplate struct {
	Name     string   // Template name (e.g., "marshal_form")
	Imports  []Import // Required imports for this function
	Template string   // Template path in embedded FS (e.g., "helpers/marshal_form.go.tmpl")
}

HelperTemplate defines a template for a helper function that is conditionally included.

type Import

type Import struct {
	Path  string
	Alias string // empty if no alias
}

Import represents a Go import with optional alias.

type InitiatorTemplate

type InitiatorTemplate struct {
	Name     string   // Template name (e.g., "initiator_base")
	Imports  []Import // Required imports for this template
	Template string   // Template path in embedded FS
}

InitiatorTemplate defines a template for initiator (webhook/callback sender) generation.

type ParamTemplate

type ParamTemplate struct {
	Name     string   // Function name (e.g., "StyleSimpleParam")
	Imports  []Import // Required imports for this function
	Template string   // Template name in embedded FS (e.g., "params/style_simple.go.tmpl")
}

ParamTemplate defines a template for a parameter styling/binding function.

type ReceiverTemplate

type ReceiverTemplate struct {
	Name     string   // Template name (e.g., "receiver")
	Imports  []Import // Required imports for this template
	Template string   // Template path in embedded FS
}

ReceiverTemplate defines a template for receiver (webhook/callback) generation.

type SenderTemplate

type SenderTemplate struct {
	Name     string   // Template name (e.g., "sender_interface")
	Imports  []Import // Required imports for this template
	Template string   // Template path in embedded FS
}

SenderTemplate defines a template shared between client and initiator generation.

type ServerTemplate

type ServerTemplate struct {
	Name     string   // Template name (e.g., "interface", "handler")
	Imports  []Import // Required imports for this template
	Template string   // Template path in embedded FS
}

ServerTemplate defines a template for server generation.

type TypeTemplate

type TypeTemplate struct {
	Name     string   // Type name (e.g., "Email", "Date")
	Imports  []Import // Required imports for this type
	Template string   // Template name in embedded FS (e.g., "types/email.tmpl")
}

TypeTemplate defines a template for a custom type along with its required imports.

Directories

Path Synopsis
test
helpers/genhelpers command
genhelpers generates Go files from helper and param templates.
genhelpers generates Go files from helper and param templates.
types/gentypes command
gentypes generates Go type files from templates.
gentypes generates Go type files from templates.

Jump to

Keyboard shortcuts

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