Repository navigation
🔎 Spec Conformance, Round Two: References, HTTP Case Rules and Runtime Expressions
validate now reads a local $ref as the JSON Pointer it is, checks the runtime expressions in Links and Callbacks, compares header and media type names the way HTTP does, and refuses an empty Responses Object. diff reports its changes in a stable order and treats a new required parameter or request body as breaking. convert stops warning about a field OAS 3 still defines, and moves a path item's body and formData parameters into each operation's request body.
Most of this makes a document that passed fail, or the other way round, so read the two lists below before you upgrade.
⚠️ Documents that passed can now fail
- A
$refthat names a location that does not exist (#654). A dangling reference written with percent-encoded separators (#%2Fcomponents%2Fschemas%2FNope) used to be read as an external file and pass. It is an error now, like every other dangling reference. - An empty Responses Object (#658).
responses: {}(or one holding onlyx-extensions) is an error in every version, because each says it MUST contain at least one response code.fixlists it among the errors it cannot fix andconvertrefuses the document. - Runtime expressions in Link values and Callback keys (#659). A string that begins
$request.or$response., or embeds{$, must follow the grammar, and a$request.path,.queryor.headername must be declared by the operation that holds the callback or the link's response (Accept,Content-TypeandAuthorizationare exempt). Constants such as$5.00still pass. - Keys of
additionalOperationsthat name a fixed-field method (#645).GET,getandGetare errors, compared ignoring case, and such an entry no longer takes the standard operation's place inGetOperations. - HTTP's case rules in every version (#646). Two header parameters whose names differ only in case (
X-Traceandx-trace) are duplicates, a repeated parameter makesgeneraterefuse the document (it used to emit code that did not compile), and a response range is only1XXto5XXin capitals. Two response header keys that differ only in case, a header parameter namedAccept,Content-TypeorAuthorization, and aContent-Typeresponse header are warnings, because the specification says they are ignored. diff --breakingis stricter (#646 and the release PR). A response header's schema is compared now. A new required parameter or request body is an error (it was a warning), so a pipeline that gated on exit code can start failing. Making a required parameter optional is info.
✅ Documents that failed now pass
- Any valid JSON Pointer
$ref(#654). Percent-encoded names (#/components/schemas/P%65t), pointers below a component and pointers intopathsresolve. OAS 2.0 definitions with bracket names referenced by an encoded$refvalidate. - A path or webhook name that holds a dot (#649).
/v1.0/usersandorder.createdare read as the keys they are, where the operation used to be lost or attributed to/v1. allowEmptyValueon a query parameter converts without a warning that it was "removed in OAS 3.0". It was not: 3.0 and 3.1 define it for query parameters, and the converter already kept it.
📋 Results you can rely on
- Duplicate
operationIdmessages and parser errors are the same on every run (#648, fixes #639). The first operation is the first in the orderpaths,webhooks,components.pathItems, sorted within each. diffreports its changes in a stable order, by path, then type, category and message. One pair of documents used to print 17 different outputs in 40 runs.validate --source-mapfinds keys that start with a digit or hold a dot (every response code,/v1.0/x), and shows the right operation for them (#649).validatereports an empty Responses Object once, at the object with its specification link.- The differ compares what each operation effectively takes: the path item's parameters with the operation's own overriding the one of the same name and location, each
$refread through the document's reusable parameters, and a required request body behind a$refis read too. A change to a path item's parameters is reported once per operation under it. convertmoves a path item'sbodyandformDataparameters into each operation's request body (the operation's own parameter of the same name wins). They used to be written out asin: formDataparameters in a 3.x document. AformDataparameter'sallowEmptyValuehas no equivalent in a request body, so the conversion now says it was dropped, and its reports name the operation and the parameter's place in the source.
🧰 New API
// Look up the position of a dot-joined path, as validate, fix, convert, diff,
// join and generate report them. Each segment is read against the keys the
// document holds, so "/v1.0/pets" is one key.
loc := result.SourceMap.GetPath("paths./v1.0/pets.get.responses.200")
if loc.IsKnown() {
fmt.Println(loc.Line, loc.Column)
}
// A Responses Object that is present and holds no response. A nil one is absent.
if op.Responses.IsEmpty() {
// the document wrote responses: {}
}
// A structure error that names the object it concerns.
var se *parser.StructureError
if errors.As(err, &se) && se.Kind == parser.StructureEmptyResponses {
fmt.Println(se.Path)
}parser.SourceMap.GetPath, parser.Responses.IsEmpty, parser.StructureError and parser.StructureEmptyResponses are new. Nothing is removed or changed in an existing signature.
📊 What it costs
Allocations per operation, from the committed benchmark files: ValidateParsed goes from 77 to 84 on the smallest document, 671 to 733 on the medium one and 7084 to 7816 on the large one (about +9 to +10%), and Diff from 395 to 418 (+6%). Parse, fix, convert, join and generate are each within 1% of v1.69.0. The validator now checks references as JSON Pointers, parses runtime expressions and applies the HTTP case rules, and the differ builds each operation's effective parameter list.
🔒 User impact
- No removed or changed API, and no change to the CLI's flags. The command line examples in the help text and the docs now put the flags before the file path, which is the order that works.
- The ten corpus specifications produce the same
validatemessages as before this release. - ✅ 12,547 tests pass,
govulncheckis clean, and every new rule was checked by breaking it and watching a test fail.
What's Changed
- fix(validator): reject additionalOperations keys that name a fixed-field method by @erraggy in #645
- fix: compare names and values that map to HTTP as HTTP does by @erraggy in #646
- fix(parser,validator): duplicate operationIds name the lowest operation on every run by @erraggy in #648
- fix(parser,validator): read dot-joined paths against the keys the document holds by @erraggy in #649
- fix(validator,parser): read a local $ref as the JSON Pointer it denotes by @erraggy in #654
- docs(claude): a local $ref is a JSON Pointer with one reader by @erraggy in #657
- fix(validator): an empty Responses Object is an error in every version by @erraggy in #658
- feat(validator): check runtime expressions in Link values and Callback keys by @erraggy in #659
- chore: prepare v1.70.0 release by @erraggy in #662
Issues Fixed
- #636 - Fixed by PR #645
- #637 - Fixed by PR #646
- #639 - Fixed by PR #648
- #640 and #641 - Fixed by PR #649
- #642 - Fixed by PR #654
- #643 - Fixed by PR #658
- #647 - Fixed by PR #659
Full Changelog: v1.69.0...v1.70.0