public Model transform(ModelTransformer transformer, Model model) {
        Optional<PaginatedTrait> serviceLevelPagination = service.getTrait(PaginatedTrait.class);
        if (!serviceLevelPagination.isPresent()) {
            return model;
        }
        PaginatedIndex paginatedIndex = PaginatedIndex.of(model);

        // Merge service-level information into each operation's pagination trait.
        Set<Shape> updatedShapes = new HashSet<>();
        for (OperationShape operationShape : model.getOperationShapesWithTrait(PaginatedTrait.class)) {
            PaginationInfo paginationInfo = paginatedIndex.getPaginationInfo(service, operationShape).get();
            OperationShape updatedShape = operationShape.toBuilder()
                    .addTrait(paginationInfo.getPaginatedTrait())
                    .build();
            updatedShapes.add(updatedShape);
        }

        // Remove the paginated trait from the service as it's info has been flattened into the operations
        updatedShapes.add(service.toBuilder().removeTrait(PaginatedTrait.ID).build());

        return transformer.replaceShapes(model, updatedShapes);
    }
Flattens pagination info from service shapes into operation-level pagination traits.
smithy-model/src/main/java/software/amazon/smithy/model/transform/FlattenPaginationInfo.java