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 ¶
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 ¶
var ErrInvalidConfig = errors.New("invalid generator config")
ErrInvalidConfig is returned when the caller supplied an incomplete generator configuration.
Functions ¶
func GenerateCLI ¶
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 ¶
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 SchemaConfig ¶ added in v0.2.0
type SchemaConfig struct {
OutDir string
}
SchemaConfig parameterises GenerateSchemas.