Unverified Commit f97ebf2d authored by Guy Margalit's avatar Guy Margalit Committed by GitHub
Browse files

fix #1101 server XML response use correct members and return null if nothing to serialize (#1098)



Signed-off-by: default avatarGuy Margalit <guymguym@gmail.com>
parent 67ec04e4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -451,12 +451,12 @@ private class ServerHttpProtocolImplGenerator(
        bindings: List<HttpBindingDescriptor>,
    ) {
        val structuredDataSerializer = protocol.structuredDataSerializer(operationShape)
        structuredDataSerializer.serverOutputSerializer(operationShape).also { serializer ->
        structuredDataSerializer.serverOutputSerializer(operationShape)?.let { serializer ->
            rust(
                "let payload = #T(output)?;",
                serializer
            )
        }
        } ?: rust("""let payload = "";""")
        // avoid non-usage warnings for response
        Attribute.AllowUnusedMut.render(this)
        rustTemplate("let mut response = #{http}::Response::builder();", *codegenScope)
+2 −1
Original line number Diff line number Diff line
@@ -63,5 +63,6 @@ data class XmlMemberIndex(val dataMembers: List<MemberShape>, val attributeMembe
        }
    }

    fun isNotEmpty() = dataMembers.isNotEmpty() || attributeMembers.isNotEmpty()
    fun isEmpty() = dataMembers.isEmpty() && attributeMembers.isEmpty()
    fun isNotEmpty() = !isEmpty()
}
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ class AwsQuerySerializerGenerator(codegenContext: CodegenContext) : QuerySeriali

    override fun MemberShape.isFlattened(): Boolean = getTrait<XmlFlattenedTrait>() != null

    override fun serverOutputSerializer(operationShape: OperationShape): RuntimeType {
    override fun serverOutputSerializer(operationShape: OperationShape): RuntimeType? {
        TODO("Not yet implemented")
    }

+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ class Ec2QuerySerializerGenerator(codegenContext: CodegenContext) : QuerySeriali

    override fun MemberShape.isFlattened(): Boolean = true

    override fun serverOutputSerializer(operationShape: OperationShape): RuntimeType {
    override fun serverOutputSerializer(operationShape: OperationShape): RuntimeType? {
        TODO("Not yet implemented")
    }

+1 −1
Original line number Diff line number Diff line
@@ -242,7 +242,7 @@ class JsonSerializerGenerator(
        }
    }

    override fun serverOutputSerializer(operationShape: OperationShape): RuntimeType {
    override fun serverOutputSerializer(operationShape: OperationShape): RuntimeType? {
        val outputShape = operationShape.outputShape(model)
        val includedMembers = httpBindingResolver.responseMembers(operationShape, HttpLocation.DOCUMENT)
        val fnName = symbolProvider.serializeFunctionName(outputShape)
Loading