Skip to content

Commit 82c1f1e

Browse files
authored
refactor(codegen): consume upstream interface changes (#540)
1 parent 1f8f269 commit 82c1f1e

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/RestXml.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ class RestXmlParserGenerator(
6262
writer: KotlinWriter
6363
): XmlSerdeDescriptorGenerator = RestXmlSerdeDescriptorGenerator(ctx.toRenderingContext(protocolGenerator, shape, writer), members)
6464

65-
override fun payloadDeserializer(ctx: ProtocolGenerator.GenerationContext, member: MemberShape): Symbol {
66-
return if (member.hasTrait<XmlNameTrait>()) {
65+
override fun payloadDeserializer(ctx: ProtocolGenerator.GenerationContext, shape: Shape): Symbol {
66+
return if (shape.hasTrait<XmlNameTrait>() && shape is MemberShape) {
6767
// can't delegate, have to generate a dedicated deserializer because the member xml name is different
6868
// from the name of the target shape
69-
explicitBoundStructureDeserializer(ctx, member)
69+
explicitBoundStructureDeserializer(ctx, shape)
7070
} else {
71-
super.payloadDeserializer(ctx, member)
71+
super.payloadDeserializer(ctx, shape)
7272
}
7373
}
7474

@@ -116,13 +116,13 @@ class RestXmlSerializerGenerator(
116116
writer: KotlinWriter
117117
): XmlSerdeDescriptorGenerator = RestXmlSerdeDescriptorGenerator(ctx.toRenderingContext(protocolGenerator, shape, writer), members)
118118

119-
override fun payloadSerializer(ctx: ProtocolGenerator.GenerationContext, member: MemberShape): Symbol {
120-
return if (member.hasTrait<XmlNameTrait>()) {
119+
override fun payloadSerializer(ctx: ProtocolGenerator.GenerationContext, shape: Shape): Symbol {
120+
return if (shape.hasTrait<XmlNameTrait>() && shape is MemberShape) {
121121
// can't delegate, have to generate a dedicated serializer because the member xml name is different
122122
// from the name of the target shape
123-
explicitBoundStructureSerializer(ctx, member)
123+
explicitBoundStructureSerializer(ctx, shape)
124124
} else {
125-
super.payloadSerializer(ctx, member)
125+
super.payloadSerializer(ctx, shape)
126126
}
127127
}
128128

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/core/QueryHttpBindingProtocolGenerator.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import software.amazon.smithy.kotlin.codegen.core.RuntimeTypes
77
import software.amazon.smithy.kotlin.codegen.core.withBlock
88
import software.amazon.smithy.kotlin.codegen.model.expectShape
99
import software.amazon.smithy.kotlin.codegen.model.knowledge.SerdeIndex
10+
import software.amazon.smithy.kotlin.codegen.model.targetOrSelf
1011
import software.amazon.smithy.kotlin.codegen.rendering.protocol.HttpBindingResolver
1112
import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolGenerator
1213
import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolMiddleware
@@ -158,10 +159,10 @@ abstract class AbstractQueryFormUrlSerializerGenerator(
158159
}
159160
}
160161

161-
override fun payloadSerializer(ctx: ProtocolGenerator.GenerationContext, member: MemberShape): Symbol {
162+
override fun payloadSerializer(ctx: ProtocolGenerator.GenerationContext, shape: Shape): Symbol {
162163
// re-use document serializer (for the target shape!)
163-
val target = ctx.model.expectShape(member.target)
164-
val symbol = ctx.symbolProvider.toSymbol(member)
164+
val target = shape.targetOrSelf(ctx.model)
165+
val symbol = ctx.symbolProvider.toSymbol(shape)
165166
val serializeFn = documentSerializer(ctx, target)
166167
val fnName = symbol.payloadSerializerName()
167168
return symbol.payloadSerializer(ctx.settings) { writer ->

codegen/smithy-aws-kotlin-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/protocols/core/AwsHttpBindingProtocolGeneratorTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class AwsHttpBindingProtocolGeneratorTest {
101101
error("Unneeded for test")
102102
}
103103

104-
override fun payloadDeserializer(ctx: ProtocolGenerator.GenerationContext, member: MemberShape): Symbol {
104+
override fun payloadDeserializer(ctx: ProtocolGenerator.GenerationContext, shape: Shape): Symbol {
105105
error("Unneeded for test")
106106
}
107107
}
@@ -112,7 +112,7 @@ class AwsHttpBindingProtocolGeneratorTest {
112112
error("Unneeded for test")
113113
}
114114

115-
override fun payloadSerializer(ctx: ProtocolGenerator.GenerationContext, member: MemberShape): Symbol {
115+
override fun payloadSerializer(ctx: ProtocolGenerator.GenerationContext, shape: Shape): Symbol {
116116
error("Unneeded for test")
117117
}
118118
}

0 commit comments

Comments
 (0)