Skip to content

Commit 7e8a5b1

Browse files
authored
fix: properly parse timestamps when format override is applied to target shapes
1 parent 0a1eeda commit 7e8a5b1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "cccb2f1d-b607-4b8d-9f26-5ff172fffa1d",
3+
"type": "bugfix",
4+
"description": "Properly parse timestamps when format override is applied to target shapes",
5+
"issues": [
6+
"awslabs/smithy-kotlin#714"
7+
]
8+
}

smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/serde/DeserializeStructGenerator.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,8 @@ open class DeserializeStructGenerator(
541541

542542
target.type == ShapeType.TIMESTAMP -> {
543543
writer.addImport(RuntimeTypes.Core.Instant)
544-
val tsFormat = shape
545-
.getTrait(TimestampFormatTrait::class.java)
546-
.map { it.format }
547-
.orElse(defaultTimestampFormat)
544+
val trait = shape.getTrait<TimestampFormatTrait>() ?: target.getTrait()
545+
val tsFormat = trait?.format ?: defaultTimestampFormat
548546

549547
when (tsFormat) {
550548
TimestampFormatTrait.Format.EPOCH_SECONDS -> "deserializeString().let { Instant.fromEpochSeconds(it) }"

0 commit comments

Comments
 (0)