Documentation
¶
Index ¶
- func FetchOrCacheSpec(specURL string, refresh bool, skipCache bool) ([]byte, error)
- func IsGraphQLSDL(data []byte) bool
- func IsOpenAPI(data []byte) bool
- func IsRemoteSpecSource(source string) bool
- func LoadSpecBytes(source string, refresh bool, skipCache bool) ([]byte, error)
- func Parse(data []byte) (*spec.APISpec, error)
- func ParseFile(path string) (*spec.APISpec, error)
- func ParseFileLenient(path string) (*spec.APISpec, error)
- func ParseLenient(data []byte) (*spec.APISpec, error)
- func ParseWithOptions(data []byte, opts ParseOptions) (*spec.APISpec, error)
- func ParseWithPath(data []byte, path string) (*spec.APISpec, error)
- func ParseWithPathLenient(data []byte, path string) (*spec.APISpec, error)
- func SetMaxEndpointsPerResource(n int)
- func SetMaxResources(n int)
- type ParseOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchOrCacheSpec ¶ added in v4.5.1
FetchOrCacheSpec downloads a spec over http(s) with a 24h on-disk cache. Exported so packages outside internal/cli (notably internal/pipeline) can route URL-sourced specs through the same fetch path the generator uses, keeping scorer subcommands and generate in sync.
func IsGraphQLSDL ¶
func IsRemoteSpecSource ¶ added in v4.1.0
IsRemoteSpecSource reports whether a spec source should be loaded as a URL.
func LoadSpecBytes ¶ added in v4.5.1
LoadSpecBytes reads OpenAPI spec bytes from either a local filesystem path or an http(s) URL, picking the right transport from the source string. Callers that previously wrapped os.ReadFile gain URL support transparently; the local-path branch is identical to the prior os.ReadFile call.
URL responses are cached under ~/.cache/printing-press/specs for 24h to match the generator's intake behavior; pass refresh=true to bypass the cache and skipCache=true to skip writing it.
func ParseFile ¶ added in v4.1.0
ParseFile parses an OpenAPI spec from a file and resolves local external refs relative to that file.
func ParseFileLenient ¶ added in v4.1.0
ParseFileLenient parses an OpenAPI spec from a file and skips validation errors from broken $refs after resolving local external refs relative to that file.
func ParseLenient ¶
ParseLenient parses an OpenAPI spec, skipping validation errors from broken $refs. It logs warnings to stderr for any issues found but continues parsing.
func ParseWithOptions ¶ added in v4.9.0
func ParseWithOptions(data []byte, opts ParseOptions) (*spec.APISpec, error)
ParseWithOptions is the canonical parser entry point; the older Parse* and ParseFile* helpers delegate to it with default ParseOptions plus their own path/lenient settings.
func ParseWithPath ¶ added in v4.1.0
ParseWithPath parses OpenAPI spec bytes and resolves local external refs relative to the given file path.
func ParseWithPathLenient ¶ added in v4.1.0
ParseWithPathLenient parses OpenAPI spec bytes, resolving local external refs relative to the given file path and skipping validation errors from broken refs.
func SetMaxEndpointsPerResource ¶
func SetMaxEndpointsPerResource(n int)
SetMaxEndpointsPerResource overrides the default limit and disables auto-calibration. When not called, the parser auto-calibrates the limit from the spec so well-formed specs never have endpoints silently skipped.
func SetMaxResources ¶
func SetMaxResources(n int)
SetMaxResources overrides the default resource limit. When not called, the parser uses a default of 500 which accommodates all known APIs.
Types ¶
type ParseOptions ¶ added in v4.9.0
type ParseOptions struct {
// Path resolves local external refs relative to a file location. Empty
// means the spec is treated as remote/in-memory only.
Path string
// Lenient skips validation errors from broken $refs.
Lenient bool
// Set when callers need other lenient cleanup while preserving missing-ref
// failures.
StrictRefs bool
// AuthPreference names a security scheme from components.securitySchemes
// that should win over the parser's default selection priority. Used when
// a spec exposes multiple valid schemes (e.g. OAuth2 + basic) and the
// caller knows which one fits the printed CLI's intended auth model.
// Unknown names are ignored (default selection runs).
AuthPreference string
// SourceURL is the http(s) URL the spec was fetched from, when the spec
// is remote. Used to derive an absolute BaseURL for specs whose servers:
// block is relative-only (e.g. {url: /api/v3}). It does NOT affect $ref
// resolution (that uses Path/location).
SourceURL string
}
ParseOptions carries optional hints that influence parsing without changing the existing single-purpose Parse* signatures. New behavioral knobs (e.g. auth-scheme preference) should be added here rather than as new positional parameters across every entry point.