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
- func EmitCatalog(spec map[string]any) ([]byte, error)
- func EmitHints(hints map[string]string) ([]byte, error)
- func EmitScopes(spec map[string]any) ([]byte, error)
- func ParseHints(text []byte) (map[string]string, error)
- func ParseSpec(text []byte) (map[string]any, error)
- func PatchPathParameters(spec map[string]any) (patchedSpec []byte, changed []string, err error)
Constants ¶
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 ¶
EmitCatalog returns generated/catalog.go: the error catalog as a lookup by slug.
func EmitScopes ¶
EmitScopes returns generated/scopes.go: the permission each operation needs, keyed "METHOD /path".
func ParseHints ¶
ParseHints decodes hints.json: a flat object of slug to text.
func PatchPathParameters ¶
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.