RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.67k stars 1.23k forks source link

Add support for sending and recieving large json arrays. #4729

Open nonwombatant opened 7 months ago

nonwombatant commented 7 months ago

Supports large json arrays that may not fit in memory and cause out of memory exceptions.

Uses IAsyncEnumerable and a custom Http Content to send large json arrays. Uses IAsyncEnumerator to recieve large json arrays.

By returning an IAsyncEnumerator it correctly handles memory safety and IDisposables.

Possible fix for https://github.com/RicoSuter/NSwag/issues/4236 and https://github.com/RicoSuter/NSwag/issues/3909

Note: I'm like 95% confident about the implementation for reading large json arrays. I'm much less confident about the custom httpContent for sending large arrays being the best approach.

Chaosflo commented 2 months ago

@RicoSuter When will this be merged to support streaming? I am desperately in need of this =/

nonwombatant commented 2 months ago

@RicoSuter When will this be merged to support streaming? I am desperately in need of this =/

This seems unlikely to be merged, kind of a niche use case I think? There's some workarounds that are posted on the issue pages.

Happy to follow up on this though.