builder

package
v0.0.0-...-61c2357 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

func New(cfg Config, opts ...Option) *Builder

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

func (b *Builder) Build() error

Build the SDK and write it to designated output directory. The OpenAPI specs first need to be loaded using Builder.Load.

func (*Builder) Load

func (b *Builder) Load(spec *v3.Document) error

Load loads OpenAPI specs into the builder. To generated the SDK, call Builder.Build.

func (*Builder) Samples

func (b *Builder) Samples(sdkVersion string) (*SampleCatalog, error)

Samples builds a deterministic catalog of Python examples using the generated SDK method IR.

type ClassDeclaration

type ClassDeclaration 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 []Property
	// Description holds the description of the type
	Description string
	// AdditionalPropertiesType holds the value type for additional properties if enabled.
	AdditionalPropertiesType string
	// RequestOnly marks request-only helper types that should not emit response models.
	RequestOnly bool
	// GenerateInput indicates this type needs an Input companion.
	GenerateInput bool
}

ClassDeclaration holds the information for generating a type. TODO: split into struct, alias, etc.

func (*ClassDeclaration) String

func (c *ClassDeclaration) String() string

func (*ClassDeclaration) TypeName

func (c *ClassDeclaration) TypeName() string

type Config

type Config struct {
	// Out is the output directory that the SDK will be written to.
	Out string
}

Config is builder configuration which configures output options.

type EnumDeclaration

type EnumDeclaration[E cmp.Ordered] struct {
	// Name of the type
	Name string
	// Type describes the type of the type (e.g. struct, int64, string)
	Type string
	// Comment holds the description of the type
	Comment string
	Values  []E
	// RequestOnly marks request-only helper types that should only emit input aliases.
	RequestOnly   bool
	GenerateInput bool
}

EnumDeclaration holds the information for enum types

func (*EnumDeclaration[E]) String

func (e *EnumDeclaration[E]) String() string

func (*EnumDeclaration[E]) TypeName

func (e *EnumDeclaration[E]) TypeName() string

type EventDefinition

type EventDefinition struct {
	RegistrationMethod string
	ObjectKind         string
	ClassName          string
	EventType          string
	ObjectType         string
	Description        string
}

EventDefinition describes a typed event notification generated from an OpenAPI webhook operation.

type Method

type Method struct {
	Description       string
	DeprecationNotice *string
	Method            string
	FunctionName      string
	ResponseType      *string
	Path              string
	PathParams        []Parameter
	QueryFields       []Property
	BodyType          string
	BodyFields        []Property
	HasBody           bool
	Responses         []Response
}

Method describes a client method. Methods map one-to-one to OpenAPI operations.

func (Method) BodyInitString

func (mt Method) BodyInitString() string

func (Method) HasFlattenedBody

func (mt Method) HasFlattenedBody() bool

func (Method) ParamsString

func (mt Method) ParamsString() string

func (Method) QueryInitString

func (mt Method) QueryInitString() string

type OneOfDeclaration

type OneOfDeclaration struct {
	Name          string
	Options       []string
	RequestOnly   bool
	GenerateInput bool
}

func (*OneOfDeclaration) String

func (o *OneOfDeclaration) String() string

func (*OneOfDeclaration) TypeName

func (o *OneOfDeclaration) TypeName() string

type Option

type Option func(b *Builder)

type Parameter

type Parameter struct {
	Name string
	Type string
}

Parameter is a method parameter.

type Property

type Property struct {
	// Name of the field
	Name string
	// SerializedName is the original identifier used when encoding (e.g. query parameter name).
	SerializedName 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
	// Optional field. The property may be omitted from the object.
	Optional bool
	// Nullable field. The property value may be JSON null.
	Nullable bool
	// Schema is the OpenAPI schema used to generate this property.
	Schema *base.SchemaProxy

	Comment string
}

Property holds the information for Property of a type.

func (Property) BodyArgumentExpr

func (p Property) BodyArgumentExpr(allowNone bool) string

func (Property) FieldName

func (p Property) FieldName() string

func (Property) MethodParameterString

func (p Property) MethodParameterString(allowNone bool) string

func (Property) MethodParameterType

func (p Property) MethodParameterType() string

func (*Property) String

func (p *Property) String() string

func (Property) TypedDictFieldString

func (p Property) TypedDictFieldString() string

func (Property) WireName

func (p Property) WireName() string

type Response

type Response struct {
	IsErr        bool
	IsDefault    bool
	IsUnexpected bool
	Type         string
	// Formats selects the parser by media type when a status has multiple formats.
	Formats        []errorResponseFormat
	Code           int
	ErrDescription string
}

func (Response) ErrorStatement

func (response Response) ErrorStatement() string

func (Response) ErrorType

func (response Response) ErrorType() string

type SDK

type SDK struct {
	Module  string `json:"module"`
	Version string `json:"version"`
}

SDK identifies the package used by every generated sample.

type Sample

type Sample struct {
	ID          string `json:"id"`
	OperationID string `json:"operationId"`
	Example     string `json:"example,omitempty"`
	Summary     string `json:"summary,omitempty"`
	Description string `json:"description,omitempty"`
	HTTPMethod  string `json:"httpMethod"`
	Path        string `json:"path"`
	Source      string `json:"sample"`
}

Sample is a complete Python program for one OpenAPI operation example.

type SampleCatalog

type SampleCatalog struct {
	SchemaVersion  int      `json:"schemaVersion"`
	Language       string   `json:"language"`
	SDK            SDK      `json:"sdk"`
	OpenAPIVersion string   `json:"openAPIVersion"`
	Samples        []Sample `json:"samples"`
}

SampleCatalog is the versioned JSON contract consumed by documentation sites.

type SchemaProxyCollection

type SchemaProxyCollection []*base.SchemaProxy

type Type

type Type interface {
	TypeName() string
}

type TypeAlias

type TypeAlias struct {
	// Name of the type
	Name string
	// Type describes the type of the type (e.g. struct, int64, string)
	Type string
	// Comment holds the description of the type
	Comment string
	// RequestOnly marks request-only helper types that should only emit input aliases.
	RequestOnly   bool
	GenerateInput bool
}

func (*TypeAlias) String

func (ta *TypeAlias) String() string

func (*TypeAlias) TypeName

func (ta *TypeAlias) TypeName() string

type Writable

type Writable interface {
	String() string
}

Jump to

Keyboard shortcuts

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