# Converting a tapir+akka project to tapir+zio

**URL:** <https://softwaremill.community/t/converting-a-tapir-akka-project-to-tapir-zio/254>\
**Category:** tapir\
**Created:** [July 23, 2023, 4:16pm UTC](https://softwaremill.community/t/converting-a-tapir-akka-project-to-tapir-zio/254 "2023-07-23T16:16:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hochgi](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/hochgi/32/32_2.png) [@hochgi](https://softwaremill.community/u/hochgi)\
**Post date:** [July 23, 2023, 4:16pm UTC](https://softwaremill.community/t/converting-a-tapir-akka-project-to-tapir-zio/254/1 "2023-07-23T16:16:18Z")

</div>

TL;DR:  
I have a “go to” default structure for services.  
Up until today I used tapir with akka-http.  
I want to try out ZIO, and need guidance.

I submitted a template repo with short README that explains the structure, and motivation:

> **[GitHub - hochgi/tapir-zervice: template project + experiments](https://github.com/hochgi/tapir-zervice)**
>
> template project + experiments. Contribute to hochgi/tapir-zervice development by creating an account on GitHub.

There are 2 server modules there.

- `server` which uses my regular akka-http code, and it works. You can just `server/run` in sbt, and try it out.
- `zerver` which uses zio-http instead, and so far I wasn’t able to understand how everything should be stitched together.

Currently I get weird compile errors like:

```auto
[error] /home/hochgi/dev/tapir-service/zerver/src/main/scala/com/hochgi/example/zerver/Main.scala:28:63: type mismatch;
[error] found : List[sttp.tapir.ztapir.ZServerEndpoint[_, Any]]
[error] (which expands to) List[sttp.tapir.server.ServerEndpoint[Any,[β$0$]zio.ZIO[_$1,Throwable,β$0$]] forSome { type _$1 }]
[error] required: List[sttp.tapir.ztapir.ZServerEndpoint[Any,sttp.capabilities.zio.ZioStreams]]
[error] (which expands to) List[sttp.tapir.server.ServerEndpoint[sttp.capabilities.zio.ZioStreams,[β$0$]zio.ZIO[Any,Throwable,β$0$]]]
[error] val app = ZioHttpInterpreter(serverOptions).toHttp(Routes.all)
[error] ^
[error] /home/hochgi/dev/tapir-service/zerver/src/main/scala/com/hochgi/example/zerver/Routes.scala:19:73: type mismatch;
[error] found : sttp.tapir.server.ServerEndpoint[Any,_1[_]] where type _1[_] >: zio.ZIO[Any,Throwable,_] <: zio.ZIO[com.typesafe.config.Config,Throwable,_]
[error] required: sttp.tapir.ztapir.ZServerEndpoint[Any,Any]
[error] (which expands to) sttp.tapir.server.ServerEndpoint[Any,[β$0$]zio.ZIO[Any,Throwable,β$0$]]
[error] val apiEndpoints: List[ZServerEndpoint[Any, Any]] = endpoints.map(_._2)
[error] ^
[error] /home/hochgi/dev/tapir-service/zerver/src/main/scala/com/hochgi/example/zerver/matapi/Info.scala:23:63: zio.URIO[com.typesafe.config.Config, _] takes no type parameters, expected: 1
[error] allConfigEndpoint => allConfigEndpoint.serverLogicSuccess[URIO[Config, _]](_ => zioConfig)
[error] ^
[error] /home/hochgi/dev/tapir-service/zerver/src/main/scala/com/hochgi/example/zerver/matapi/Info.scala:26:50: zio.URIO[com.typesafe.config.Config, _] takes no type parameters, expected: 1
[error] configEndpoint => configEndpoint.serverLogic[URIO[Config, _]]{ path =>
[error] ^

```

which I struggle to decipher.

Not sure if it’s more of a ZIO question or a tapir question, but figured it wouldn’t hurt to ask.  
Any help, guidance, or links to relevant material I should read is greatly appreciated.  
Thanks!

---

<div class="post-metadata">

**Author:** ![hochgi](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/hochgi/32/32_2.png) [@hochgi](https://softwaremill.community/u/hochgi)\
**Post date:** [July 24, 2023, 1:19pm UTC](https://softwaremill.community/t/converting-a-tapir-akka-project-to-tapir-zio/254/2 "2023-07-24T13:19:45Z")

</div>

After some more reading, I managed to get it to work.  
The way ZIO wants me to handle dependency injection feels a bit alien to me.  
I’m not 100% sure I did it “as I should have”, with all the layers,  
so if there’s any pointers, I’d still love to hear 🙏

---

<div class="post-metadata">

**Author:** ![adamw](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/adamw/32/28_2.png) [@adamw](https://softwaremill.community/u/adamw)\
**Post date:** [July 24, 2023, 2:24pm UTC](https://softwaremill.community/t/converting-a-tapir-akka-project-to-tapir-zio/254/3 "2023-07-24T14:24:18Z")

</div>

I think you might have been missing the kindproject plugin, and using it in type parameters e.g. as follows: `URIO[Config, *]`?

As for structuring a ZIO application using tapir, maybe our template repository will provide some guidance: [GitHub - softwaremill/realworld-tapir-zio: RealWorld.io with tapir and ZIO](https://github.com/softwaremill/realworld-tapir-zio)

---

<div class="post-metadata">

**Author:** ![hochgi](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/hochgi/32/32_2.png) [@hochgi](https://softwaremill.community/u/hochgi)\
**Post date:** [July 24, 2023, 3:36pm UTC](https://softwaremill.community/t/converting-a-tapir-akka-project-to-tapir-zio/254/4 "2023-07-24T15:36:21Z")

</div>

Thanks @adamw  
Indeed, I haven’t used the kindproject plugin.  
Will also take a look at the example project. Thanks!
