gen

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 23 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 turns an OpenAPI 3.0 / 3.1 document into a tui-builder config: `tui-builder gen <spec>`.

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout bounds fetching a spec (and each file or URL it references) from a URL.

Variables

View Source
var ErrNothing = errors.New("nothing to generate")

ErrNothing is returned when no selected operation maps to a screen.

Functions

This section is empty.

Types

type DocOptions

type DocOptions struct {
	// Name is --name: the preset's name and the env prefix's source.
	Name string
	// BaseURL is --base-url: the base URL's default, overriding servers.
	BaseURL string
	// PromptServer is --prompt-server: ask which server at startup when
	// the spec lists several.
	PromptServer bool
	// Security is the overrides' gen.security: the scheme whose
	// alternative to use, in place of the first.
	Security string
}

Document-level options.

type Input

type Input struct {
	// Spec is a file path, an http(s):// URL, or "-" for Stdin.
	Spec  string
	Stdin io.Reader
	// Headers are sent with every URL fetch (--header), for specs behind
	// auth. They never reach the config.
	Headers http.Header
	Timeout time.Duration
}

Input is where the spec comes from.

type Options

type Options struct {
	Input  Input
	Select Select
	Doc    DocOptions
	// Layout is --layout: "tabs" or "menu" in place of the count's
	// choice.
	Layout string
	// Command is the command line as typed, for the header comment.
	Command string
	// Overrides is --overrides: a file of gen: hints and config to merge
	// in; PruneOverrides makes hints for operations gone from the spec
	// warnings rather than errors.
	Overrides      string
	PruneOverrides bool
	// InitOverrides asks for a starter overrides file (Result.Starter).
	InitOverrides bool
	// Previous is the config this run replaces, when there is one: its
	// footer lists the spec's operations then, so new ones can be told.
	Previous []byte
}

Options is what `tui-builder gen` was asked for.

func (*Options) Register

func (o *Options) Register(f *pflag.FlagSet)

Register adds the flags that shape what's generated to f.

type Result

type Result struct {
	Config []byte
	// Summary is a count of what was generated.
	Summary string
	// Skipped is one line per operation not generated, with why.
	Skipped []string
	// Warnings are things that will likely go wrong at runtime.
	Warnings []string
	// Hints suggest what to do about a big result: --tag, with a count
	// per tag.
	Hints []string
	// Notes say how lists are fetched where it's worth knowing: those
	// that walk every page, and why some that looked windowed don't.
	Notes []string
	// Starter is a starter overrides file, with InitOverrides.
	Starter []byte
	// New and Gone are the spec's operations since the Previous config
	// was generated: added, and removed.
	New, Gone []string
}

Result is a generated config and what to tell the user.

func Generate

func Generate(ctx context.Context, opts Options) (Result, error)

Generate reads the spec and writes the config.

type Select

type Select struct {
	// Tags and Operations narrow to those listed (operationIds, globs
	// like list_*); ExcludeTags and ExcludeOperations then remove.
	Tags, ExcludeTags             []string
	Operations, ExcludeOperations []string
	// ReadOnly generates nothing from POST, PUT, PATCH or DELETE.
	ReadOnly bool
	// IncludeDeprecated keeps deprecated: true operations.
	IncludeDeprecated bool
}

Select is which operations to generate from.

Jump to

Keyboard shortcuts

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