private OpenApi removalRound(Context<? extends Trait> context, OpenApi openapi) {
        // Create a set of every component pointer (currently just schemas).
        String schemaPointerPrefix = context.getConfig().getDefinitionPointer() + "/";
        Set<String> pointers = openapi.getComponents()
                .getSchemas()
                .keySet()
                .stream()
                .map(key -> schemaPointerPrefix + key)
                .collect(Collectors.toSet());

        // Remove all found "$ref" pointers from the set, leaving only unreferenced.
        pointers.removeAll(findAllRefs(openapi.toNode().expectObjectNode()));

        if (pointers.isEmpty()) {
            return openapi;
        }

        LOGGER.info(() -> "Removing unused OpenAPI components: " + pointers);

        ComponentsObject.Builder componentsBuilder = openapi.getComponents().toBuilder();
        for (String pointer : pointers) {
            if (pointer.startsWith(schemaPointerPrefix)) {
                componentsBuilder.removeSchema(pointer.replace(schemaPointerPrefix, ""));
            } else {
                throw new UnsupportedOperationException("Unreachable statement for not yet implemented removal");
            }
        }

        return openapi.toBuilder().components(componentsBuilder.build()).build();
    }
Removes unused components from the OpenAPI model.

<p>This plugin will take effect by default, but can be disabled by setting
"openapi.keepUnusedComponents" to true. Refs are removed in rounds until
a round of removals has no effect.

<p>TODO: This plugin currently only supports the removal of schemas and security schemes.
smithy-openapi/src/main/java/software/amazon/smithy/openapi/fromsmithy/mappers/RemoveUnusedComponents.java