Closed kubukoz closed 2 years ago
Given this schema:
@discriminated("type") union TestUnion { one: String, two: Integer } @discriminated("tpe") union TestBiggerUnion { one: One, two: Two } structure One { value: String } structure Two { value: Integer }
And this JSON:
""" { "tpe" : "one" , "value" : "hello" }"""
A failure is generated:
[error] [json] - Discriminated union decoding tolerates whitespace 46ms [error] [json] PayloadError: Expected JSON object, offset: 0x00000003, buf: [error] [json] +----------+-------------------------------------------------+------------------+ [error] [json] | | 0 1 2 3 4 5 6 7 8 9 a b c d e f | 0123456789abcdef | [error] [json] +----------+-------------------------------------------------+------------------+ [error] [json] | 00000000 | 20 7b 20 22 74 70 65 22 20 3a 20 22 6f 6e 65 22 | { "tpe" : "one" | [error] [json] | 00000010 | 20 2c 20 22 76 61 6c 75 65 22 20 3a 20 22 68 65 | , "value" : "he | [error] [json] | 00000020 | 6c 6c 6f 22 20 7d | llo" } | [error] [json] +----------+-------------------------------------------------+------------------+
If all whitespace is removed from the JSON string, decoding succeeds.
Reproduction in https://github.com/disneystreaming/smithy4s/pull/49.
As for the good news, dump-model produces a model that (after trimming whitespace between tokens) can be read by the default codecs :)
Given this schema:
And this JSON:
A failure is generated:
If all whitespace is removed from the JSON string, decoding succeeds.
Reproduction in https://github.com/disneystreaming/smithy4s/pull/49.