feat(compilers/openapi): populate the operation streaming fields - #352
Open
OmarAlJarrah wants to merge 1 commit into
Open
feat(compilers/openapi): populate the operation streaming fields#352OmarAlJarrah 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
Operation.Streaming,Operation.RequestStreamandOperation.ResponseStreamwere written by nocompiler at any version. An SSE or NDJSON API declares what it does by naming a media type, and the
media type was copied to
Content.MediaTypeand never read; a 3.2itemSchemasetContent.Itemand stopped there. Compiling either shape produced
streaming: nullwith no diagnostic, so nothingdownstream could tell a stream from an ordinary body.
This adds the reading, in two halves that are deliberately not the same kind of fact:
itemSchemadeclares the stream. The keyword states that the body is a sequence ofitems, so the operation streams and the declared item schema is the element type. Nothing is
guessed, so no heuristic marker is stamped.
text/event-stream,application/x-ndjsonandapplication/jsonlare read as frame formats through a new
Options.StreamingMediapolicy — default on, replaceable,and switchable off — with
Provenance.Inferrednaming the heuristic. That is architectureprinciple 6: the list is a default, not a standard, and a caller who wants only what a document
declares turns it off. Matching ignores case and media-type parameters.
For a frame format the schema under the media type describes one frame rather than the whole body,
which is the opposite of how an ordinary content is read;
StreamDetail.Eventsis what says so.Where a direction offers several streaming contents the direction still streams but the element type
is left unnamed, with an info diagnostic:
StreamDetailholds oneEventsper direction while thepayload keeps every media type, so electing one of them would be the primary-content selection a
compiler must not make.
Two notes on the issue as filed. Its acceptance item about an
itemSchema"not double-applying"assumed an existing 3.2 writer — there was none, so the gap was wider than reported rather than
narrower, and the two paths here cannot both fire because a declaration at a content wins over the
reading of its media type. And
Provenance.Inferredholds a single string that path-prefix groupingalready used, so an operation reached by both heuristics now lists both rather than losing one.
Merge ordering: #345 also rewrites
testdata/conformance/openapi/unwitnessed.golden.txt, and #341adds
DecodeOptionsto the compiler contract. Whichever of the three lands first, the others rebase;once #341 is in,
StreamingMediashould gain textual option names there so the CLI's-optpath canreach it.
Test plan
streaming-media-30andstreaming-media-31cover a 3.0 media-type-only stream, abidirectional operation, a
charsetparameter on the media type, and the several-contents refusal.unwitnessed.golden.txtloses five entries —Operation.Streaming,Operation.RequestStream,Operation.ResponseStream,StreamDetail.EventsandProvenance.Inferred, the last of which nocorpus spec witnessed at all before.
sequential-medianow records the stream itsitemSchemadeclares; its assertion pins that it isdeclared rather than inferred.
fields to agree, which is what an implementation electing the first candidate would fail.
them, and the exported default list being the one the lowering applies.
Closes #250