Documentation
¶
Overview ¶
Package openapipreview parses an OpenAPI spec on demand so the create-server wizard can show which operations exist before anything is deployed.
It is deliberately a sibling of internal/probe rather than part of it. The probe performs an MCP handshake and returns []mcp.Tool, which discards the method, path, and tags a spec picker needs to filter on. The two share infrastructure patterns (TTL cache, stable error codes) but not a code path.
Index ¶
Constants ¶
const ( CodeInvalidRequest = "invalid_request" CodeNeedsAuth = "needs_auth" CodeFetchFailed = "fetch_failed" CodeParseFailed = "parse_failed" CodeRateLimited = "rate_limited" CodeInternal = "internal" )
Stable error codes. The web UI keys its copy off these, so treat them as a wire contract: add new ones rather than repurposing existing ones.
const DefaultTTL = 5 * time.Minute
DefaultTTL is how long a successful preview is cached.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a concurrency-safe TTL cache for preview results. The zero value is not usable — call NewCache.
func NewCache ¶
NewCache constructs a preview cache with the given TTL. Zero or negative TTLs fall back to DefaultTTL so callers cannot accidentally disable caching.
type Entry ¶
type Entry struct {
Title string
Version string
Operations []mcp.OperationSummary
LoadedAt time.Time
}
Entry is a cached preview result.
type Previewer ¶
type Previewer struct {
// contains filtered or unexported fields
}
Previewer parses specs and caches successful results.
func New ¶
New constructs a Previewer. A nil cache disables caching; a nil logger falls back to the default.
type Request ¶
type Request struct {
Spec string
CertFile string
KeyFile string
CAFile string
InsecureSkipVerify bool
}
Request identifies the spec to parse.
There is deliberately no auth block: spec fetching is unauthenticated on the deployed path too, because API credentials authenticate calls to the API, not retrieval of its description. TLS material is accepted because a spec served from an mTLS-protected host cannot be fetched without it.