Unverified Commit d5ea2cdd authored by ysaito1001's avatar ysaito1001 Committed by GitHub
Browse files

Upgrade Smithy to 1.49 (#3662)

## Motivation and Context
Upgrades Smithy to 1.49.0

## Description
As part of the upgrade, it updates the serializer for EC2 query protocol
to handle empty lists in response to
[this](https://github.com/smithy-lang/smithy/pull/2269) (otherwise [a
protocol
test](https://github.com/smithy-lang/smithy-rs/blob/main/codegen-client-test/build.gradle.kts#L75)
`ec2_empty_query_lists_request` would fail).

## Testing
Existing tests in CI

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent ab74d876
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -6,10 +6,13 @@
package software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize

import software.amazon.smithy.aws.traits.protocols.Ec2QueryNameTrait
import software.amazon.smithy.model.shapes.CollectionShape
import software.amazon.smithy.model.shapes.MemberShape
import software.amazon.smithy.model.shapes.OperationShape
import software.amazon.smithy.model.shapes.ShapeId
import software.amazon.smithy.model.traits.XmlNameTrait
import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter
import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock
import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType
import software.amazon.smithy.rust.codegen.core.util.getTrait
@@ -32,4 +35,13 @@ class Ec2QuerySerializerGenerator(codegenContext: CodegenContext) : QuerySeriali
    override fun serverErrorSerializer(shape: ShapeId): RuntimeType {
        TODO("Not yet implemented")
    }

    override fun RustWriter.serializeCollection(
        memberContext: MemberContext,
        context: Context<CollectionShape>,
    ) {
        rustBlock("if !${context.valueExpression.asRef()}.is_empty()") {
            super.serializeCollectionInner(memberContext, context, this)
        }
    }
}
+30 −20
Original line number Diff line number Diff line
@@ -282,10 +282,19 @@ abstract class QuerySerializerGenerator(private val codegenContext: CodegenConte
        }
    }

    private fun RustWriter.serializeCollection(
    protected open fun RustWriter.serializeCollection(
        memberContext: MemberContext,
        context: Context<CollectionShape>,
    ) {
        serializeCollectionInner(memberContext, context, this)
    }

    protected fun serializeCollectionInner(
        memberContext: MemberContext,
        context: Context<CollectionShape>,
        writer: RustWriter,
    ) {
        writer.apply {
            val flat = memberContext.shape.isFlattened()
            val memberOverride =
                when (val override = context.shape.member.getTrait<XmlNameTrait>()?.value) {
@@ -308,6 +317,7 @@ abstract class QuerySerializerGenerator(private val codegenContext: CodegenConte
                rust("$listName.finish();")
            }
        }
    }

    private fun RustWriter.serializeMap(
        memberContext: MemberContext,
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ kotlin.code.style=official

# codegen
smithyGradlePluginVersion=0.9.0
smithyVersion=1.47.0
smithyVersion=1.49.0
allowLocalDeps=false

# kotlin