Skip to content

Commit

Permalink
Update zio-schema to 1.2.0 (#2867)
Browse files Browse the repository at this point in the history
  • Loading branch information
987Nabil authored May 28, 2024
1 parent 91e054b commit f9ed0f0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Dependencies {
val ZioVersion = "2.1.1"
val ZioCliVersion = "0.5.0"
val ZioJsonVersion = "0.6.2"
val ZioSchemaVersion = "1.1.1"
val ZioSchemaVersion = "1.2.0"
val SttpVersion = "3.3.18"
val ZioConfigVersion = "4.0.2"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package zio.http.endpoint.cli

import scala.annotation.tailrec
import scala.language.implicitConversions
import scala.util.Try

Expand Down Expand Up @@ -185,6 +184,7 @@ private[cli] object HttpOptions {
case StandardType.LocalDateTimeType => Options.localDateTime(prefix.mkString("."))
case StandardType.MonthType => Options.text(prefix.mkString("."))
case StandardType.YearType => Options.integer(prefix.mkString("."))
case StandardType.CurrencyType => Options.text(prefix.mkString("."))
}

loop(List(name), schema)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package zio.http.endpoint.cli

import scala.annotation.tailrec

import zio.cli._
import zio.test._

Expand Down Expand Up @@ -155,6 +153,7 @@ object CommandGen {
case StandardType.LocalDateTimeType => "date-time"
case StandardType.MonthType => "text"
case StandardType.YearType => "integer"
case StandardType.CurrencyType => "currency"
}
case _ => "non primitive"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package zio.http.codec.internal

import java.time._
import java.util.UUID
import java.util.{Currency, UUID}

import zio._

Expand Down Expand Up @@ -252,6 +252,13 @@ object TextBinaryCodec {
} catch {
case e: Exception => Left(DecodeError.ReadError(Cause.fail(e), e.getMessage))
}
case StandardType.CurrencyType =>
(s: String) =>
try {
Right(Currency.getInstance(s))
} catch {
case e: Exception => Left(DecodeError.ReadError(Cause.fail(e), e.getMessage))
}
}
case schema =>
val result = Left(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ object JsonSchema {
case StandardType.OffsetTimeType => JsonSchema.String()
case StandardType.OffsetDateTimeType => JsonSchema.String()
case StandardType.ZonedDateTimeType => JsonSchema.String()
case StandardType.CurrencyType => JsonSchema.String()
}

case Schema.Optional(schema, _) => fromZSchema(schema, refType).nullable(true)
Expand Down

0 comments on commit f9ed0f0

Please sign in to comment.