Skip to content

Commit dc64724

Browse files
sichanyooSichan Yoo
andauthored
chore: Misc codegen fixes (#732)
* Add .sorted() before comment codegen for errors. * Fix extra spacing in deprecated trait message codegen. --------- Co-authored-by: Sichan Yoo <[email protected]>
1 parent bbe6f43 commit dc64724

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/ServiceGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ServiceGenerator() {
7979
writer.writeSingleLineDocs { write("- Throws: One of the exceptions listed below __Possible Exceptions__.") }
8080
writeEmptyLine()
8181
writer.writeSingleLineDocs { write("__Possible Exceptions:__") }
82-
op.getErrors(service).forEach { error ->
82+
op.getErrors(service).sorted().forEach { error ->
8383
writer.writeDocs("\\- \\`${error.name}\\` : ${retrieveMemberShapeDoc(error.toShapeId(), model)}")
8484
}
8585
}

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftWriter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ class SwiftWriter(private val fullPackageName: String, swiftImportContainer: Swi
228228
message.append(deprecatedTrait.message.get())
229229
}
230230
if (sincePresent) {
231-
message.append(" API deprecated since ${deprecatedTrait.since.get()}")
231+
val conditionalSpace = if (messagePresent) " " else ""
232+
message.append("${conditionalSpace}API deprecated since ${deprecatedTrait.since.get()}")
232233
}
233234

234235
if (messagePresent || sincePresent) {

smithy-swift-codegen/src/test/kotlin/StructureGeneratorTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ public struct MyError: ClientRuntime.ModeledError, ClientRuntime.ServiceError, C
456456
Assertions.assertNotNull(structWithDeprecatedTrait)
457457
structContainsDeprecatedTrait = """
458458
extension ExampleClientTypes {
459-
@available(*, deprecated, message: " API deprecated since 2019-03-21")
459+
@available(*, deprecated, message: "API deprecated since 2019-03-21")
460460
public struct StructSincePropertySet {
461461
""".trimIndent()
462462
structWithDeprecatedTrait.shouldContain(structContainsDeprecatedTrait)
@@ -480,7 +480,7 @@ public struct MyError: ClientRuntime.ModeledError, ClientRuntime.ServiceError, C
480480
public var intVal: Swift.Int?
481481
@available(*, deprecated)
482482
public var string: Swift.String?
483-
@available(*, deprecated, message: " API deprecated since 2019-03-21")
483+
@available(*, deprecated, message: "API deprecated since 2019-03-21")
484484
public var structSincePropertySet: ExampleClientTypes.StructSincePropertySet?
485485
@available(*, deprecated, message: "This shape is no longer used. API deprecated since 1.3")
486486
public var structWithDeprecatedTrait: ExampleClientTypes.StructWithDeprecatedTrait?

0 commit comments

Comments
 (0)