Skip to content

Commit

Permalink
fix(codegen): resource operations not generating paginators or waiters (
Browse files Browse the repository at this point in the history
  • Loading branch information
aajtodd authored Mar 28, 2024
1 parent 61ce2ab commit 281d415
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/c855db56-72aa-4f1e-9200-46122fdaec75.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "c855db56-72aa-4f1e-9200-46122fdaec75",
"type": "bugfix",
"description": "Fix not generating waiters and paginators for operations that come from resources"
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import software.amazon.smithy.kotlin.codegen.utils.getOrNull
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.knowledge.PaginatedIndex
import software.amazon.smithy.model.knowledge.PaginationInfo
import software.amazon.smithy.model.knowledge.TopDownIndex
import software.amazon.smithy.model.shapes.CollectionShape
import software.amazon.smithy.model.shapes.MapShape
import software.amazon.smithy.model.shapes.OperationShape
Expand All @@ -38,7 +39,9 @@ import software.amazon.smithy.model.traits.PaginatedTrait
*/
class PaginatorGenerator : KotlinIntegration {
override fun enabledForService(model: Model, settings: KotlinSettings): Boolean =
model.operationShapes.any { it.hasTrait<PaginatedTrait>() }
TopDownIndex.of(model)
.getContainedOperations(settings.service)
.any { it.hasTrait<PaginatedTrait>() }

override fun writeAdditionalFiles(ctx: CodegenContext, delegator: KotlinDelegator) {
val service = ctx.model.expectShape<ServiceShape>(ctx.settings.service)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
import software.amazon.smithy.kotlin.codegen.model.expectShape
import software.amazon.smithy.kotlin.codegen.model.getTrait
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.knowledge.TopDownIndex
import software.amazon.smithy.model.shapes.OperationShape
import software.amazon.smithy.model.shapes.ServiceShape
import software.amazon.smithy.waiters.*
Expand All @@ -20,7 +21,9 @@ import software.amazon.smithy.waiters.*
*/
class ServiceWaitersGenerator : KotlinIntegration {
override fun enabledForService(model: Model, settings: KotlinSettings): Boolean =
model.operationShapes.any { it.waitableTrait != null }
TopDownIndex.of(model)
.getContainedOperations(settings.service)
.any { it.waitableTrait != null }

override fun writeAdditionalFiles(ctx: CodegenContext, delegator: KotlinDelegator) {
delegator.useFileWriter("Waiters.kt", "${ctx.settings.pkg.name}.waiters") { writer ->
Expand Down

0 comments on commit 281d415

Please sign in to comment.