Documentation
¶
Overview ¶
Package spec handles API specification discovery, loading, and caching.
Index ¶
- Variables
- func ExpandParams(s string, params map[string]string) string
- func HasLocalSpecFiles(specFiles []string) bool
- func InvalidateCache(cacheDir, apiName string) error
- func LoadOperationSetFromCacheStatus(cacheDir, apiName, version string, specFiles []string, opts OperationOptions, ...) (OperationSet, OperationCacheStatus, bool)
- func MergeParameters(pathLevel, operationLevel []*v3.Parameter) []*v3.Parameter
- func OpExtBool(op *v3.Operation, key string) bool
- func OpExtString(op *v3.Operation, key string) string
- func OpExtStrings(op *v3.Operation, key string) []string
- func ParamExtBool(p *v3.Parameter, key string) bool
- func ParamExtString(p *v3.Parameter, key string) string
- func PathItemExtBool(item *v3.PathItem, key string) bool
- func ServerVariablesCacheKey(values map[string]string) string
- func StoreOperationSetInCache(cacheDir, apiName, version string, opts OperationOptions, set OperationSet) error
- func StoreSpecInCache(cacheDir, apiName, version string, apiSpec *APISpec, specFiles []string, ...) error
- type APIInfo
- type APISpec
- func Discover(ctx context.Context, cfg DiscoverConfig, loaders []Loader) (*APISpec, error)
- func LoadFromCache(cacheDir, apiName, version string, specFiles []string, loaders []Loader) (*APISpec, error)
- func LoadStaleFromCache(cacheDir, apiName, version string, specFiles []string, loaders []Loader) (*APISpec, error)
- func (s *APISpec) Info() (APIInfo, error)
- func (s *APISpec) OperationSet(opts OperationOptions) (OperationSet, error)
- func (s *APISpec) Operations(opts OperationOptions) ([]Operation, error)
- func (s *APISpec) SecuritySchemeSummaries() ([]SecuritySchemeSummary, error)
- func (s *APISpec) V3Model() (*libopenapi.DocumentModel[v3.Document], error)
- func (s *APISpec) XCLIExtensionReport() (XCLIExtensionReport, error)
- type CredentialAlternative
- type CredentialRequirement
- type DiscoverConfig
- type LoadError
- type LoadOptions
- type Loader
- type MethodOp
- type OpenAPILoader
- type Operation
- type OperationBodyHelp
- type OperationCacheStatus
- type OperationHelp
- type OperationOptions
- type OperationResponseHelp
- type OperationSet
- type OperationXCLI
- type Param
- type ParamObjectProperty
- type ParamXCLI
- type PluginLoader
- type SecuritySchemeSummary
- type XCLIAuth
- type XCLIConfig
- type XCLICredential
- type XCLIExtensionDetail
- type XCLIExtensionReport
- type XCLIProfile
- type XCLIPromptVar
Constants ¶
This section is empty.
Variables ¶
var ErrNoSpecFound = errors.New("no API spec found")
Functions ¶
func ExpandParams ¶
ExpandParams replaces {var} placeholders in s with the corresponding values from params. Unrecognised placeholders are left as-is.
func HasLocalSpecFiles ¶
func InvalidateCache ¶
InvalidateCache removes the cached spec file for apiName. Returns nil if the file did not exist.
func LoadOperationSetFromCacheStatus ¶
func LoadOperationSetFromCacheStatus(cacheDir, apiName, version string, specFiles []string, opts OperationOptions, allowStale bool) (OperationSet, OperationCacheStatus, bool)
LoadOperationSetFromCacheStatus reads extracted operations and reports whether the matching metadata is stale. When allowStale is true, expired remote spec metadata remains usable as "last known good" operations. Local spec file changes still invalidate the metadata, because the local source is immediately available and should be treated as authoritative.
func MergeParameters ¶
MergeParameters merges path-level and operation-level parameters. Operation-level parameters override path-level ones with the same (in, name). Header names are matched case-insensitively to match HTTP semantics.
func OpExtString ¶
OpExtString reads a string OpenAPI extension from an operation.
func OpExtStrings ¶
OpExtStrings reads a string-slice OpenAPI extension from an operation.
func ParamExtBool ¶
ParamExtBool reads a boolean OpenAPI extension from a parameter.
func ParamExtString ¶
ParamExtString reads a string OpenAPI extension from a parameter.
func PathItemExtBool ¶
PathItemExtBool reads a boolean OpenAPI extension from a path item.
func ServerVariablesCacheKey ¶
ServerVariablesCacheKey returns a deterministic string for operation-cache identity. It is exported so on-disk cache metadata can use the same shape as the in-memory APISpec cache.
func StoreOperationSetInCache ¶
func StoreOperationSetInCache(cacheDir, apiName, version string, opts OperationOptions, set OperationSet) error
StoreOperationSetInCache updates an existing raw cache entry with extracted operations and API metadata. It is best-effort for callers; failed upgrades should not make startup fail when the raw cache can still be parsed. Expired entries can be upgraded so rebuilt operation metadata is durable, but the original cache TTL is preserved. The cache entry is keyed by base URL, operation base, and server variable values (via opts).
func StoreSpecInCache ¶
func StoreSpecInCache(cacheDir, apiName, version string, apiSpec *APISpec, specFiles []string, opts OperationOptions, ttl time.Duration) error
StoreSpecInCache writes a parsed API spec and, when possible, extracted operation metadata to the on-disk spec cache. A non-positive ttl uses the default spec-cache lifetime.
Types ¶
type APIInfo ¶
APIInfo is the top-level OpenAPI info object fields Restish surfaces in generated command help and cached operation metadata.
type APISpec ¶
type APISpec struct {
// ContentType is the MIME type the spec was fetched with.
ContentType string
// Raw is the original spec bytes (JSON or YAML).
Raw []byte
// Document is the libopenapi parsed representation.
Document libopenapi.Document
// SourceURL/LocalPath capture where the spec came from so external refs can
// be resolved consistently when the raw spec is cached and reparsed.
SourceURL string
LocalPath string
AllowCrossOrigin bool
// contains filtered or unexported fields
}
APISpec is a parsed API specification.
func Discover ¶
Discover returns the APISpec for an API, using cache when available. Discovery order (first success wins, network steps run in parallel):
- CBOR spec cache
- Explicit SpecURL (if configured)
- Link headers from a GET on BaseURL (service-desc / service-doc / describedby)
- Well-known paths /openapi.json and /openapi.yaml
- BaseURL body itself
func LoadFromCache ¶
func LoadFromCache(cacheDir, apiName, version string, specFiles []string, loaders []Loader) (*APISpec, error)
LoadFromCache reads the cached spec for apiName, re-parses it using loaders, and returns the result. Returns nil, nil when the cache is empty or expired.
func LoadStaleFromCache ¶ added in v2.1.0
func LoadStaleFromCache(cacheDir, apiName, version string, specFiles []string, loaders []Loader) (*APISpec, error)
LoadStaleFromCache reads the cached spec for apiName even when the remote cache entry has expired. Local spec files still invalidate stale cache data when they changed after the cache was written.
func (*APISpec) OperationSet ¶
func (s *APISpec) OperationSet(opts OperationOptions) (OperationSet, error)
OperationSet returns all operations with top-level API metadata. The result is keyed by base URL, operation base, and resolved OpenAPI server variable values via opts.
func (*APISpec) Operations ¶
func (s *APISpec) Operations(opts OperationOptions) ([]Operation, error)
Operations returns all HTTP operations extracted from the spec's V3 model, with paths prefixed by the base path derived from the spec's servers[] list and opts.BaseURL. When opts.OperationBase is non-empty the spec servers are ignored and Operation.Path contains only the bare path template; the CLI resolves operationBase against baseURL at request time. opts.ServerVariables supplies values for OpenAPI server URL variables.
Results are memoized per (baseURL, operationBase, server variables) tuple.
func (*APISpec) SecuritySchemeSummaries ¶
func (s *APISpec) SecuritySchemeSummaries() ([]SecuritySchemeSummary, error)
SecuritySchemeSummaries returns the declared OpenAPI security schemes in document order with compact display metadata.
func (*APISpec) V3Model ¶
func (s *APISpec) V3Model() (*libopenapi.DocumentModel[v3.Document], error)
V3Model returns the built V3 document model, memoizing the result so that Document.BuildV3Model() is called at most once per APISpec.
func (*APISpec) XCLIExtensionReport ¶ added in v2.1.0
func (s *APISpec) XCLIExtensionReport() (XCLIExtensionReport, error)
XCLIExtensionReport extracts behavior-changing x-cli-* extension uses from the parsed OpenAPI document before generated command filtering is applied.
type CredentialAlternative ¶
type CredentialAlternative []CredentialRequirement
CredentialAlternative is one AND-set within OpenAPI's OR-list security model.
type CredentialRequirement ¶
type CredentialRequirement struct {
ID string // stable local ID, usually the OpenAPI security scheme name
Ref string // canonical source ref or URI
Kind string // oauth2, api-key, http-basic, http-bearer, openid, mtls, unknown
Needs []string // scopes, roles, or other requirement values
In string // api-key location, e.g. query, header, cookie
Name string // api-key parameter/header/cookie name
Source string // loader identity, e.g. openapi
External bool // true when the source used a URI-style reference
// Undeclared is true when OpenAPI security references an ID that is absent
// from components.securitySchemes.
Undeclared bool
// Deprecated is true when the source security scheme is marked deprecated.
Deprecated bool
}
CredentialRequirement is a loader-neutral authentication requirement.
type DiscoverConfig ¶
type DiscoverConfig struct {
// APIName is the registered short name (used as the cache key).
APIName string
// BaseURL is the API's root URL.
BaseURL string
// SpecURL, if non-empty, is checked before probing other locations.
// Ignored when SpecFiles is set.
SpecURL string
// SpecFiles, when non-empty, is an ordered list of local file paths or
// URLs to load the spec from. Multiple files are deep-merged in order
// (later entries win on conflict). Network discovery is skipped entirely.
SpecFiles []string
// CacheDir is the directory for CBOR spec cache files.
CacheDir string
// OperationBase overrides operation URL generation and is included in the
// cached operation metadata key.
OperationBase string
// ServerVariables supplies explicit OpenAPI server variable values and is
// included in cached operation metadata keys.
ServerVariables map[string]string
// Version is the running restish version; cache entries with a different
// version are discarded.
Version string
// Transport is used for all HTTP fetches. nil uses http.DefaultTransport.
Transport http.RoundTripper
// AllowCrossOrigin permits Link-header-discovered spec URLs on other hosts.
// When false, only same-host discovered links are followed. Private/local
// cross-origin targets are still rejected unless the base URL is already in
// that trust class.
AllowCrossOrigin bool
// ForceRefresh bypasses any cached entry and rebuilds it from the source.
ForceRefresh bool
// Timeout is used when the caller context has no deadline. Zero selects a
// default based on discovery mode.
Timeout time.Duration
// Trace receives verbose discovery progress messages.
Trace func(format string, args ...any)
// Warnf receives non-fatal operation extraction warnings.
Warnf func(format string, args ...any)
}
DiscoverConfig holds parameters for spec discovery for a single API.
type LoadError ¶
type LoadError struct {
Errors []string
}
LoadError wraps one or more errors returned by the libopenapi parser.
type LoadOptions ¶
type LoadOptions struct {
Context context.Context
ContentType string
SourceURL string
LocalPath string
AllowCrossOrigin bool
Transport http.RoundTripper
Trace func(format string, args ...any)
}
LoadOptions carries source metadata needed by loaders that resolve external references. Plain loaders may ignore it.
type Loader ¶
type Loader interface {
// Detect returns true if this loader recognises the content type and/or body.
Detect(contentType string, body []byte) bool
// LoadWithOptions parses body and returns a structured APISpec.
LoadWithOptions(body []byte, opts LoadOptions) (*APISpec, error)
// Priority determines loader selection order; higher priority wins.
Priority() int
}
Loader detects and parses an API specification format. Multiple loaders may be registered; the highest-priority one that detects a given body is used.
func DefaultLoaders ¶
func DefaultLoaders() []Loader
DefaultLoaders returns the built-in set of loaders.
type MethodOp ¶
MethodOp pairs an HTTP method name with its OpenAPI operation.
func PathItemMethods ¶
PathItemMethods returns all HTTP method/operation pairs for a path item in the conventional order GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE. Callers should check Op for nil before use.
type OpenAPILoader ¶
type OpenAPILoader struct{}
OpenAPILoader handles OpenAPI 3.0 and 3.1 specifications.
func (OpenAPILoader) Detect ¶
func (OpenAPILoader) Detect(contentType string, body []byte) bool
Detect returns true when the content type or body look like an OpenAPI spec. It accepts JSON, YAML, text-ish raw files, and the official OpenAPI MIME types, then confirms by sniffing for an "openapi:" / `"openapi"` key.
func (OpenAPILoader) Load ¶
func (OpenAPILoader) Load(body []byte) (*APISpec, error)
Load parses body as an OpenAPI 3.x document.
func (OpenAPILoader) LoadWithOptions ¶
func (OpenAPILoader) LoadWithOptions(body []byte, opts LoadOptions) (*APISpec, error)
LoadWithOptions parses body as an OpenAPI 3.x document, using source metadata to resolve supported external references.
func (OpenAPILoader) Priority ¶
func (OpenAPILoader) Priority() int
type Operation ¶
type Operation struct {
// ID is the operationId, or a kebab-case fallback when absent.
ID string
Method string
// Path is the full path template after applying any server base prefix.
Path string
// OperationServer is an absolute server URL from an operation/path-level
// OpenAPI server whose origin differs from the configured API base URL.
OperationServer string
Summary string
Description string
Deprecated bool
Tags []string
Parameters []Param
// HasBody is true when the operation has a requestBody.
HasBody bool
// BodyRequired is true when requestBody.required is true.
BodyRequired bool
// NoAuth is true when the operation explicitly declares security: [].
NoAuth bool
// OptionalAuth is true when an operation allows anonymous calls alongside
// one or more credential alternatives.
OptionalAuth bool
// CredentialAlternatives is the OR-list of AND credential requirements
// derived from the effective OpenAPI security requirement.
CredentialAlternatives []CredentialAlternative
// MCPIgnore is true when x-mcp-ignore is set.
MCPIgnore bool
// RequestMediaType is the deterministic preferred content type from
// requestBody.content, if the operation accepts a body.
RequestMediaType string
// ResponseMediaType is the deterministic preferred Accept value from
// successful response content, if the operation declares one.
ResponseMediaType string
// ResponseMediaTypes are all declared successful response content types in
// deterministic response-code and spec declaration order.
ResponseMediaTypes []string
// RequestMultipartContentTypes maps multipart/form-data property names to
// per-part Content-Type values from the OpenAPI encoding object.
RequestMultipartContentTypes map[string]string
XCLI OperationXCLI
Help OperationHelp
}
Operation is a single HTTP operation extracted from a spec, expressed in format-neutral terms so command generators need not import libopenapi.
type OperationBodyHelp ¶
type OperationBodyHelp struct {
MediaType string
Schema string
JSONSchema map[string]any
JSONSchemaDialect string
Example string
RawBinary bool
}
OperationBodyHelp is a compact request/response body example extracted from OpenAPI schemas for generated command help.
type OperationCacheStatus ¶
OperationCacheStatus describes the freshness of cached operation metadata.
func RawSpecCacheStatus ¶ added in v2.1.0
func RawSpecCacheStatus(cacheDir, apiName, version string, specFiles []string) (OperationCacheStatus, bool)
RawSpecCacheStatus reports the freshness of the cached raw spec. Expired remote specs can still report status; local spec file changes invalidate the cache because the local source is authoritative.
type OperationHelp ¶
type OperationHelp struct {
Request *OperationBodyHelp
Requests []OperationBodyHelp
Responses []OperationResponseHelp
Examples []string
}
OperationHelp stores pre-rendered help snippets for generated commands.
type OperationOptions ¶
type OperationOptions struct {
BaseURL string
OperationBase string
ServerVariables map[string]string
Warnf func(format string, args ...any)
}
OperationOptions controls config-sensitive OpenAPI operation extraction.
type OperationResponseHelp ¶
type OperationResponseHelp struct {
Codes []string
MediaType string
Headers []string
Schema string
Example string
NoBody bool
Description string
}
OperationResponseHelp is a compact response shape for generated command help. Codes may contain several status codes when they share the same schema.
type OperationSet ¶
type OperationSet struct {
Info APIInfo
Operations []Operation
Warnings []string
XCLIExtensions XCLIExtensionReport
}
OperationSet is the extracted operation list plus API-level metadata needed to present the generated command group without reparsing the raw spec.
func LoadOperationSetFromCache ¶
func LoadOperationSetFromCache(cacheDir, apiName, version string, specFiles []string, opts OperationOptions) (OperationSet, bool)
LoadOperationSetFromCache reads extracted operations and API metadata for a cached spec without reparsing the raw OpenAPI document. The bool return is false when the cache entry is missing, expired, stale against local files, or lacks operations for the requested base URL, operation base, and server variable set.
type OperationXCLI ¶
type OperationXCLI struct {
Ignore bool
Hidden bool
Name string
Description string
Aliases []string
}
OperationXCLI holds x-cli-* extension values extracted from an operation.
type Param ¶
type Param struct {
Name string
In string // "path", "query", "header", "cookie"
Desc string
Schema string
JSONSchema map[string]any
JSONSchemaDialect string
Required bool
Type string
ItemType string
Default string
DefaultValues []string
HasDefault bool
Style string
Explode *bool
AllowReserved bool
ContentMediaType string
Enum []string
ObjectProperties []ParamObjectProperty
XCLI ParamXCLI
}
Param is a single request parameter (path, query, header, or cookie).
type ParamObjectProperty ¶
ParamObjectProperty is a simple scalar property from an object-capable parameter schema, used by generated commands to expose child flags.
type ParamXCLI ¶
type ParamXCLI struct {
Ignore bool
Hidden bool
// Name overrides the kebab-case parameter name used for the flag.
Name string
// Description overrides the OpenAPI parameter description.
Description string
}
ParamXCLI holds x-cli-* extension values extracted from a parameter.
type PluginLoader ¶
PluginLoader is a spec.Loader backed by a hook plugin. The plugin receives a CBOR message on stdin with the URL, content type, and raw body; it returns a CBOR message containing an OpenAPI spec in JSON or YAML form.
func (PluginLoader) Detect ¶
func (l PluginLoader) Detect(contentType string, _ []byte) bool
Detect returns true when contentType matches one of the plugin's declared loader content types.
func (PluginLoader) Load ¶
func (l PluginLoader) Load(body []byte) (*APISpec, error)
Load calls the plugin and parses the returned OpenAPI spec. The returned APISpec has ContentType and Raw set from the plugin's response, allowing the plugin to produce a normalized form different from the input.
func (PluginLoader) LoadWithOptions ¶
func (l PluginLoader) LoadWithOptions(body []byte, opts LoadOptions) (*APISpec, error)
LoadWithOptions calls the plugin with source metadata from discovery or cache when it is available.
func (PluginLoader) Priority ¶
func (l PluginLoader) Priority() int
Priority returns a high priority so plugin loaders are tried before built-in loaders for the same content type.
type SecuritySchemeSummary ¶
type SecuritySchemeSummary struct {
ID string
Kind string
Detail string
Supported bool
GlobalDefault bool
Deprecated bool
}
SecuritySchemeSummary describes one declared security scheme in a loader-neutral shape suitable for CLI setup and diagnostics.
type XCLIAuth ¶
type XCLIAuth struct {
// Type is the restish auth type (e.g. "bearer", "http-basic").
Type string `json:"type,omitempty" yaml:"type,omitempty"`
// Params holds auth parameters; secret values should be empty strings.
Params map[string]string `json:"params,omitempty" yaml:"params,omitempty"`
}
XCLIAuth holds pre-populated authentication configuration.
func SchemeToXCLIAuth ¶
func SchemeToXCLIAuth(scheme *v3high.SecurityScheme, params map[string]string) *XCLIAuth
SchemeToXCLIAuth converts an OpenAPI security scheme to an XCLIAuth. params overrides are applied on top of the defaults derived from the scheme. Returns nil for unsupported/unrecognised scheme types.
type XCLIConfig ¶
type XCLIConfig struct {
// Profiles maps profile names to their pre-populated settings.
Profiles map[string]*XCLIProfile `json:"profiles,omitempty" yaml:"profiles,omitempty"`
// Legacy v1 shape. These fields are normalized into Profiles["default"]
// during API configuration so specs already in the wild keep working.
Security string `json:"security,omitempty" yaml:"security,omitempty"`
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
Prompt map[string]XCLIPromptVar `json:"prompt,omitempty" yaml:"prompt,omitempty"`
Params map[string]string `json:"params,omitempty" yaml:"params,omitempty"`
}
XCLIConfig is the x-cli-config extension at the OpenAPI document root. It drives `restish api connect` pre-population of the config file.
func FallbackXCLIConfig ¶
func FallbackXCLIConfig(s *APISpec) *XCLIConfig
FallbackXCLIConfig derives an XCLIConfig from the document's referenced security schemes when the spec does not define x-cli-config. The first scheme named in the document-level security requirements is preferred, followed by operation-level security requirements.
Returns nil when no supported auth scheme can be derived.
func ReadXCLIConfig ¶
func ReadXCLIConfig(s *APISpec) (*XCLIConfig, error)
ReadXCLIConfig extracts the x-cli-config extension from s.Raw. Returns nil, nil when the extension is absent or the spec cannot be parsed. Accepts both JSON and YAML specs (YAML is a superset of JSON).
func (*XCLIConfig) Normalize ¶
func (xcli *XCLIConfig) Normalize() *XCLIConfig
Normalize returns a copy of xcli using the v2 profile-shaped structure. Legacy top-level v1 x-cli-config fields are mapped to the default profile.
func (*XCLIConfig) Resolve ¶
func (xcli *XCLIConfig) Resolve(s *APISpec) *XCLIConfig
Resolve returns a copy of xcli with all Security scheme names resolved to XCLIAuth values and {var} templates in Headers expanded using Params. s is used for scheme lookups; it may be nil when no document is available (in which case unresolved Security fields are silently dropped). The original XCLIConfig is not modified.
type XCLICredential ¶
type XCLICredential struct {
Auth *XCLIAuth `json:"auth,omitempty" yaml:"auth,omitempty"`
AuthRef string `json:"auth_ref,omitempty" yaml:"auth_ref,omitempty"`
Satisfies []string `json:"satisfies,omitempty" yaml:"satisfies,omitempty"`
Prompt map[string]XCLIPromptVar `json:"prompt,omitempty" yaml:"prompt,omitempty"`
Params map[string]string `json:"params,omitempty" yaml:"params,omitempty"`
PromptValues map[string]string `json:"-" yaml:"-"`
PromptedParams map[string]bool `json:"-" yaml:"-"`
}
XCLICredential holds pre-populated configuration for one named operation credential requirement.
type XCLIExtensionDetail ¶ added in v2.1.0
type XCLIExtensionDetail struct {
Kind string `json:"kind" cbor:"kind"`
Extension string `json:"extension" cbor:"extension"`
Location string `json:"location" cbor:"location"`
Name string `json:"name,omitempty" cbor:"name,omitempty"`
Value string `json:"value,omitempty" cbor:"value,omitempty"`
Effect string `json:"effect" cbor:"effect"`
}
XCLIExtensionDetail is one behavior-changing x-cli-* extension use.
type XCLIExtensionReport ¶ added in v2.1.0
type XCLIExtensionReport struct {
Details []XCLIExtensionDetail `json:"details,omitempty" cbor:"details,omitempty"`
}
XCLIExtensionReport describes behavior-changing x-cli-* OpenAPI extensions found in a document. It intentionally excludes x-cli-description, which only changes help prose.
func (XCLIExtensionReport) Empty ¶ added in v2.1.0
func (r XCLIExtensionReport) Empty() bool
Empty reports whether the document had any behavior-changing x-cli-* uses.
func (XCLIExtensionReport) Summary ¶ added in v2.1.0
func (r XCLIExtensionReport) Summary() []string
Summary returns stable, compact phrases for human connect/sync output.
type XCLIProfile ¶
type XCLIProfile struct {
Headers []string `json:"headers,omitempty" yaml:"headers,omitempty"`
Query []string `json:"query,omitempty" yaml:"query,omitempty"`
Auth *XCLIAuth `json:"auth,omitempty" yaml:"auth,omitempty"`
Credentials map[string]*XCLICredential `json:"credentials,omitempty" yaml:"credentials,omitempty"`
// Security, when non-empty, is the name of a security scheme in the spec's
// components/securitySchemes. It is resolved to an Auth type and default
// Params when applying the config; an explicit Auth field takes precedence.
Security string `json:"security,omitempty" yaml:"security,omitempty"`
// Params holds key→value pairs used for {var} template expansion in Headers.
// Empty-string values indicate a placeholder that the operator should fill in.
Params map[string]string `json:"params,omitempty" yaml:"params,omitempty"`
// Prompt describes configuration-time questions. Prompted values are written
// into Params before Resolve runs; prompts are never evaluated at request time.
Prompt map[string]XCLIPromptVar `json:"prompt,omitempty" yaml:"prompt,omitempty"`
// PromptValues holds configure-time prompt answers, including excluded
// answers that are only available for template expansion.
PromptValues map[string]string `json:"-" yaml:"-"`
// PromptedParams marks Params entries that came directly from prompt input.
// Prompt answers are literal values and are not expanded a second time.
PromptedParams map[string]bool `json:"-" yaml:"-"`
}
XCLIProfile holds pre-populated configuration for a single API profile.
func SchemeToXCLIAPIKeyProfile ¶
func SchemeToXCLIAPIKeyProfile(scheme *v3high.SecurityScheme) *XCLIProfile
SchemeToXCLIAPIKeyProfile converts an OpenAPI apiKey security scheme into first-class setup prompts that persist as profile headers or query params.
type XCLIPromptVar ¶
type XCLIPromptVar struct {
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Example string `json:"example,omitempty" yaml:"example,omitempty"`
Default any `json:"default,omitempty" yaml:"default,omitempty"`
Enum []any `json:"enum,omitempty" yaml:"enum,omitempty"`
// Exclude keeps the prompted value out of auth params; it can still be used
// for {var} template expansion in Params, Headers, or explicit Auth params.
Exclude bool `json:"exclude,omitempty" yaml:"exclude,omitempty"`
}
XCLIPromptVar describes a single configuration-time prompt from the legacy v1 x-cli-config.prompt extension.