Skip to content

Commit

Permalink
further simplications...
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicoulaud-ledger committed Nov 4, 2023
1 parent 9a6000b commit dbe2a54
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 0 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ inThisBuild(
lazy val api = project.in(file("modules/api"))
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "2.10.0",
"com.softwaremill.sttp.tapir" %% "tapir-core" % "1.8.5",
"com.softwaremill.sttp.tapir" %% "tapir-iron" % "1.8.5",
"io.github.iltotore" %% "iron" % "2.3.0",
"io.github.iltotore" %% "iron-cats" % "2.3.0",
)
)
7 changes: 2 additions & 5 deletions modules/api/src/main/scala/types.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import cats.Show
import cats.syntax.all.*
import io.github.iltotore.iron.*
import io.github.iltotore.iron.constraint.all.*
import sttp.tapir
import sttp.tapir.Codec.PlainCodec
import sttp.tapir.DecodeResult
import sttp.tapir.codec.iron.TapirCodecIron
import sttp.tapir.{CodecFormat, DecodeResult, Codec as TapirCodec, Schema as TapirSchema}

private type VersionConstraints = DescribedAs[GreaterEqual[0], "Version must be positive"]
opaque type Version = Int :| VersionConstraints

object Version extends RefinedTypeOps[Int, VersionConstraints, Version] with TapirCodecIron:
given PlainCodec[Version] = summon[PlainCodec[Int]].mapDecode(s => DecodeResult.fromEitherString(s.show, either(s)))(_.value)
given PlainCodec[Version] = summon[PlainCodec[Int]].mapDecode(s => DecodeResult.fromEitherString(s.toString, either(s)))(_.value)

0 comments on commit dbe2a54

Please sign in to comment.