Repository navigation
fix(ir)!: tell no default from an empty one and name a writer - #1370
Open
OmarAlJarrah wants to merge 5 commits into
Open
OmarAlJarrah wants to merge 5 commits into
OmarAlJarrah wants to merge 5 commits into
Conversation
Three fields could not say what a source left unstated, or who wrote a position. - ServerVariable.Default becomes *string. A variable's default: "" substitutes nothing, and lowered to the same IR as a variable with no default, which AsyncAPI allows. The parser holds both as an empty string, so the OpenAPI compiler reads the key off the node. - XMLHints.Wrapped becomes *bool, written only where declared, and an encoding's and XML hints' property-over-type override is stated field by field: a field the property sets replaces the type's, and one it leaves unset takes it. A whole-struct override would drop a scalar's decoded Schema whenever a property only renamed the encoding. - Provenance gains WrittenBy. A construct an overlay wrote into the spec named the overlay as its Source at a position of the patched spec, so a reader could not tell which file the pointer was in. Source is now always the document the pointer addresses and WrittenBy the overlay; a finding about the overlay file itself keeps the overlay as Source. The renderer spells root.yaml#/components/schemas/B (written by patch.yaml), report.Explain reads the source's own positions and so no longer takes the source table, and irverify holds a writer to an overlay entry (ir/provenance-writer). BREAKING CHANGE: IRVersion moves to 0.32.0. A consumer pinned to 0.31.0 refuses the document; one that read an overlay's Source as its file reads its pointer at the wrong place. In Go, ServerVariable.Default and XMLHints.Wrapped are pointers and report.Explain drops its sources argument.
…into fix/ir-defaults-writers-overrides
The explain test wrapped diag in a lambda of the same signature, and the writer check's fixture named the model's embedded TypeCommon; both now take the direct spelling the linters ask for.
17 tasks done
…into fix/ir-defaults-writers-overrides # Conflicts: # ir/document.go
…into fix/ir-defaults-writers-overrides
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fields could not say what a source left unstated, or who wrote a position.
ServerVariable.Defaultbecomes*string. OpenAPI requires a default, anddefault: ""substitutes nothing, an optional path prefix for instance. AsyncAPI allows a variable with no default. Both lowered to an empty string. The parser's own field holds both as"", so the OpenAPI compiler reads the key off the variable's node. That needsnodeviewin theserverspackage's allowlist, with the reason beside the entry: a forwarding wrapper elsewhere would be a seam with one user.ProvenancegainsWrittenBy. A construct an overlay wrote into the spec named the overlay as itsSource, at a position of the patched spec. A refusal of the overlay's own actions named it at a position of the overlay. Nothing told the two apart, andmorphic validatespelledpatch.yaml#/components/schemas/B, a positionpatch.yamldoes not hold. NowSourceis always the document the pointer addresses, andWrittenBythe overlay that wrote what is there. The same run printsroot.yaml#/components/schemas/B (written by patch.yaml), the rendering the issue proposed.report.Explainreads the source's own positions whoever wrote them, so itssourcesargument is gone, andirverifyholds a writer to an overlay entry other than the provenance'sSource(ir/provenance-writer). The issue's alternative, a flag saying the pointer addresses the patched document, keeps two meanings onSourcethat every reader must branch on;docs/ir/provenance.mdrecords why it lost.docs/ir/constraints.mdnow states that a property'sEncodingandXMLHintsoverride the type's field by field: a field the property sets replaces the type's, and one it leaves unset takes it. JSON Schema applies keywords at both places, and a whole-struct override would drop a scalar's decodedSchemawhenever a property only renamed the encoding.XMLHints.Wrapped, the one field with no unset state, becomes*bool, written only where declared, so a property'sfalsecan override a type'strue.None of this touches the golden spec, which has no overlay, no empty variable default and no
xmlobject beside a property's (spec @319dc756). That is the P3 ranking all three carry.Closes #883
Closes #1035
Closes #465
Breaking
IRVersionmoves to 0.34.0, after #1367's 0.33.0. A consumer pinned to the generation before this one refuses the document. One that read an overlay'sSourceas its file reads such a pointer at the wrong place, and one that read the absentdefaultkey as "no default" now reads""where the document wrote it. In Go,ServerVariable.DefaultandXMLHints.Wrappedare pointers,report.Explaintakes no source table, andoverlay.Applytakes the patched document's index.Stack
Base: #1367, on the rest of the IR stack. Merge in order.
Test plan
go testonir/...,compilers/...,engine/...,cmd/...,pass/...andinternal/.... The goldens, the shape pin and the census were regenerated. The goldens move only where an undeclaredwrapped: falseis no longer written, and wheredefault: ""now is.servers.TestServerVariables_AnEmptyDefaultIsNotNone.irverify.TestVerify_AWriterIsAnOverlayWritingIntoTheSource(six rows).report.TestWriteDiagnostics_NamesTheWriterBesideTheSource.TestExplain_ReadsOnlyTheSourcesCoordinates, rewritten for writers.wrapped: falsekept inannotation.TestXMLHints_ReadsEveryFieldDirectly.Atcrediting the overlay asSource;ProvenanceAtdropping the writer; the renderer dropping it; the verifier accepting a writer that is no overlay.root.yamlandpatch.yamlthroughmorphic validateandmorphic compile, which print and hold what is quoted above.skills_lintclean.