Documentation
¶
Overview ¶
Package openapi turns an OpenAPI 3.0/3.1 or Swagger 2.0 document into a model.Manifest (SPEC §3.4, §3.5).
The spec is untrusted input (SPEC §5.3, T1/T2/T4). Defenses, each tested in this package and in testdata/hostile:
- only local "#/..." $refs resolve; libopenapi's file and remote lookups are switched off, and a pre-pass over the parsed node tree (refcheck.go) rejects ref chains deeper than MaxRefDepth and pure ref cycles without relying on those switches;
- YAML alias expansion is limited (libopenapi's limit, never relaxed);
- schema conversion is capped at MaxSchemaDepth levels and MaxSchemaNodes nodes per tool, degrading to {} with an Issue;
- all spec text that reaches the model is cleaned (naming.CleanText);
- libopenapi never logs to stdout, and its panics become errors.
Index ¶
Constants ¶
const ( MaxSchemaDepth = 12 MaxSchemaNodes = 5000 MaxRefDepth = 32 )
Limits on untrusted spec structure.
Variables ¶
var ( ErrUnsupportedSpec = errors.New("unsupported spec: need OpenAPI 3.0, 3.1 or Swagger 2.0") ErrRefTooDeep = errors.New("$ref chain too deep") ErrRefCycle = errors.New("$ref cycle") ErrParserPanic = errors.New("spec parser failed") ErrInvalidSpec = errors.New("invalid spec") )
Sentinel errors callers can match with errors.Is.