Closed
Description
Consider:
operation NoInputAndNoOutput { }
operation EmptyInputAndEmptyOutput {
input: EmptyInputOutput
output: EmptyInputOutput
}
structure EmptyInputOutput { }
In the AWS JSON 1.x protocols, there's tests that assert that services must accept both an empty HTTP request body and a request body with an empty JSON document {}
when there is no input.
However, what should the behavior be when there is empty input? Note that:
- In AWS JSON 1.0 and AWS JSON 1.1, clients must always send an empty JSON document
{}
. If this is really a MUST, it would make sense to have services reject an empty HTTP request body for an empty input operation. - However,
restJson1
andrpcv2Cbor
are more lenient and allow both empty request bodies and empty JSON/CBOR objects.- In
restJson1
, clients even don't serialize a payload when the input is empty! So services must obviously accept this.- Although, it would be good to add an explicit protocol test for services.
- In
rpcv2Cbor
, there's an explicit test asserting that when the input is empty, services must accept an empty HTTP body.
- In
It's important to pin down this behavior because the protocol tests currently don't prescribe one; (1) would indicate that servers should be strict, but (2), and in general Postel's law, would lead us to not make the AWS JSON 1.x protocols less lenient than the other ones.
As a data point, currently AWS JSON 1.x smithy-rs servers are lenient.