Documentation
¶
Overview ¶
Package golang generates a typed Go client SDK from an AuthSome OpenAPI spec.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GeneratedFile ¶
GeneratedFile represents a single generated file.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator produces Go SDK code from an OpenAPI spec.
func NewGenerator ¶
func NewGenerator(cfg GeneratorConfig) *Generator
NewGenerator creates a Go SDK generator.
type GeneratorConfig ¶
type GeneratorConfig struct {
// PackageName is the Go package name (default: "authclient").
PackageName string
// ModulePath is the Go module path (default: "github.com/xraph/authsome/client").
ModulePath string
}
GeneratorConfig configures the Go SDK generator.
type OperationDef ¶
type OperationDef struct {
Name string
Method string
Path string
Summary string
HasBody bool
FormBody bool
BodyFields []FieldDef
ResponseType string
AuthRequired bool
Tags []string
PathParams []ParamDef
QueryParams []ParamDef
}
OperationDef represents a generated client method.
func (OperationDef) HasPathParams ¶
func (o OperationDef) HasPathParams() bool
HasPathParams returns true when the operation has path parameters.
func (OperationDef) HasQueryParams ¶
func (o OperationDef) HasQueryParams() bool
HasQueryParams returns true when the operation has query parameters.
type ParamDef ¶
type ParamDef struct {
Name string // original name from spec ("orgId")
GoName string // exported Go name ("OrgID")
Type string // Go type ("string", "[]string")
// Repeated marks an array-typed query parameter, which is sent once per
// value rather than once in total. Query parameters default to style form
// with explode true, so an array in the document means exactly that.
Repeated bool
// ItemType is the element type behind Repeated ("string"), so the template
// knows whether each value needs converting on its way into the query.
ItemType string
}
ParamDef represents a path or query parameter for a client method.
type TemplateData ¶
type TemplateData struct {
PackageName string
ModulePath string
Types []TypeDef
Operations []OperationDef
HasSocial bool
HasMagicLink bool
HasMFA bool
// contains filtered or unexported fields
}
TemplateData holds all data passed to templates.
func (*TemplateData) IsNewRequestType ¶
func (d *TemplateData) IsNewRequestType(opName string) bool
IsNewRequestType returns true if the operation's request type name doesn't collide with an existing schema type.