Documentation
¶
Overview ¶
Package gen turns an OpenAPI 3.0 / 3.1 document into a tui-builder config: `tui-builder gen <spec>`.
Index ¶
Constants ¶
const DefaultTimeout = 30 * time.Second
DefaultTimeout bounds fetching a spec (and each file or URL it references) from a URL.
Variables ¶
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.
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.
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.