gen

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 11 Imported by: 0 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

Overview

Package gen holds the pure parts of the generator: it validates the API spec and the shared hints and emits the Go source of the error catalog, the operation scope map and the hints table. scripts/generate.go is the command that wraps it with file and network access.

Index

Constants

View Source
const (
	// DefaultSpec is where the generator fetches the API spec from when it is given no path.
	DefaultSpec = "https://api.hushscript.com/openapi.json"
)

Variables

This section is empty.

Functions

func EmitCatalog

func EmitCatalog(spec map[string]any) ([]byte, error)

EmitCatalog returns generated/catalog.go: the error catalog as a lookup by slug.

func EmitHints

func EmitHints(hints map[string]string) ([]byte, error)

EmitHints returns generated/hints.go: the shared English hint text by error slug.

func EmitScopes

func EmitScopes(spec map[string]any) ([]byte, error)

EmitScopes returns generated/scopes.go: the permission each operation needs, keyed "METHOD /path".

func NameInlineObjects added in v1.1.0

func NameInlineObjects(spec map[string]any) ([]string, error)

NameInlineObjects gives every inline object schema that has properties a stable x-go-type-name derived from where it sits (Error.details becomes ErrorDetails), so oapi-codegen emits a named type instead of an anonymous struct. A named type can gain a field later without an incompatible change to package generated; an anonymous one cannot. The spec is changed in place and the names it assigned are returned, sorted. A name that another schema, another inline object or a type oapi-codegen derives from an operation already holds is an error: guessing would hide it.

func ParseHints

func ParseHints(text []byte) (map[string]string, error)

ParseHints decodes hints.json: a flat object of slug to text.

func ParseSpec

func ParseSpec(text []byte) (map[string]any, error)

ParseSpec decodes the spec, keeping numbers exact.

func PatchPathParameters

func PatchPathParameters(spec map[string]any) (patchedSpec []byte, changed []string, err error)

PatchPathParameters declares every path template variable that an operation leaves undeclared, as a required string parameter, because oapi-codegen refuses a path with an undeclared variable. It returns the patched spec as JSON for the generator's private copy (openapi.json itself is never touched) and the operations it changed. A declared path parameter that is not in the template is an error: that is a different defect, and guessing would hide it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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