Create Codec for NonEmptyList[String]


This is surely a noob question, but i’ve been struggling to make a codec for query parameters whose high-level value is NonEmptyList[String].

I have an OK handle on making Codec’s for custom types (though mostly i just use circe’s codecs), but making a codec of type Codec[List[String], NonEmptyList[String], TextPlain] has me confused since it’s a list and not a normal custom type so i cant just use Codec.mapDecode()

Feel free to just point me somewhere this has already been explained if it has.


I think it should be sufficient to import import sttp.tapir.integ.cats.codec._ using tapir-cats: Datatypes integrations — tapir 1.x documentation

The following seems to work (well, compile :slight_smile: ):

import sttp.tapir._
import sttp.tapir.integ.cats.codec._

object X extends App {