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

dart

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: 8 Imported by: 0

Documentation

Overview

Package dart generates a typed Dart 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 // Dart field name (camelCase)
	JSONName string // Original JSON key
	Type     string // Dart type
	Optional bool
}

FieldDef represents a field in a Dart class.

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 Dart SDK code from an OpenAPI spec.

func NewGenerator

func NewGenerator(cfg GeneratorConfig) *Generator

NewGenerator creates a Dart SDK generator.

func (*Generator) Generate

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

Generate produces all Dart SDK files from the given spec.

type GeneratorConfig

type GeneratorConfig struct {
	// PackageName is the Dart package name (default: "authsome_core").
	PackageName string

	// PackageVersion is the Dart package version (default: "0.1.0").
	PackageVersion string

	// OutputMode controls what files are generated.
	// "standalone" (default) — full Dart package (types, client, pubspec).
	// "embedded" — only api_types.dart and api_client.dart for embedding.
	OutputMode string

	// MethodOverrides maps operationID to a custom method name.
	MethodOverrides map[string]string
}

GeneratorConfig configures the Dart SDK generator.

type OperationDef

type OperationDef struct {
	Name         string
	Method       string
	Path         string
	Summary      string
	HasBody      bool
	FormBody     bool
	BodyType     string // Dart type of the request body
	ResponseType string // Dart type of the response
	AuthRequired bool
	PathParams   []PathParamDef
	QueryParams  []QueryParamDef
}

OperationDef represents a generated client method.

type PathParamDef

type PathParamDef struct {
	Name     string // Original name from the spec
	DartName string // Dart parameter name (camelCase)
}

PathParamDef represents a path parameter in an operation.

type QueryParamDef

type QueryParamDef struct {
	Name     string // Original name from the spec
	DartName string // Dart parameter name
	Type     string // Dart type ("String", "List<String>")
	Required bool

	// 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
}

QueryParamDef represents a query parameter in an operation.

type TemplateData

type TemplateData struct {
	PackageName    string
	PackageVersion string
	OutputMode     string
	Types          []TypeDef
	Operations     []OperationDef
}

TemplateData holds all data passed to templates.

type TypeDef

type TypeDef struct {
	Name   string
	Fields []FieldDef
}

TypeDef represents a generated Dart class.

Jump to

Keyboard shortcuts

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