Skip to content

Commit

Permalink
chore: Add imports to model files where needed (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins authored May 10, 2024
1 parent 1fbe84e commit c2d1346
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import software.amazon.smithy.model.shapes.TimestampShape
import software.amazon.smithy.model.traits.SparseTrait
import software.amazon.smithy.model.traits.TimestampFormatTrait
import software.amazon.smithy.model.traits.XmlFlattenedTrait
import software.amazon.smithy.swift.codegen.SwiftDependency
import software.amazon.smithy.swift.codegen.SwiftWriter
import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator
import software.amazon.smithy.swift.codegen.integration.serde.json.TimestampUtils
Expand All @@ -32,6 +33,7 @@ class WritingClosureUtils(
}

private fun makeWritingClosure(shape: Shape, memberTimestampFormatTrait: TimestampFormatTrait?, isSparse: Boolean): String {
writer.addImport(SwiftDependency.SMITHY_READ_WRITE.target)
val base = when (shape) {
is MapShape -> {
val keyNodeInfo = nodeInfoUtils.nodeInfo(shape.key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import software.amazon.smithy.swift.codegen.integration.serde.readwrite.requestW
import software.amazon.smithy.swift.codegen.integration.serde.readwrite.responseWireProtocol
import software.amazon.smithy.swift.codegen.model.ShapeMetadata
import software.amazon.smithy.swift.codegen.model.isError
import java.lang.Exception

class StructEncodeGenerator(
private val ctx: ProtocolGenerator.GenerationContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import software.amazon.smithy.swift.codegen.integration.serde.member.MemberShape
import software.amazon.smithy.swift.codegen.integration.serde.readwrite.AWSProtocol
import software.amazon.smithy.swift.codegen.integration.serde.readwrite.addImports
import software.amazon.smithy.swift.codegen.integration.serde.readwrite.awsProtocol
import software.amazon.smithy.swift.codegen.integration.serde.readwrite.requestWireProtocol
import software.amazon.smithy.swift.codegen.integration.serde.readwrite.responseWireProtocol
import software.amazon.smithy.swift.codegen.integration.serde.struct.readerSymbol
import software.amazon.smithy.swift.codegen.model.getTrait

Expand All @@ -27,7 +27,7 @@ class UnionDecodeGenerator(
) : MemberShapeDecodeGenerator(ctx, writer, shapeContainingMembers) {

fun render() {
writer.addImports(ctx.service.requestWireProtocol)
writer.addImports(ctx.service.responseWireProtocol)
val symbol = ctx.symbolProvider.toSymbol(shapeContainingMembers)
writer.openBlock(
"static func read(from reader: \$N) throws -> \$N {", "}",
Expand Down

0 comments on commit c2d1346

Please sign in to comment.