sdk

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: EUPL-1.2 Imports: 15 Imported by: 0

Documentation

Overview

SDK validation and API compatibility commands.

Commands:

  • diff: Check for breaking API changes between spec versions
  • validate: Validate OpenAPI spec syntax

Configuration via .core/sdk.yaml. For SDK generation, use: core build sdk

Package sdk provides OpenAPI SDK generation and diff capabilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSDKCommands

func AddSDKCommands(root *cobra.Command)

AddSDKCommands registers the 'sdk' command and all subcommands.

func DiffExitCode

func DiffExitCode(result *DiffResult, err error) int

DiffExitCode returns the exit code for CI integration. 0 = no breaking changes, 1 = breaking changes, 2 = error

Types

type Config

type Config struct {
	// Spec is the path to the OpenAPI spec file (auto-detected if empty).
	Spec string `yaml:"spec,omitempty"`
	// Languages to generate SDKs for.
	Languages []string `yaml:"languages,omitempty"`
	// Output directory (default: sdk/).
	Output string `yaml:"output,omitempty"`
	// Package naming configuration.
	Package PackageConfig `yaml:"package,omitempty"`
	// Diff configuration for breaking change detection.
	Diff DiffConfig `yaml:"diff,omitempty"`
	// Publish configuration for monorepo publishing.
	Publish PublishConfig `yaml:"publish,omitempty"`
}

Config holds SDK generation configuration from .core/release.yaml.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns sensible defaults for SDK configuration.

type DiffConfig

type DiffConfig struct {
	// Enabled determines whether to run diff checks.
	Enabled bool `yaml:"enabled,omitempty"`
	// FailOnBreaking fails the release if breaking changes are detected.
	FailOnBreaking bool `yaml:"fail_on_breaking,omitempty"`
}

DiffConfig holds breaking change detection configuration.

type DiffResult

type DiffResult struct {
	// Breaking is true if breaking changes were detected.
	Breaking bool
	// Changes is the list of breaking changes.
	Changes []string
	// Summary is a human-readable summary.
	Summary string
}

DiffResult holds the result of comparing two OpenAPI specs.

func Diff

func Diff(basePath, revisionPath string) (*DiffResult, error)

Diff compares two OpenAPI specs and detects breaking changes.

type PackageConfig

type PackageConfig struct {
	// Name is the base package name.
	Name string `yaml:"name,omitempty"`
	// Version is the SDK version (supports templates like {{.Version}}).
	Version string `yaml:"version,omitempty"`
}

PackageConfig holds package naming configuration.

type PublishConfig

type PublishConfig struct {
	// Repo is the SDK monorepo (e.g., "myorg/sdks").
	Repo string `yaml:"repo,omitempty"`
	// Path is the subdirectory for this SDK (e.g., "packages/myapi").
	Path string `yaml:"path,omitempty"`
}

PublishConfig holds monorepo publishing configuration.

type SDK

type SDK struct {
	// contains filtered or unexported fields
}

SDK orchestrates OpenAPI SDK generation.

func New

func New(projectDir string, config *Config) *SDK

New creates a new SDK instance.

func (*SDK) DetectSpec

func (s *SDK) DetectSpec() (string, error)

DetectSpec finds the OpenAPI spec file. Priority: config path -> common paths -> Laravel Scramble.

func (*SDK) Generate

func (s *SDK) Generate(ctx context.Context) error

Generate generates SDKs for all configured languages.

func (*SDK) GenerateLanguage

func (s *SDK) GenerateLanguage(ctx context.Context, lang string) error

GenerateLanguage generates SDK for a specific language.

func (*SDK) SetVersion

func (s *SDK) SetVersion(version string)

SetVersion sets the SDK version for generation. This updates both the internal version field and the config's Package.Version.

Directories

Path Synopsis
Package generators provides SDK code generators for different languages.
Package generators provides SDK code generators for different languages.

Jump to

Keyboard shortcuts

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