Loading codegen-core/common-test-models/pokemon-awsjson.smithy +0 −7 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ service PokemonService { } /// Capture Pokémons via event streams. @http(uri: "/capture-pokemon-event/{region}", method: "POST") operation CapturePokemon { input: CapturePokemonEventsInput, output: CapturePokemonEventsOutput, Loading @@ -36,17 +35,11 @@ operation CapturePokemon { @input structure CapturePokemonEventsInput { @httpPayload events: AttemptCapturingPokemonEvent, @httpLabel @required region: String, } @output structure CapturePokemonEventsOutput { @httpPayload events: CapturePokemonEvents, } Loading codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsJson.kt +18 −8 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ package software.amazon.smithy.rust.codegen.core.smithy.protocols import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.model.Model import software.amazon.smithy.model.pattern.UriPattern import software.amazon.smithy.model.shapes.MemberShape Loading Loading @@ -49,9 +50,17 @@ class AwsJsonHttpBindingResolver( .uri(UriPattern.parse("/")) .build() private fun bindings(shape: ToShapeId) = shape.let { model.expectShape(it.toShapeId()) }.members() .map { private fun bindings(shape: ToShapeId): List<HttpBindingDescriptor> { val members = shape.let { model.expectShape(it.toShapeId()) }.members() // TODO(https://github.com/awslabs/smithy-rs/issues/2237): support non-streaming members too if (members.size > 1 && members.any { it.isStreaming(model) }) { throw CodegenException( "We only support one payload member if that payload contains a streaming member." + "Tracking issue to relax this constraint: https://github.com/awslabs/smithy-rs/issues/2237", ) } return members.map { if (it.isStreaming(model)) { HttpBindingDescriptor(it, HttpLocation.PAYLOAD, "document") } else { Loading @@ -59,6 +68,7 @@ class AwsJsonHttpBindingResolver( } } .toList() } override fun httpTrait(operationShape: OperationShape): HttpTrait = httpTrait Loading Loading
codegen-core/common-test-models/pokemon-awsjson.smithy +0 −7 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ service PokemonService { } /// Capture Pokémons via event streams. @http(uri: "/capture-pokemon-event/{region}", method: "POST") operation CapturePokemon { input: CapturePokemonEventsInput, output: CapturePokemonEventsOutput, Loading @@ -36,17 +35,11 @@ operation CapturePokemon { @input structure CapturePokemonEventsInput { @httpPayload events: AttemptCapturingPokemonEvent, @httpLabel @required region: String, } @output structure CapturePokemonEventsOutput { @httpPayload events: CapturePokemonEvents, } Loading
codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsJson.kt +18 −8 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ package software.amazon.smithy.rust.codegen.core.smithy.protocols import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.model.Model import software.amazon.smithy.model.pattern.UriPattern import software.amazon.smithy.model.shapes.MemberShape Loading Loading @@ -49,9 +50,17 @@ class AwsJsonHttpBindingResolver( .uri(UriPattern.parse("/")) .build() private fun bindings(shape: ToShapeId) = shape.let { model.expectShape(it.toShapeId()) }.members() .map { private fun bindings(shape: ToShapeId): List<HttpBindingDescriptor> { val members = shape.let { model.expectShape(it.toShapeId()) }.members() // TODO(https://github.com/awslabs/smithy-rs/issues/2237): support non-streaming members too if (members.size > 1 && members.any { it.isStreaming(model) }) { throw CodegenException( "We only support one payload member if that payload contains a streaming member." + "Tracking issue to relax this constraint: https://github.com/awslabs/smithy-rs/issues/2237", ) } return members.map { if (it.isStreaming(model)) { HttpBindingDescriptor(it, HttpLocation.PAYLOAD, "document") } else { Loading @@ -59,6 +68,7 @@ class AwsJsonHttpBindingResolver( } } .toList() } override fun httpTrait(operationShape: OperationShape): HttpTrait = httpTrait Loading