Skip to content
Unverified Commit 3d0b98c1 authored by david-perez's avatar david-perez Committed by GitHub
Browse files

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`.
parent f34abdaf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment