You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/05/21 07:06:56 UTC

(camel) branch worktree-CAMEL-23593-normalize-rest-routeconfig created (now 9bb70213d6b6)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch worktree-CAMEL-23593-normalize-rest-routeconfig
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 9bb70213d6b6 CAMEL-23593: camel-yaml-io - Fix YAML dump for REST DSL and routeConfigurations

This branch includes the following new commits:

     new 9bb70213d6b6 CAMEL-23593: camel-yaml-io - Fix YAML dump for REST DSL and routeConfigurations

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(camel) 01/01: CAMEL-23593: camel-yaml-io - Fix YAML dump for REST DSL and routeConfigurations

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch worktree-CAMEL-23593-normalize-rest-routeconfig
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9bb70213d6b67b6680448eb4dff7cbe6391d35f5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu May 21 09:06:36 2026 +0200

    CAMEL-23593: camel-yaml-io - Fix YAML dump for REST DSL and routeConfigurations
    
    The YamlWriter only special-cased "routes" and "dataFormats" as root
    container elements. When dumping REST DSL or routeConfiguration blocks,
    startElement/endElement fell through to the EipModel lookup path,
    producing empty objects like "rests: {}" or "routeConfigurations: {}".
    
    Add "rests" and "routeConfigurations" to the container name checks in
    both startElement() and endElement(), and fix NPE in the normalize
    command by wiring up the MavenResolverMixin.
    
    Co-Authored-By: Claude <no...@anthropic.com>
---
 .../src/main/java/org/apache/camel/yaml/io/YamlWriter.java        | 8 ++++----
 .../dsl/jbang/core/commands/validate/YamlNormalizeCommand.java    | 5 +++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java
index e9cf74145946..715128aa5e8c 100644
--- a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java
+++ b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java
@@ -106,8 +106,8 @@ public class YamlWriter extends ServiceSupport implements CamelContextAware {
     }
 
     public void startElement(String name) throws IOException {
-        if ("routes".equals(name) || "dataFormats".equals(name)) {
-            // special for routes or dataFormats
+        if ("routes".equals(name) || "rests".equals(name) || "routeConfigurations".equals(name)
+                || "dataFormats".equals(name)) {
             routesIsRoot = true;
             return;
         }
@@ -138,8 +138,8 @@ public class YamlWriter extends ServiceSupport implements CamelContextAware {
     }
 
     public void endElement(String name) throws IOException {
-        if ("routes".equals(name) || "dataFormats".equals(name)) {
-            // we are done
+        if ("routes".equals(name) || "rests".equals(name) || "routeConfigurations".equals(name)
+                || "dataFormats".equals(name)) {
             writer.write(toYaml());
             return;
         }
diff --git a/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlNormalizeCommand.java b/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlNormalizeCommand.java
index 9281ccfafd59..8e569c2eed00 100644
--- a/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlNormalizeCommand.java
+++ b/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlNormalizeCommand.java
@@ -26,6 +26,7 @@ import java.util.Stack;
 
 import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.MavenResolverMixin;
 import org.apache.camel.dsl.jbang.core.commands.Run;
 import org.apache.camel.dsl.jbang.core.common.CamelJBangConstants;
 import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
@@ -41,6 +42,9 @@ public class YamlNormalizeCommand extends CamelCommand {
 
     private static final String IGNORE_FILE = "application";
 
+    @CommandLine.Mixin
+    MavenResolverMixin mavenResolver;
+
     @CommandLine.Option(names = { "--output" },
                         description = "File or directory to write normalized output. If not specified, output is printed to console.")
     private String output;
@@ -86,6 +90,7 @@ public class YamlNormalizeCommand extends CamelCommand {
                 main.addInitialProperty("camel.language.bean.validate", "false");
             }
         };
+        run.mavenResolver = mavenResolver;
         run.files = matched;
         run.executionLimitOptions.maxSeconds = 1;
         Integer exit = run.runTransform(true);