swift

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package swift provides a code generator for Swift.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(ctx context.Context, model *api.API, outdir string, cfg *parser.ModelConfig, swiftCfg *config.SwiftPackage) error

Generate generates code from the model.

func GenerateConversions added in v0.27.0

func GenerateConversions(ctx context.Context, model *api.API, outdir string, cfg *parser.ModelConfig, swiftCfg *config.SwiftPackage) error

GenerateConversions generates the user-facing clean types and conversion mappings.

func GenerateVersion added in v0.27.0

func GenerateVersion(ctx context.Context, outDir string, library *config.Library) error

GenerateVersion generates a version file for core and veneers.

Swift does not provide programmatic access to the version of a package. The version information is in `git`, not in any manifest file. In GAPICs and core libraries we need the version to populate telemetry headers.

This function generates a small "version file" based on the information in librarian.

func PackageName

func PackageName(api *api.API) string

PackageName returns the package name for the API.

func ProtoPackagePrefix added in v0.27.0

func ProtoPackagePrefix(packageName string) string

ProtoPackagePrefix returns the SwiftProtobuf prefix for a given protobuf package name. E.g., google.storage.control.v2 -> Google_Storage_Control_V2_.

Types

type DecodingStyle added in v0.21.0

type DecodingStyle int

DecodingStyle defines an enumeration for decoding fields.

const (
	// DecodingSimple means that the field is decoded using a simple `.decode()`
	// call.
	DecodingSimple DecodingStyle = iota

	// DecodingOptional means that the field is decoded using a
	// `.decodeIfPresent()` call.
	DecodingOptional

	// DecodingMapCustomKey means that the field is a map, with non-string keys
	// and requires mapping through a string-keyed temporary.
	DecodingMapCustomKey
)

type Dependency added in v0.10.1

type Dependency struct {
	config.SwiftDependency
}

Dependency wraps config.SwiftDependency to add helper methods.

func (*Dependency) LocalName added in v0.10.1

func (dep *Dependency) LocalName() string

LocalName returns the name of the dependency when used in a `Package.swift` file.

For local dependencies this is the last directory in the path. For external dependencies this is the last directory of the URL path.

type EncodingStyle added in v0.21.0

type EncodingStyle int

EncodingStyle defines an enumeration for encoding fields.

const (
	// EncodingSimple means that the field is encoded using a simple `.encode()` call.
	EncodingSimple EncodingStyle = iota

	// EncodingMapCustomKey means that the field is a map, with non-string keys
	// and requires mapping through a string-keyed temporary.
	EncodingMapCustomKey
)

Jump to

Keyboard shortcuts

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