softwaremill / softwaremill/tapir
Hardcoded IO in generated code
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.5k
- Forks
- 468
- Avg merge
- 5h 37m
- Merged PRs (30d)
- 34
Description
Tapir version: 1.13.19
If you have a lazy type (eg, a default binary octet stream) specified as the body, the code generator sets up an fs2 Stream, as it should. Unfortunately, it hardcodes the effect of that Stream as IO.
That's often correct, but if you're in an environment that is trying to be effect-neutral (as our services are), it's basically unusable. We're admittedly a little unusual in following tagless final in services, but this problem would be a blocker for any library that follows Typelevel best practices. (And heaven knows I've written my share of libraries that were built around an external OpenAPI spec.)
For now, I've hacked our first OpenAPI spec to require the incoming file to be defined as an eager String, but that's pretty awful -- counter to both Tapir's and our own architectural best practices.
I think what I'm hoping for here is a feature flag that causes the generated code to be abstract in F[_], so that it plays nicely in a tagless-final environment. Does that seem appropriate? I'm happy to work on this, if so.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named. Start at the OpenAPI code-generation path for lazy request bodies and trace where the fs2 Stream effect is fixed to IO; done means generated code can preserve an abstract F[_] under the proposed feature option, with coverage for that case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, scala
- Domain
- backend-api-design, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100