@Override
    public ObjectNode updateNode(Context<? extends Trait> context, OpenApi openapi, ObjectNode node) {
        ObjectNode components = node.getObjectMember(COMPONENTS).orElse(null);

        if (components == null) {
            return node;
        }

        // Remove all component key value pairs that are empty objects.
        ObjectNode updatedComponents = components.getMembers()
                .entrySet()
                .stream()
                .filter(entry -> !isEmptyObject(entry.getValue()))
                .collect(ObjectNode.collect(Map.Entry::getKey, Map.Entry::getValue));

        // Remove the "components" key from the model if it's empty.
        return updatedComponents.isEmpty()
                ? node.withoutMember(COMPONENTS)
                : node.withMember(COMPONENTS, updatedComponents);
    }
Removes empty key-value pairs in the "components" of a model if empty, and
removes the "components" key-value pair of a model if it is empty.
smithy-openapi/src/main/java/software/amazon/smithy/openapi/fromsmithy/mappers/RemoveEmptyComponents.java