Map 22+ query params to case class

Hi, I have endpoint with 23+ query params, and of sake of convenience I`ve mapped them to case class.


and it works just fine untill 23rd parameter in list. The error is following:

The arity of the source type doesn't match the arity of the target type

So my question is how to handle such cases(23+ query params mapped to case class)?

This is a limitation in scala (2, in scala 3 it could’ve worked, but tapir is cross built to scala 2 as well)

  1. As a general rule of thumb, you probably want to avoid classes and function with high arity
  2. You can group subsets of parameters, and compose, e.g. something like: p1.and(p2).mapTo[CaseCls1].and(p3.and(p4).mapTo[CaseCls2]).mapTo[CaseCls3]

Yes, we have tuple operations defined only up to 22:

As @hochgi mentioned, we could fix this using Scala 3, but so far this code is kept the same for Scala 2/ Scala 3. Not that we wouldn’t welcome a PR changing this, but so far nobody complained :slight_smile: