Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is an SDK builder. Builder works in two steps: First, it loads the OpenAPI specs and pre-processes them for code generation by transforming the specs into intermediary representation. Secondly, it generates and writes the SDK to desired destination.
func New ¶
New creates a new Builder. Call [Build.Load] to load in OpenAPI specs and [Build.Build] to generate SDK based on provided config.
func (*Builder) Build ¶
Build the SDK and write it to designated output directory. The OpenAPI specs first need to be loaded using Builder.Load.
type Config ¶
type Config struct {
// Out is the output directory that the SDK will be written to.
Out string
// PkgName is the name of the package.
PkgName string
// Module is the name of golang module.
Module string
// Name is the name of the product / service.
Name string
}
Config is builder configuration which configures output options.
type EnumDeclaration ¶
type EnumDeclaration[E cmp.Ordered] struct { Type TypeDeclaration Values []EnumOption[E] }
EnumDeclaration holds the information for enum types
func (*EnumDeclaration[E]) String ¶
func (et *EnumDeclaration[E]) String() string
type EnumOption ¶
type Method ¶
type Method struct {
Description string
HTTPMethod string
FunctionName string
ResponseType *ResponseType
Path string
PathParams []Parameter
QueryParams *Parameter
HasBody bool
Responses []Response
}
Method describes a client method. Methods map one-to-one to OpenAPI operations.
func (Method) ParamsString ¶
type OneOfDeclaration ¶
func (*OneOfDeclaration) String ¶
func (o *OneOfDeclaration) String() string
type ResponseType ¶
type StructField ¶
type StructField struct {
// Name of the field
Name string
// Type of the field, either primitive type (e.g. string) or if the field
// is a schema reference then the type of the schema.
Type string
// Tags to apply to the field, this would usually be json serialization
// information.
Tags map[string][]string
// Optional field.
Optional bool
// Pointer indicates whether the field should be a pointer in the generated struct.
Pointer bool
Comment string
Parameter *openapi3.Parameter
}
StructField holds the information for StructField of a type.
func (*StructField) String ¶
func (f *StructField) String() string
type TypeDeclaration ¶
type TypeDeclaration struct {
// Name of the type
Name string
// Type describes the type of the type (e.g. struct, int64, string)
Type string
// Fields holds the information for the field
Fields []StructField
// Comment holds the description of the type
Comment string
Response *openapi3.Response
Operation *openapi3.Operation
Schema *openapi3.Schema
}
TypeDeclaration holds the information for generating a type. TODO: split into struct, alias, etc.
func (*TypeDeclaration) String ¶
func (tt *TypeDeclaration) String() string