gen

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package gen turns a parsed RTM spec into a generated Go client package. The caller passes a spec and an output directory; Generate emits one core file plus one file per service.

Index

Constants

View Source
const SchemaMajor = 1

SchemaMajor is the current response JSON Schema contract's major version. It is baked into every emitted `$id` URL and into the output directory layout on the GitHub Pages site. Bump deliberately when a response-shape change is not additive (field removal, type narrowing, optional → required).

Variables

View Source
var ErrInvalidConfig = errors.New("invalid generator config")

ErrInvalidConfig is returned when the caller supplied an incomplete generator configuration.

Functions

func GenerateCLI

func GenerateCLI(spec apispec.Spec, cfg CLIConfig) ([]string, error)

GenerateCLI emits the cobra commands package into cfg.OutDir from the given spec. It creates cfg.OutDir if missing, overwrites generated files, and returns the list of files written. It does not emit go.mod, main.go, or any file outside cfg.OutDir.

func GenerateClient

func GenerateClient(spec apispec.Spec, cfg Config) ([]string, error)

GenerateClient emits the RTM client package into cfg.OutDir from the given spec. It creates cfg.OutDir if missing, overwrites generated files, and returns the list of files written. It does not emit go.mod or any file outside cfg.OutDir.

func GenerateSchemas added in v0.2.0

func GenerateSchemas(spec apispec.Spec, cfg SchemaConfig) ([]string, error)

GenerateSchemas emits one JSON Schema (draft 2020-12) file per method in spec into cfg.OutDir, named `<rtm.method.name>.json`. Returns the paths of written files.

Types

type CLIConfig

type CLIConfig struct {
	OutDir            string
	PackageName       string
	ClientModulePath  string
	ClientPackageName string
}

CLIConfig describes a CLI-generation target.

type Config

type Config struct {
	OutDir      string
	PackageName string
}

Config describes a single client generation target.

type SchemaConfig added in v0.2.0

type SchemaConfig struct {
	OutDir string
}

SchemaConfig parameterises GenerateSchemas.

Jump to

Keyboard shortcuts

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