@CheckForNull
    @Restricted(NoExternalUse.class) // for testing only
    public Node toYaml(CNode config) throws ConfiguratorException {

        if (config == null) {
            return null;
        }

        switch (config.getType()) {
            case MAPPING:
                final Mapping mapping = config.asMapping();
                final List<NodeTuple> tuples = new ArrayList<>();
                final List<Map.Entry<String, CNode>> entries = new ArrayList<>(mapping.entrySet());
                entries.sort(Map.Entry.comparingByKey());
                for (Map.Entry<String, CNode> entry : entries) {
                    final Node valueNode = toYaml(entry.getValue());
                    if (valueNode == null) {
                        continue;
                    }
                    tuples.add(new NodeTuple(new ScalarNode(Tag.STR, entry.getKey(), null, null, PLAIN), valueNode));
                }
                if (tuples.isEmpty()) {
                    return null;
                }

                return new MappingNode(Tag.MAP, tuples, BLOCK);

            case SEQUENCE:
                final Sequence sequence = config.asSequence();
                List<Node> nodes = new ArrayList<>();
                for (CNode cNode : sequence) {
                    final Node valueNode = toYaml(cNode);
                    if (valueNode == null) {
                        continue;
                    }
                    nodes.add(valueNode);
                }
                if (nodes.isEmpty()) {
                    return null;
                }
                return new SequenceNode(Tag.SEQ, nodes, BLOCK);

            case SCALAR:
            default:
                final Scalar scalar = config.asScalar();
                final String value = scalar.getValue();
                if (StringUtils.isBlank(value) && !scalar.isPrintableWhenEmpty()) {
                    return null;
                }

                final DumperOptions.ScalarStyle style;
                if (scalar.getFormat().equals(Format.MULTILINESTRING) && !scalar.isRaw()) {
                    style = LITERAL;
                } else if (scalar.isRaw()) {
                    style = PLAIN;
                } else {
                    style = DOUBLE_QUOTED;
                }

                return new ScalarNode(getTag(scalar.getFormat()), value, null, null, style);
        }
    }
Export JSONSchema to URL
@throws Exception
plugin/src/main/java/io/jenkins/plugins/casc/ConfigurationAsCode.java