diff --git a/project/Dependencies.scala b/project/Dependencies.scala index a2b0be16192..c463b5febf2 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -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" diff --git a/zio-http-cli/src/main/scala/zio/http/endpoint/cli/HttpOptions.scala b/zio-http-cli/src/main/scala/zio/http/endpoint/cli/HttpOptions.scala index 254afc8d740..15d94f26428 100644 --- a/zio-http-cli/src/main/scala/zio/http/endpoint/cli/HttpOptions.scala +++ b/zio-http-cli/src/main/scala/zio/http/endpoint/cli/HttpOptions.scala @@ -1,6 +1,5 @@ package zio.http.endpoint.cli -import scala.annotation.tailrec import scala.language.implicitConversions import scala.util.Try @@ -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) diff --git a/zio-http-cli/src/test/scala/zio/http/endpoint/cli/AuxGen.scala b/zio-http-cli/src/test/scala/zio/http/endpoint/cli/AuxGen.scala index 8fdb42d8630..d2bdfc96a16 100644 --- a/zio-http-cli/src/test/scala/zio/http/endpoint/cli/AuxGen.scala +++ b/zio-http-cli/src/test/scala/zio/http/endpoint/cli/AuxGen.scala @@ -124,6 +124,7 @@ object AuxGen { StandardType.YearMonthType, StandardType.ZonedDateTimeType, StandardType.ZoneIdType, + StandardType.CurrencyType, ), ) .map(Schema.Primitive(_)) diff --git a/zio-http-cli/src/test/scala/zio/http/endpoint/cli/CommandGen.scala b/zio-http-cli/src/test/scala/zio/http/endpoint/cli/CommandGen.scala index ec5b4f7bfb9..395fab43838 100644 --- a/zio-http-cli/src/test/scala/zio/http/endpoint/cli/CommandGen.scala +++ b/zio-http-cli/src/test/scala/zio/http/endpoint/cli/CommandGen.scala @@ -1,7 +1,5 @@ package zio.http.endpoint.cli -import scala.annotation.tailrec - import zio.cli._ import zio.test._ @@ -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" } diff --git a/zio-http/shared/src/main/scala/zio/http/codec/internal/TextBinaryCodec.scala b/zio-http/shared/src/main/scala/zio/http/codec/internal/TextBinaryCodec.scala index e829a9aec6f..70158a80d83 100644 --- a/zio-http/shared/src/main/scala/zio/http/codec/internal/TextBinaryCodec.scala +++ b/zio-http/shared/src/main/scala/zio/http/codec/internal/TextBinaryCodec.scala @@ -1,7 +1,7 @@ package zio.http.codec.internal import java.time._ -import java.util.UUID +import java.util.{Currency, UUID} import zio._ @@ -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( diff --git a/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala b/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala index e25d8b85a04..ca574fc8059 100644 --- a/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala +++ b/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala @@ -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)