Return empty HTTP response body when restJson1 operation has no output shape (#1208)
According to the protocol tests, here's how a server should behave when the operation has no output, and when the operation output shape is empty (has no members): * Empty output is serialized to `"{}"`; clients should gracefully accept `""`. * No output is serialized to `""`. Compare this to how clients should behave when the operation has no input, and when the operation input shape is empty (has no members): * Empty input is serialized to `""`; servers should gracefully accept `"{}"`. * No input is serialized to `""`. Notice the behavioral difference in the empty case among clients and servers. Since clients treat both cases the same by serializing `""`, the "no input" case is reduced to the "empty input" case by transforming the model and creating synthetic empty input shapes for all operations that have no input shapes. However, the server behavior is different. Up until this commit servers were always serializing `"{}"` in both cases. This commit implements the correct behavior. It does so by disambiguating both cases by checking if the operation output shape is actually synthetic, which would mean that the original model has no operation output. In that case the structured data serializer now returns `null`, so we end up serializing `""` to the HTTP response body. This commit also renames the methods in charge of serializing operation inputs/outputs from the `StructuredDataSerializerGenerator` interface, and removes the unused class `OutputBodyTrait` from `SyntheticOutputTrait.kt`.
Loading
Please register or sign in to comment