Add schema-serde streaming JSON/XML deserializers, ec2Query, Codec, and ClientProtocol - #3910
Add schema-serde streaming JSON/XML deserializers, ec2Query, Codec, and ClientProtocol#3910pulimsr wants to merge 2 commits into
Conversation
de98be8 to
6976217
Compare
| EXPECT_EQ(entries["baz"], "qux"); | ||
| } | ||
|
|
||
| TEST_F(JsonShapeDeserializerTest, NestedStructure) { |
There was a problem hiding this comment.
summarizing from conversation:
so one thing that is left kind of ambigious to me in this is how we go from serializer to a hard type T. for instance given the class.
class bar {
std::string buzz;
};
class foo {
bar fizz;
};
how can the deserializer actually achieve constructing a object from {fizz: {buzz: \"value\"}}. would like to see a added test for each deserializer that accomplishes this, that can be used as the blueprint to adding it to codegen
There was a problem hiding this comment.
Added nested foo{bar{buzz}} round-trip tests for all three deserializers in CodecTest.cpp
| class SMITHY_API JsonCodec final : public Codec { | ||
| public: | ||
| SerializerOutcome Serialize(const Schema& schema, const SerializableStruct& shape) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateDeserializer(const unsigned char* data, size_t length) const override; |
There was a problem hiding this comment.
summarizing from offline:
ok i think CreateDeserializer is where where we have the disconnect and where it will come together for us with "how do we actually create a object T". so looking at the smithy java codec. we're actually borrowing a little bit more than we need. and we can actually walk this back.
so Serialize looks good, lets park that lets only talk about deserialize
in the java impl the have one called deserializeShape that is closer to our needs and answers the second question which is "how do we construct T given a stream of characters".
javas looks like
public <T extends SerializableShape> T deserializeShape(byte[] source, ShapeBuilder<T> builder)ours should end up looking like
void deserializeShape(const unsigned char* data,
size_t length,
std::function<void (const Schema& schema, const StructMemberConsumer& consumer)> consumer)this is so that during coden class would implement those struct member consumers to construct self
There was a problem hiding this comment.
Done — ported from the smithy-java Codec you linked. Added DeserializeShape(data, length, SerializableStruct& shape), which delegates to shape.Deserialize(*CreateDeserializer(...)) — the analogue of deserializeShape(source, builder) → builder.deserialize(createDeserializer(source)). The generated shape implements From() as its member consumer to construct itself.
Two deltas from the sketch, both to match smithy-java:
- Kept
CreateDeserializerpublic — smithy-java keepscreateDeserializeras a core interface method anddeserializeShapeis a helper on top, so there's nothing to walk back. - Passed the shape/builder instead of
std::function<void(const Schema&, StructMemberConsumer&)>- that literal form is circular (the callback would receive the consumer it's meant to supply).
…nd ClientProtocol
… with nested-shape codegen blueprint tests
6976217 to
294e2cd
Compare
Adds response deserialization and the protocol-selection layer to the schema-serde runtime.
ShapeDeserializerreworked to a push/consumer model (ReadStruct/ReadList/ReadMap), the dual ofShapeSerializer; scalars take const Schema&.JsonShapeDeserializerandXmlShapeDeserializer(new),CborShapeDeserializerupdated to match.QueryShapeSerializer: full nesting +ec2Queryflavor (newEc2QueryNameTrait).Codec(Json/Xml/Cbor) pairs serializer+deserializer;ClientProtocolpicks codec + content-type per protocol (restJson1, awsJson1.0/1.1, rpcv2Cbor, restXml, awsQuery, ec2Query),including the asymmetric query request/XML response case.
Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.