feat(compilers/openapi): fill typed fields from vendor extensions - #355
Open
OmarAlJarrah wants to merge 1 commit into
Open
feat(compilers/openapi): fill typed fields from vendor extensions#355OmarAlJarrah wants to merge 1 commit into
OmarAlJarrah wants to merge 1 commit into
Conversation
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
Several typed IR fields model information OpenAPI gives no keyword for, so the only way a document
can state it is a vendor extension — and nothing connected the two.
x-deprecated-reasonlanded inUnmodeledandir.Deprecation.Messagestayed empty at every one of the seven places the compilerbuilds a
Deprecation, with no diagnostic either way. Any emitter wanting the value had to reachinto
Unmodeledwith an ad-hocx-*lookup, which is exactly what an emitter must not do.The deliverable is the mechanism, not the two keys that demonstrate it.
The rule, recorded first.
docs/ir-design.md§12 now states what promoting a vendor extensioninto a typed field means: the mapping is injectable policy, default on and disableable; the
extension stays in
Unmodeledwith itsvendor_extensionreason, so a promotion is a secondreading and never a move; the node records the heuristic in its own
Provenance.Inferred; and anode with no
Provenanceis not promoted into, because a guess nobody can audit is worse than anempty field. Reading an extension is a heuristic — the format assigns
x-*no semantics at all —so invariant 6 governs all of it.
The seam.
Options.Promotionsmaps an extension key to a member of a closedExtensionTargetvocabulary. Adding a target later is a constant and an applier, not a change to the policy shape or
to any call site. The default mapping is deliberately small and obviously a default:
x-deprecated-reason,x-deprecated-sinceandx-sunsetare conventions no specification defines,and a caller may replace the mapping outright rather than extend it.
What it fills today: the three
ir.Deprecationmembers, at every carrier that can record thepromotion — operation, response header, type, property and security scheme.
Parameteris the onecarrier left out and the reason is in the code beside it:
ir.Parameterhas noProvenance, sorule 3 cannot be satisfied there, and giving it one is a change to
ir-design.mdrather than tothis compiler. The other extension-sourced fields —
Pagination.*,LongRunning,Idempotency,ErrorCase.Retryable/Throttling,Enum.Flags,EnumMember.Name,Sensitive,Secret— arefollow-up targets for this vocabulary;
ErrorCase.Retryable/Throttlingadditionally needs #275,since response extensions are not read at all until it lands.
Merge ordering: #341 adds
DecodeOptionsto the compiler contract, and #345 and #352 also rewriteunwitnessed.golden.txt. Whichever lands first, the others rebase; once #341 is in,Promotionsshould gain textual option names there so the CLI's
-optpath can reach it.Test plan
extension-promotionnames all five carriers individually, so a construction sitethat stops promoting fails on its own row rather than being covered by a neighbour. It also pins
the two refusals: an extension beside no
deprecated: trueannotates nothing, and a value that isnot text fills no field and is reported.
unwitnessed.golden.txtloses four entries —Deprecation.Message,Deprecation.Since,Deprecation.RemovalVersion, andProvenance.Inferred, which no corpus spec witnessed at allbefore this.
heuristic was already recorded and is not repeated when a node is annotated twice, and that both
the exported default mapping and a caller's own map are copied rather than shared.
extending them.
Closes #252