Documentation
¶
Overview ¶
Package spec fetches, caches and revalidates an OpenAPI document.
Index ¶
Constants ¶
const ( StatusFetched = "fetched" // the document is new or has changed StatusRevalidated = "revalidated" // confirmed unchanged, by 304 or by bytes StatusCached = "cached" // served from disk, network not consulted StatusStale = "stale" // the backend was unreachable )
How a spec came to be in hand, which is worth reporting under --verbose. The distinction that matters is whether the document changed, not whether a full GET happened: a server with no ETag makes every run a full GET.
const NegativeTTL = 10 * time.Minute
NegativeTTL is how long blip remembers that an environment serves no spec. Without it, a config that declares routes instead of a spec would pay for four failed probes on every single command.
Variables ¶
var ProbePaths = []string{
"/openapi/v1.json",
"/swagger/v1/swagger.json",
"/openapi/v1.yaml",
"/swagger/v1/swagger.yaml",
}
ProbePaths are tried in order when an environment does not name a spec_url. The first two cover .NET minimal APIs, from Microsoft.AspNetCore.OpenApi and from Swashbuckle respectively.
Functions ¶
Types ¶
type Fetcher ¶
type Fetcher struct {
Client *http.Client
// Strict is used for any candidate that is not the API's own origin, so an
// insecure granted for a localhost dev certificate cannot follow it away.
Strict *http.Client
Refresh bool
Offline bool
Warnf func(format string, args ...any)
// Authorize applies credentials to a spec request. It is called only after an
// unauthenticated attempt has been refused, so a public spec never reaches for
// a vault.
Authorize func(ctx context.Context, req *http.Request) error
}
Fetcher loads a spec, using the cache and the network according to the flags.