-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
f8ec0dd
commit 57b2059
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1143,6 +1143,37 @@ object JsonCodecSpec extends ZIOSpecDefault { | |
charSequenceToByteChunk("""{"amount":1000, "type":"onetime"}""") | ||
) | ||
}, | ||
test("case name aliases - type in the last place and the content with an escaped string") { | ||
@discriminatorName("type") | ||
sealed trait Example { | ||
type Content | ||
def content: Content | ||
} | ||
|
||
object Example { | ||
@caseName("JSON") | ||
final case class JsonInput(content: String) extends Example { | ||
override type Content = String | ||
} | ||
|
||
implicit val schema: Schema[Example] = DeriveSchema.gen | ||
} | ||
|
||
assertDecodes( | ||
Example.schema, | ||
Example.JsonInput( | ||
""""{\n \"name\": \"John\",\"location\":\"Sydney\",\n \"email\": \"[email protected]\"\n}"""" | ||
), | ||
charSequenceToByteChunk( | ||
""" | ||
|{ | ||
| "content": "\"{\\n \\\"name\\\": \\\"John\\\",\\\"location\\\":\\\"Sydney\\\",\\n \\\"email\\\": \\\"[email protected]\\\"\\n}\"", | ||
| "type": "JSON" | ||
|} | ||
|""".stripMargin.trim | ||
) | ||
) | ||
}, | ||
test("case name - illegal discriminator value") { | ||
assertDecodesToError( | ||
Subscription.schema, | ||
|