cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitUsage       = 1
	ExitBuildFailed = 2
	ExitRunFailed   = 3
	ExitDrift       = 4
	ExitWriteFailed = 5
)

Variables

View Source
var ErrDrift = errors.New("openapi output is out of date")

Functions

func CheckDrift

func CheckDrift(path string, data []byte) error

func CleanupDriver

func CleanupDriver(driverDir string, keep bool)

func DriverDir

func DriverDir(cfg Config) string

func EnsureOpenAPIModule

func EnsureOpenAPIModule(cfg Config) error

func ResolveOutputPath

func ResolveOutputPath(cfg Config) string

func RunDriver

func RunDriver(driverDir string) ([]byte, string, error)

func RunPipeline

func RunPipeline(cfg Config) ([]byte, []string, error)

func Serve

func Serve(cfg Config, serveCfg ServeConfig) error

func WriteAtomic

func WriteAtomic(path string, data []byte) error

func WriteDriver

func WriteDriver(cfg Config, entry Entry, hook *Hook) (string, error)

Types

type Config

type Config struct {
	ConfigPath       string
	ConfigExplicit   bool
	Entry            string            `yaml:"entry"`
	Out              string            `yaml:"out"`
	Format           string            `yaml:"format"`
	Sources          []string          `yaml:"sources"`
	IncludeTestFiles bool              `yaml:"includeTestFiles"`
	Info             InfoConfig        `yaml:"info"`
	Servers          []ServerConfig    `yaml:"servers"`
	Tags             []TagConfig       `yaml:"tags"`
	SecuritySchemes  map[string]Scheme `yaml:"securitySchemes"`
	MetadataHook     string            `yaml:"metadataHook"`
	AutoAdd          bool              `yaml:"autoAdd"`
	Workdir          string            `yaml:"workdir"`
	KeepDriver       bool              `yaml:"keepDriver"`
	Verbose          bool              `yaml:"verbose"`
}

func LoadConfig

func LoadConfig(overrides Overrides) (Config, error)

type DriverData

type DriverData struct {
	Entry              Entry
	Hook               Hook
	HasHook            bool
	Format             string
	OptionSnippets     []string
	InfoDescription    string
	ServerDescriptions []string
	TagSnippets        []string
}

func BuildDriverData

func BuildDriverData(cfg Config, entry Entry, hook *Hook) (DriverData, error)

type DriverError

type DriverError struct {
	Phase    string
	ExitCode int
	Stderr   string
	Cause    error
}

func (*DriverError) Error

func (e *DriverError) Error() string

type Entry

type Entry struct {
	ImportPath   string
	FuncName     string
	ReturnsError bool
}

func ResolveEntry

func ResolveEntry(workdir, value string) (Entry, error)

type ExternalDocsConfig

type ExternalDocsConfig struct {
	URL         string `yaml:"url"`
	Description string `yaml:"description"`
}

type Hook

type Hook struct {
	ImportPath string
	FuncName   string
}

func ResolveHook

func ResolveHook(workdir, value string) (Hook, error)

type InfoConfig

type InfoConfig struct {
	Title       string `yaml:"title"`
	Version     string `yaml:"version"`
	Description string `yaml:"description"`
}

type OAuthFlow

type OAuthFlow struct {
	AuthorizationURL string            `yaml:"authorizationUrl"`
	TokenURL         string            `yaml:"tokenUrl"`
	RefreshURL       string            `yaml:"refreshUrl"`
	Scopes           map[string]string `yaml:"scopes"`
}

type OAuthFlows

type OAuthFlows struct {
	Implicit          *OAuthFlow `yaml:"implicit"`
	Password          *OAuthFlow `yaml:"password"`
	ClientCredentials *OAuthFlow `yaml:"clientCredentials"`
	AuthorizationCode *OAuthFlow `yaml:"authorizationCode"`
}

type Overrides

type Overrides struct {
	ConfigPath          string
	ConfigExplicit      bool
	Entry               string
	EntrySet            bool
	Out                 string
	OutSet              bool
	Format              string
	FormatSet           bool
	Sources             []string
	SourcesSet          bool
	IncludeTestFiles    bool
	IncludeTestFilesSet bool
	MetadataHook        string
	MetadataHookSet     bool
	AutoAdd             bool
	AutoAddSet          bool
	Workdir             string
	WorkdirSet          bool
	KeepDriver          bool
	KeepDriverSet       bool
	Verbose             bool
	VerboseSet          bool
}

type Scheme

type Scheme struct {
	Type             string      `yaml:"type"`
	Description      string      `yaml:"description"`
	Name             string      `yaml:"name"`
	In               string      `yaml:"in"`
	Scheme           string      `yaml:"scheme"`
	BearerFormat     string      `yaml:"bearerFormat"`
	Flows            *OAuthFlows `yaml:"flows"`
	OpenIDConnectURL string      `yaml:"openIdConnectUrl"`
}

type ServeConfig

type ServeConfig struct {
	Addr  string
	UIs   []string
	Watch bool
	Open  bool
}

type ServerConfig

type ServerConfig struct {
	URL         string `yaml:"url"`
	Description string `yaml:"description"`
}

type TagConfig

type TagConfig struct {
	Name         string              `yaml:"name"`
	Description  string              `yaml:"description"`
	ExternalDocs *ExternalDocsConfig `yaml:"externalDocs"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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