private List<ValidationEvent> validateService(TopDownIndex topDownIndex, ServiceShape service) {
        List<ValidationEvent> events = new ArrayList<>();
        for (ResourceShape resource : topDownIndex.getContainedResources(service)) {
            Set<ShapeId> containers = new HashSet<>();
            if (service.getResources().contains(resource.getId())) {
                containers.add(service.getId());
            }

            for (ResourceShape otherResource : topDownIndex.getContainedResources(service)) {
                if (otherResource.getResources().contains(resource.getId())) {
                    containers.add(otherResource.getId());
                }
            }

            if (containers.size() > 1) {
                events.add(error(resource,
                        String.format(
                                "A resource can appear only once in an entire service closure. This resource is "
                                        + "illegally bound into the `%s` service closure from multiple shapes: [%s]",
                                service.getId(),
                                ValidationUtils.tickedList(containers))));
            }
        }
        return events;
    }
Validates that a resource is only bound to once in an entire
service closure.
smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/SingleResourceBindingValidator.java