softwaremill / softwaremill/tapir

Respond in valid JSON Array when using streams

Open
#4,116 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.5k
Forks
468
Avg merge
5h 37m
Merged PRs (30d)
34

Description

Hello!

In http4s there is streamJsonArrayEncoderOf which allows you to use fs2.Stream but encode it as a valid JSON Array.

When in one of our services we switched to Tapir for endpoints definitions, we noticed that this functionality is missing, or at the very least we are not sure how to achieve it.

For us, this is very useful, as for short streams, it allows for easier integration with different tools that might not understand NDJSON or other approaches.

As a workaround we roll out our own stream json array encoding, but It'd be nice to have this built-in in Tapir, maybe as an opt-in.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with http4s's streamJsonArrayEncoderOf in circe/CirceInstances.scala and review Tapir's existing stream encoding entry points. Compare the current behavior with the issue's service workaround and define tests showing that an opt-in stream response is emitted as a valid JSON array, including short streams.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.