Add StreamOne/StreamMany/StreamAggregate helpers for Wolverine.Http.Marten#2528
Merged
jeremydmiller merged 2 commits intomainfrom Apr 20, 2026
Merged
Add StreamOne/StreamMany/StreamAggregate helpers for Wolverine.Http.Marten#2528jeremydmiller merged 2 commits intomainfrom
jeremydmiller merged 2 commits intomainfrom
Conversation
…arten (#1562) Three new return-types that stream Marten JSON directly to the HTTP response, avoiding a deserialize/serialize round trip through .NET. Patterned after Marten.AspNetCore's WriteSingle/WriteArray/WriteLatest helpers, with correct OpenAPI metadata contributed via IEndpointMetadataProvider. - StreamOne<T>(IQueryable<T>): single document via WriteSingle, 404 on miss - StreamMany<T>(IQueryable<T>): JSON array via WriteArray, empty array on no match - StreamAggregate<T>(IDocumentSession, id): latest event-sourced aggregate via WriteLatest, 404 on unknown stream. Supports both Guid and string ids. All three implement IResult (picked up by Wolverine.Http's existing ResultWriterPolicy, no codegen plumbing needed) and IEndpointMetadataProvider so Swashbuckle / NSwag / Minimal-API OpenAPI all see the right response shape. OnFoundStatus and ContentType are init-only properties so endpoints can customize 200 → 201 (for create) or advertise a vendor-specific content type. Follow-up: replicate this pattern in Wolverine.Http.Polecat (separate PR). Closes #1562 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The streaming result types originally landed locally in Wolverine.Http.Marten in this branch. They've since shipped upstream in Marten.AspNetCore 8.31.0 (via JasperFx/marten#4260 — the same types, lifted to live next to the existing WriteSingle/WriteArray/WriteLatest helpers and usable from any Minimal-API endpoint, not just Wolverine.Http). This commit: - Bumps Marten + Marten.AspNetCore 8.28.0 → 8.31.0 and JasperFx.Events 1.27.0 → 1.28.1 in Directory.Packages.props - Deletes the local StreamOne/StreamMany/StreamAggregate types from Wolverine.Http.Marten - Switches the WolverineWebApi sample endpoints and the test file to use Marten.AspNetCore.StreamOne/StreamMany/StreamAggregate - Updates docs/guide/http/marten.md to point at Marten.AspNetCore as the source of the types and call out that no Wolverine-specific code is required — the types implement IResult and Wolverine.Http dispatches them through its existing ResultWriterPolicy The existing tests carry over unchanged — they pass against the upstream types because the public surface is identical (same constructors, same init-only OnFoundStatus/ContentType, same OpenAPI metadata via IEndpointMetadataProvider). Verified with `dotnet test`: all 12 streaming_endpoints tests + 20 related Marten tests (compiled_query_writer, using_aggregate_handler_workflow) pass against the new packages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Apr 21, 2026
Closed
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
Closes #1562. Three new return-types that stream Marten JSON directly to the HTTP response, avoiding a deserialize/serialize round trip through .NET. Built on top of Marten.AspNetCore's existing JSON streaming helpers (
WriteSingle/WriteArray/WriteLatest), with correct OpenAPI metadata contributed viaIEndpointMetadataProvider.API
Design notes
IResult; Wolverine.Http's existingResultWriterPolicydispatches them naturally.IEndpointMetadataProvider— Swashbuckle, NSwag, and the Minimal-API built-in OpenAPI generator all pick up correct200: T/200: T[]+404responses without any extra registration.Wolverine.Http.Marten(matches existingCompiledQueryWriterPolicy) for discoverability.StreamOnevsStreamAggregateexplicitly distinguished in docs:StreamOneis for regular Marten documents (session.Query<T>()),StreamAggregateis for event-sourced aggregates (events.WriteLatest<T>, internally).Scope boundaries
In scope:
StreamOne<T>(IQueryable<T>),StreamMany<T>(IQueryable<T>),StreamAggregate<T>(IDocumentSession, Guid|string), OpenAPI metadata, custom status/content-type, tests, docs.Deferred to follow-up: a parallel port for Polecat (
Wolverine.Http.Polecat), to be opened as a separate PR once this lands.Files
StreamOne.cs,StreamMany.cs,StreamAggregate.csinWolverine.Http.MartenStreamingEndpoints.csinWolverineWebApi/Marten(the Alba test host project)streaming_endpoints.csinWolverine.Http.Tests/Marten(12 tests)docs/guide/http/marten.md(new "Streaming JSON Responses" section with the StreamOne-vs-StreamAggregate distinction called out explicitly)Test plan
OnFoundStatus(tested at 202)ContentType(tested with vendor-specific type)[]with 200 (not 404) on no matchStreamOne<T>advertisesProduces<T>+ 404StreamMany<T>advertisesProduces<IReadOnlyList<T>>StreamAggregate<T>advertisesProduces<T>+ 404🤖 Generated with Claude Code