Skip to content

Commit 49ebbd5

Browse files
authored
Merge branch 'main' into update-all-lockfiles-1758665151
2 parents 29e5aa6 + 4892877 commit 49ebbd5

File tree

7 files changed

+22
-30
lines changed

7 files changed

+22
-30
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ jobs:
110110
runner: ubuntu-latest
111111
- action: check-server-codegen-unit-tests-python
112112
runner: ubuntu-latest
113+
- action: check-serde-codegen-unit-tests
114+
runner: ubuntu-latest
113115
- action: check-server-e2e-test
114116
runner: ubuntu-latest
115117
- action: check-server-python-e2e-test

ci.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ check-server-codegen-integration-tests:
8484
check-server-codegen-unit-tests:
8585
$(CI_ACTION) $@ $(ARGS)
8686

87+
.PHONY: check-serde-codegen-unit-tests
88+
check-serde-codegen-unit-tests:
89+
$(CI_ACTION) $@ $(ARGS)
90+
8791
.PHONY: check-server-codegen-integration-tests-python
8892
check-server-codegen-integration-tests-python:
8993
$(CI_ACTION) $@ $(ARGS)

codegen-serde/src/main/kotlin/software/amazon/smithy/rust/codegen/serde/SerializeImplGenerator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ class SerializeImplGenerator(private val codegenContext: CodegenContext) {
544544
) {
545545
rustTemplate(
546546
"""
547-
impl<'a> #{serde}::Serialize for #{ConfigurableSerdeRef}<'a, #{Shape}> {
547+
impl #{serde}::Serialize for #{ConfigurableSerdeRef}<'_, #{Shape}> {
548548
fn serialize<S>(&self, serializer: S) -> #{Result}<S::Ok, S::Error>
549549
where
550550
S: #{serde}::Serializer,
@@ -567,7 +567,7 @@ class SerializeImplGenerator(private val codegenContext: CodegenContext) {
567567
return writable {
568568
rustTemplate(
569569
"""
570-
impl<'a, 'b> #{serde}::Serialize for #{ConfigurableSerdeRef}<'a, #{Shape}<'b>> {
570+
impl #{serde}::Serialize for #{ConfigurableSerdeRef}<'_, #{Shape}<'_>> {
571571
fn serialize<S>(&self, serializer: S) -> #{Result}<S::Ok, S::Error>
572572
where
573573
S: #{serde}::Serializer,

codegen-serde/src/main/kotlin/software/amazon/smithy/rust/codegen/serde/SupportStructures.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ object SupportStructures {
133133
"""
134134
pub(crate) struct Sensitive<T>(pub(crate) T);
135135
136-
impl<'a, T> #{serde}::Serialize for ConfigurableSerdeRef<'a, Sensitive<T>>
136+
impl<T> #{serde}::Serialize for ConfigurableSerdeRef<'_, Sensitive<T>>
137137
where
138138
T: #{serde}::Serialize,
139139
{
@@ -175,7 +175,7 @@ object SupportStructures {
175175
.serialize(serializer)
176176
}
177177
}
178-
impl<'a, T> #{serde}::Serialize for #{ConfigurableSerdeRef}<'a, Option<T>>
178+
impl<T> #{serde}::Serialize for #{ConfigurableSerdeRef}<'_, Option<T>>
179179
where
180180
T: #{SerializeConfigured},
181181
{
@@ -235,7 +235,7 @@ object SupportStructures {
235235
///
236236
/// Note: This may alter the type of the serialized output and make it impossible to deserialize as
237237
/// numerical fields will be replaced with strings.
238-
pub const fn redact_sensitive_fields() -> Self { Self { redact_sensitive_fields: true, out_of_range_floats_as_strings: false } }
238+
pub const fn redact_sensitive_fields() -> Self { Self { redact_sensitive_fields: true, out_of_range_floats_as_strings: true } }
239239
240240
/// Preserve the contents of sensitive fields during serializing
241241
pub const fn leak_sensitive_fields() -> Self { Self { redact_sensitive_fields: false, out_of_range_floats_as_strings: false } }

codegen-serde/src/test/kotlin/software/amazon/smithy/rust/codegen/serde/SerdeDecoratorTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ class SerdeDecoratorTest {
255255
IntegrationTestParams(cargoCommand = "cargo test --all-features", service = "com.example#MyService")
256256
serverIntegrationTest(model, params = params) { _, crate ->
257257
crate.integrationTest("test_serde") {
258+
rust("##![allow(unexpected_cfgs)]")
258259
unitTest("fails_if_serde_feature_exists", additionalAttributes = listOf(Attribute(cfg(feature("serde"))))) {
259260
rust("assert!(false);")
260261
}
@@ -347,6 +348,7 @@ class SerdeDecoratorTest {
347348
.build()
348349
.unwrap();
349350
let mut settings = SerializationSettings::default();
351+
settings.out_of_range_floats_as_strings = true;
350352
let serialized = #{serde_json}::to_string(&input.serialize_ref(&settings)).expect("failed to serialize");
351353
assert_eq!(serialized, ${expectedNoRedactions.dq()});
352354
settings.redact_sensitive_fields = true;

codegen-serde/src/test/kotlin/software/amazon/smithy/rust/codegen/serde/SerdeProtocolTestTest.kt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,21 @@
55

66
package software.amazon.smithy.rust.codegen.serde
77

8-
import org.junit.jupiter.api.Test
98
import org.junit.jupiter.params.ParameterizedTest
10-
import org.junit.jupiter.params.provider.Arguments
119
import org.junit.jupiter.params.provider.ValueSource
1210
import software.amazon.smithy.model.Model
1311
import software.amazon.smithy.model.SourceLocation
1412
import software.amazon.smithy.model.node.Node
1513
import software.amazon.smithy.model.shapes.ServiceShape
1614
import software.amazon.smithy.model.shapes.ShapeId
1715
import software.amazon.smithy.model.transform.ModelTransformer
18-
import software.amazon.smithy.rust.codegen.client.testutil.clientIntegrationTest
19-
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId
2016
import software.amazon.smithy.rust.codegen.core.testutil.IntegrationTestParams
2117
import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel
2218
import software.amazon.smithy.rust.codegen.core.util.letIf
2319
import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverIntegrationTest
2420
import java.io.File
25-
import java.util.stream.Stream
2621

2722
class SerdeProtocolTestTest {
28-
companion object {
29-
@JvmStatic
30-
fun testedModels(): Stream<Arguments> =
31-
Stream.of(
32-
Arguments.of(ShapeId.from(ServiceShapeId.REST_JSON)),
33-
Arguments.of(ShapeId.from("com.amazonaws.constraints#ConstraintService")),
34-
)
35-
}
36-
37-
@Test
38-
fun testRestJson() {
39-
val serviceShapeId = ShapeId.from("com.amazonaws.constraints#ConstraintService")
40-
val model = Model.assembler().discoverModels().assemble().result.get().attachSerdeToService(serviceShapeId)
41-
clientIntegrationTest(
42-
model,
43-
IntegrationTestParams(service = serviceShapeId.toString(), cargoCommand = "cargo test --all-features"),
44-
) { clientCodegenContext, rustCrate ->
45-
}
46-
}
47-
4823
private fun Model.attachSerdeToService(serviceShapeId: ShapeId): Model {
4924
val service =
5025
this.expectShape(serviceShapeId, ServiceShape::class.java).toBuilder().addTrait(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
#
3+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
set -eux
8+
cd smithy-rs
9+
./gradlew codegen-serde:test

0 commit comments

Comments
 (0)