diff --git a/zio-schema-json/shared/src/main/scala/zio/schema/codec/JsonCodec.scala b/zio-schema-json/shared/src/main/scala/zio/schema/codec/JsonCodec.scala index 2a3446168..595f1c408 100644 --- a/zio-schema-json/shared/src/main/scala/zio/schema/codec/JsonCodec.scala +++ b/zio-schema-json/shared/src/main/scala/zio/schema/codec/JsonCodec.scala @@ -68,7 +68,7 @@ object JsonCodec { implicit def schemaBasedBinaryCodec[A](implicit schema: Schema[A]): BinaryCodec[A] = schemaBasedBinaryCodec[A](JsonCodec.Config.default) - implicit def schemaBasedBinaryCodec[A](cfg: Config)(implicit schema: Schema[A]): BinaryCodec[A] = + def schemaBasedBinaryCodec[A](cfg: Config)(implicit schema: Schema[A]): BinaryCodec[A] = new BinaryCodec[A] { override def decode(whole: Chunk[Byte]): Either[DecodeError, A] = JsonDecoder.decode( diff --git a/zio-schema-json/shared/src/test/scala-2/zio/schema/codec/JsonCodecSpec.scala b/zio-schema-json/shared/src/test/scala-2/zio/schema/codec/JsonCodecSpec.scala index 868befead..81db36e62 100644 --- a/zio-schema-json/shared/src/test/scala-2/zio/schema/codec/JsonCodecSpec.scala +++ b/zio-schema-json/shared/src/test/scala-2/zio/schema/codec/JsonCodecSpec.scala @@ -1171,8 +1171,8 @@ object JsonCodecSpec extends ZIOSpecDefault { val dyn = DynamicValue.fromSchemaAndValue(schema, value) ZStream .succeed(dyn) - .via(JsonCodec.schemaBasedBinaryCodec(Schema.dynamicValue, JsonCodec.Config.default).streamEncoder) - .via(JsonCodec.schemaBasedBinaryCodec(Schema.dynamicValue, JsonCodec.Config.default).streamDecoder) + .via(JsonCodec.schemaBasedBinaryCodec(Schema.dynamicValue).streamEncoder) + .via(JsonCodec.schemaBasedBinaryCodec(Schema.dynamicValue).streamDecoder) .map(_.toTypedValue(schema)) .runHead .map { result => @@ -1215,7 +1215,7 @@ object JsonCodecSpec extends ZIOSpecDefault { ) = { val stream = ZStream .succeed(value) - .via(JsonCodec.schemaBasedBinaryCodec(schema, cfg).streamEncoder) + .via(JsonCodec.schemaBasedBinaryCodec(cfg)(schema).streamEncoder) .runCollect .tap { chunk => printLine(s"${new String(chunk.toArray)}").when(print).ignore @@ -1231,7 +1231,7 @@ object JsonCodecSpec extends ZIOSpecDefault { ) = { val stream = ZStream .succeed(value) - .via(JsonCodec.schemaBasedBinaryCodec[A](schema, cfg).streamEncoder) + .via(JsonCodec.schemaBasedBinaryCodec[A](cfg)(schema).streamEncoder) .runCollect .map(chunk => new String(chunk.toArray)) assertZIO(stream)(equalTo(json)) @@ -1240,7 +1240,7 @@ object JsonCodecSpec extends ZIOSpecDefault { private def assertEncodesJson[A](schema: Schema[A], value: A)(implicit enc: JsonEncoder[A]) = { val stream = ZStream .succeed(value) - .via(JsonCodec.schemaBasedBinaryCodec[A](schema, JsonCodec.Config.default).streamEncoder) + .via(JsonCodec.schemaBasedBinaryCodec[A](schema).streamEncoder) .runCollect assertZIO(stream)(equalTo(jsonEncoded(value))) } @@ -1253,7 +1253,7 @@ object JsonCodecSpec extends ZIOSpecDefault { ) = { val stream = ZStream .fromChunk(charSequenceToByteChunk(json)) - .via(JsonCodec.schemaBasedBinaryCodec[A](schema, cfg).streamDecoder) + .via(JsonCodec.schemaBasedBinaryCodec[A](cfg)(schema).streamDecoder) .catchAll(ZStream.succeed[DecodeError](_)) .runHead assertZIO(stream)(isSome(equalTo(ReadError(Cause.empty, JsonError.render(errors))))) @@ -1265,7 +1265,7 @@ object JsonCodecSpec extends ZIOSpecDefault { chunk: Chunk[Byte], cfg: JsonCodec.Config = JsonCodec.Config.default ) = { - val result = ZStream.fromChunk(chunk).via(JsonCodec.schemaBasedBinaryCodec[A](schema, cfg).streamDecoder).runCollect + val result = ZStream.fromChunk(chunk).via(JsonCodec.schemaBasedBinaryCodec[A](cfg)(schema).streamDecoder).runCollect assertZIO(result)(equalTo(Chunk(value))) } @@ -1283,13 +1283,13 @@ object JsonCodecSpec extends ZIOSpecDefault { ZStream .succeed(value) .tap(value => printLine(s"Input Value: $value").when(print).ignore) - .via(JsonCodec.schemaBasedBinaryCodec[A1](encodingSchema, cfg).streamEncoder) + .via(JsonCodec.schemaBasedBinaryCodec[A1](cfg)(encodingSchema).streamEncoder) .runCollect .tap(encoded => printLine(s"Encoded: ${new String(encoded.toArray)}").when(print).ignore) .flatMap { encoded => ZStream .fromChunk(encoded) - .via(JsonCodec.schemaBasedBinaryCodec[A2](decodingSchema, cfg).streamDecoder) + .via(JsonCodec.schemaBasedBinaryCodec[A2](cfg)(decodingSchema).streamDecoder) .runCollect .tapError { err => printLineError(s"Decoding failed for input ${new String(encoded.toArray)}\nError Message: $err")