Documentation
¶
Index ¶
- Constants
- Variables
- func CheckDrift(path string, data []byte) error
- func CleanupDriver(driverDir string, keep bool)
- func DriverDir(cfg Config) string
- func ResolveOutputPath(cfg Config) string
- func RunDriver(driverDir string) ([]byte, string, error)
- func RunPipeline(cfg Config) ([]byte, []string, error)
- func Serve(cfg Config, serveCfg ServeConfig) error
- func WriteAtomic(path string, data []byte) error
- func WriteDriver(cfg Config, entry Entry, hook *Hook, loader *ConfigLoader) (string, error)
- type Config
- type ConfigLoader
- type DriverData
- type DriverError
- type Entry
- type EntryCandidate
- type EntryConfig
- type ExternalDocsConfig
- type Hook
- type InfoConfig
- type InitOptions
- type InitResult
- type OAuthFlow
- type OAuthFlows
- type Overrides
- type Scheme
- type ServeConfig
- type ServerConfig
- type TagConfig
Constants ¶
View Source
const ( // FormatYAML emits the spec as YAML. FormatYAML = "yaml" // FormatJSON emits the spec as JSON. FormatJSON = "json" )
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 CleanupDriver ¶
func ResolveOutputPath ¶
func Serve ¶
func Serve(cfg Config, serveCfg ServeConfig) error
func WriteAtomic ¶
func WriteDriver ¶
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"`
EntryConfig EntryConfig `yaml:"entryConfig"`
Workdir string `yaml:"workdir"`
KeepDriver bool `yaml:"keepDriver"`
Verbose bool `yaml:"verbose"`
// EntryAutoDiscovered is true when the entry was filled in by
// DiscoverEntry rather than the config file or CLI flags. CLI commands
// use this to surface "entry: ..." back to the user so the auto-pick is
// never invisible.
EntryAutoDiscovered bool `yaml:"-"`
// EntryDiscoveryScope narrows where DiscoverEntry looks for an entry
// function. Filled in by the CLI from the optional positional path
// argument. It does NOT affect Sources (comment extraction), which is
// kept module-wide so descriptions on referenced types are not lost
// when the entry lives in a sub-tree.
EntryDiscoveryScope []string `yaml:"-"`
// ResolvedEntry caches the *Entry produced by DiscoverEntry so the
// pipeline can skip a second packages.Load on the auto-discovery path.
// nil when the entry was set explicitly and still needs ResolveEntry.
ResolvedEntry *Entry `yaml:"-"`
}
func LoadConfig ¶
type ConfigLoader ¶ added in v0.2.0
func ResolveConfigLoader ¶ added in v0.2.0
func ResolveConfigLoader(workdir, value, path string) (ConfigLoader, error)
type DriverData ¶
type DriverData struct {
Entry Entry
Hook Hook
ConfigLoader ConfigLoader
HasHook bool
HasConfigLoader bool
Format string
OptionSnippets []string
InfoDescription string
ServerDescriptions []string
TagSnippets []string
}
func BuildDriverData ¶
func BuildDriverData(cfg Config, entry Entry, hook *Hook, loader *ConfigLoader) (DriverData, error)
type DriverError ¶
func (*DriverError) Error ¶
func (e *DriverError) Error() string
type Entry ¶
type Entry struct {
ImportPath string
FuncName string
ReturnsError bool
TakesContext bool
TakesConfig bool
}
func DiscoverEntry ¶ added in v0.2.0
DiscoverEntry walks the given scope (e.g. []string{"./..."}) under workdir and looks for an exported function whose signature matches one of the supported entry shapes (see entrySignatureError).
Resolution rules:
- If one or more candidates are marked with `// fox-openapi:entry`, only marked candidates are considered.
- Exactly one candidate -> success.
- Zero candidates -> "no entry function found" error.
- Multiple candidates -> error listing all symbols so the user can disambiguate via --entry or the marker comment.
func ResolveEntry ¶
type EntryCandidate ¶ added in v0.2.0
EntryCandidate describes a function that matches the entry signature. It is exported so callers can render multi-match diagnostics.
func (EntryCandidate) Symbol ¶ added in v0.2.0
func (c EntryCandidate) Symbol() string
Symbol returns the fully qualified runtime symbol (importPath.FuncName).
type EntryConfig ¶ added in v0.2.0
type ExternalDocsConfig ¶
type Hook ¶
func ResolveHook ¶
type InfoConfig ¶
type InitOptions ¶ added in v0.2.0
type InitOptions struct {
Workdir string
ConfigPath string
Entry string
Out string
Title string
Version string
Force bool
}
InitOptions configures fox-openapi.yaml initialization.
type InitResult ¶ added in v0.2.0
InitResult describes what InitConfig wrote so callers can surface it.
func InitConfig ¶ added in v0.2.0
func InitConfig(opts InitOptions) (InitResult, error)
InitConfig writes an initial fox-openapi.yaml.
type OAuthFlows ¶
type Overrides ¶
type Overrides struct {
ConfigPath string
ConfigExplicit bool
Entry string
EntrySet bool
Out string
OutSet bool
Format string
FormatSet bool
InfoTitle string
InfoTitleSet bool
InfoVersion string
InfoVersionSet bool
Servers []string
ServersSet bool
Sources []string
SourcesSet bool
IncludeTestFiles bool
IncludeTestFilesSet bool
MetadataHook string
MetadataHookSet bool
EntryConfigLoader string
EntryConfigLoaderSet bool
EntryConfigPath string
EntryConfigPathSet bool
Workdir string
WorkdirSet bool
KeepDriver bool
KeepDriverSet bool
Verbose bool
VerboseSet bool
// EntryDiscoveryScope is set by the CLI from the optional positional
// path argument. It limits where DiscoverEntry searches but does not
// affect Sources (comment extraction).
EntryDiscoveryScope []string
EntryDiscoveryScopeSet bool
}
type ServeConfig ¶
type ServerConfig ¶
type TagConfig ¶
type TagConfig struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
ExternalDocs *ExternalDocsConfig `yaml:"externalDocs"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.