Skip to content

Commit 3254b1f

Browse files
authored
update smithy to 1.42.0 (#631)
1 parent d51e9a6 commit 3254b1f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kotlin.code.style=official
33
# config
44

55
# codegen
6-
smithyVersion=1.39.0
6+
smithyVersion=1.42.0
77
smithyGradleVersion=0.6.0
88

99
# kotlin

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import software.amazon.smithy.model.shapes.StructureShape
2020
import software.amazon.smithy.model.shapes.UnionShape
2121
import software.amazon.smithy.model.traits.EnumTrait
2222
import software.amazon.smithy.model.traits.SensitiveTrait
23+
import software.amazon.smithy.model.transform.ModelTransformer
2324
import software.amazon.smithy.swift.codegen.core.GenerationContext
2425
import software.amazon.smithy.swift.codegen.integration.CustomDebugStringConvertibleGenerator
2526
import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator
@@ -86,6 +87,7 @@ class CodegenVisitor(context: PluginContext) : ShapeVisitor.Default<Void>() {
8687

8788
fun preprocessModel(model: Model): Model {
8889
var resolvedModel = model
90+
resolvedModel = ModelTransformer.create().flattenAndRemoveMixins(resolvedModel)
8991
resolvedModel = AddOperationShapes.execute(resolvedModel, settings.getService(resolvedModel), settings.moduleName)
9092
resolvedModel = RecursiveShapeBoxer.transform(resolvedModel)
9193
resolvedModel = NestedShapeTransformer.transform(resolvedModel, settings.getService(resolvedModel))

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class HttpProtocolTestGenerator(
3939
private val serdeContext: HttpProtocolUnitTestGenerator.SerdeContext,
4040
private val imports: List<String> = listOf(),
4141
// list of test IDs to ignore/skip
42-
private val testsToIgnore: Set<String> = setOf()
42+
private val testsToIgnore: Set<String> = setOf(),
43+
private val tagsToIgnore: Set<String> = setOf(),
4344
) {
4445
private val LOGGER = Logger.getLogger(javaClass.name)
4546

@@ -94,7 +95,7 @@ class HttpProtocolTestGenerator(
9495
.getOrNull()
9596
?.getTestCasesFor(AppliesTo.CLIENT)
9697
.orEmpty()
97-
val requestTestCases = filterProtocolTestCases(tempTestCases)
98+
val requestTestCases = filterProtocolTestCases(filterProtocolTestCasesByTags(tempTestCases))
9899
if (requestTestCases.isNotEmpty()) {
99100
val testClassName = "${operation.toUpperCamelCase()}RequestTest"
100101
val testFilename = "./${ctx.settings.testModuleName}/$testClassName.swift"
@@ -133,7 +134,7 @@ class HttpProtocolTestGenerator(
133134
.getOrNull()
134135
?.getTestCasesFor(AppliesTo.CLIENT)
135136
.orEmpty()
136-
val responseTestCases = filterProtocolTestCases(tempResponseTests)
137+
val responseTestCases = filterProtocolTestCases(filterProtocolTestCasesByTags(tempResponseTests))
137138
if (responseTestCases.isNotEmpty()) {
138139
val testClassName = "${operation.id.name.capitalize()}ResponseTest"
139140
val testFilename = "./${ctx.settings.testModuleName}/$testClassName.swift"
@@ -173,7 +174,7 @@ class HttpProtocolTestGenerator(
173174
.getOrNull()
174175
?.getTestCasesFor(AppliesTo.CLIENT)
175176
.orEmpty()
176-
val testCases = filterProtocolTestCases(tempTestCases)
177+
val testCases = filterProtocolTestCases(filterProtocolTestCasesByTags(tempTestCases))
177178
numTestCases += testCases.count()
178179
if (testCases.isNotEmpty()) {
179180
// multiple error (tests) may be associated with a single operation,
@@ -213,6 +214,11 @@ class HttpProtocolTestGenerator(
213214
private fun <T : HttpMessageTestCase> filterProtocolTestCases(testCases: List<T>): List<T> = testCases.filter {
214215
it.protocol == ctx.protocol && it.id !in testsToIgnore
215216
}
217+
218+
private fun <T : HttpMessageTestCase> filterProtocolTestCasesByTags(testCases: List<T>): List<T> =
219+
testCases.filter { testCase ->
220+
testCase.protocol == ctx.protocol && tagsToIgnore.none { tag -> testCase.hasTag(tag) }
221+
}
216222
}
217223

218224
private fun serverOnly(shape: Shape): Boolean = shape.hasTag("server-only")

0 commit comments

Comments
 (0)