You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
openapi: a $ref to a property's schema reports readOnly as kept on a node that lacks it #750
A schema $ref aimed at a property's, parameter's or header's schema lowers that position as a declaration with no carrier. When the position owns a node (an object, an array, an enum) and writes default, readOnly or writeOnly, the reference stores those keywords under the node's Unmodeled. It reports openapi/degraded-construct for each one: "it is kept verbatim under Unmodeled and applied to a referencing property, header or parameter". The declaration that owns the position lowers it as a carrier. That keeps the keywords on the ir.Property or ir.Parameter and stores nothing on the node.
So which lowering runs first decides the result:
On fix(compilers/openapi): let a declaration name what a $ref built #561, the declaration rebuilds a node that a reference built first, so the node holds no such entry in either order. But when the reference lowers first, the diagnostic it reported is still emitted. It describes an Unmodeled entry that is not in the document.
On main at 98ba293, the entries stay on the node and the diagnostic is reported when the reference lowers first. When the declaration lowers first, the reference resolves to the node it already built and adds neither. The registry differs between the two orders.
b_first.yaml is the same document with /b declared before /a.
forfin a_first b_first;do
go run ./cmd/morphic compile $f.yaml >$f.json
jq -c '.types["t/anon/paths/~1b/get/responses/200/content/application~1json/schema/properties/p"].unmodeled | keys? // null'$f.json
done
On #561, a_first prints the openapi/degraded-construct info diagnostic for /properties/p/readOnly and null. b_first prints no diagnostic and null. On main, a_first prints the diagnostic and ["openapi:readOnly"]. go run ./cmd/morphic-harness reports both files order-dependent: on #561 for their diagnostics, on main for their registry.
Notes
The same holds for a parameter's schema (/paths/~1b/get/parameters/0/schema) and a response header's (.../headers/X-H/schema), and for default and writeOnly. These are the three positions lowered through schema.CarriedRef.
format: password now reaches this path as well, because a password position owns a node after #592. The usual spelling is {type: string, format: password, writeOnly: true}. Replaying the repro above with that property gives order-dependent diagnostics in morphic-harness on that branch, where main reports ok. format: hex-token already does so on main.
#592 (format: password) adds a case. A password property that writes writeOnly, readOnly or default now owns a node, so a $ref to its schema by pointer reports the openapi/degraded-construct info only when the reference lowers first.
Repro: the a_first.yaml document above with p replaced by {type: string, format: password, writeOnly: true}. go run ./cmd/morphic-harness reports it order-dependent on diagnostics on that branch and ok on main. format: hex-token already behaves this way on main, so the fix here covers both.
Problem
A schema
$refaimed at a property's, parameter's or header's schema lowers that position as a declaration with no carrier. When the position owns a node (an object, an array, an enum) and writesdefault,readOnlyorwriteOnly, the reference stores those keywords under the node'sUnmodeled. It reportsopenapi/degraded-constructfor each one: "it is kept verbatim under Unmodeled and applied to a referencing property, header or parameter". The declaration that owns the position lowers it as a carrier. That keeps the keywords on their.Propertyorir.Parameterand stores nothing on the node.So which lowering runs first decides the result:
Unmodeledentry that is not in the document.mainat 98ba293, the entries stay on the node and the diagnostic is reported when the reference lowers first. When the declaration lowers first, the reference resolves to the node it already built and adds neither. The registry differs between the two orders.Reproduction
a_first.yaml:b_first.yamlis the same document with/bdeclared before/a.On #561,
a_firstprints theopenapi/degraded-constructinfo diagnostic for/properties/p/readOnlyandnull.b_firstprints no diagnostic andnull. Onmain,a_firstprints the diagnostic and["openapi:readOnly"].go run ./cmd/morphic-harnessreports both filesorder-dependent: on #561 for their diagnostics, onmainfor their registry.Notes
/paths/~1b/get/parameters/0/schema) and a response header's (.../headers/X-H/schema), and fordefaultandwriteOnly. These are the three positions lowered throughschema.CarriedRef.$defs, where the reference's record is the only one.