Help us shape the future of Go! Take the 2026 Go Developer Survey

golang

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 10 Imported by: 0

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 FieldDef

type FieldDef struct {
	Name     string
	Type     string
	JSONTag  string
	Optional bool
}

FieldDef represents a field in a Go struct.

type GeneratedFile

type GeneratedFile struct {
	Path    string
	Content string
}

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.

func (*Generator) Generate

func (g *Generator) Generate(spec *openapi.Spec) ([]GeneratedFile, error)

Generate produces all Go SDK files from the given spec.

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.

type TypeDef

type TypeDef struct {
	Name   string
	Fields []FieldDef
}

TypeDef represents a generated Go struct.

Jump to

Keyboard shortcuts

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