File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
zio-schema-json/shared/src/test/scala/zio/schema/codec Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ object BuildHelper {
3434 val Scala3 : String = versions(" 3.3" )
3535
3636 val zioVersion = " 2.1.14"
37- val zioJsonVersion = " 0.7.5 "
37+ val zioJsonVersion = " 0.7.6 "
3838 val zioPreludeVersion = " 1.0.0-RC37"
3939 val zioOpticsVersion = " 0.2.2"
4040 val zioBsonVersion = " 1.0.6"
Original file line number Diff line number Diff line change @@ -1143,6 +1143,37 @@ object JsonCodecSpec extends ZIOSpecDefault {
11431143 charSequenceToByteChunk(""" {"amount":1000, "type":"onetime"}""" )
11441144 )
11451145 },
1146+ test(" case name aliases - type in the last place and the content with an escaped string" ) {
1147+ @ discriminatorName(" type" )
1148+ sealed trait Example {
1149+ type Content
1150+ def content : Content
1151+ }
1152+
1153+ object Example {
1154+ @ caseName(" JSON" )
1155+ final case class JsonInput (content : String ) extends Example {
1156+ override type Content = String
1157+ }
1158+
1159+ implicit val schema : Schema [Example ] = DeriveSchema .gen
1160+ }
1161+
1162+ assertDecodes(
1163+ Example .schema,
1164+ Example .JsonInput (
1165+ """ "{\n \"name\": \"John\",\"location\":\"Sydney\",\n \"email\": \"[email protected] \"\n}"""" 1166+ ),
1167+ charSequenceToByteChunk(
1168+ """
1169+ |{
1170+ | "content": "\"{\\ n \\ \"name\\ \": \\ \"John\\ \",\\ \"location\\ \":\\ \"Sydney\\ \",\\ n \\ \"email\\ \": \\ \"[email protected] \\ \"\\ n}\"", 1171+ | "type": "JSON"
1172+ |}
1173+ |""" .stripMargin.trim
1174+ )
1175+ )
1176+ },
11461177 test(" case name - illegal discriminator value" ) {
11471178 assertDecodesToError(
11481179 Subscription .schema,
You can’t perform that action at this time.
0 commit comments