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

davsclaus pushed a commit to branch feat/camel-tui
in repository https://gitbox.apache.org/repos/asf/camel.git

commit d34b092b15f50bda025d21cc5afe8cd35fa1237d
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon May 18 10:38:15 2026 +0200

    TUI: HTTP tab - expose REST routeId and specification flag in JSON and TUI
    
    Fix DefaultRestRegistry dropping routeId that was passed to addRestService()
    but never stored in RestServiceEntry. Add getRouteId() to 
RestRegistry.RestService
    interface. Emit routeId and specification fields in RestDevConsole JSON 
output.
    TUI HTTP tab now shows API specification endpoints in magenta with "API 
Spec"
    source label, displays Route ID in detail panel, and separates REST/Spec 
counts
    in the server info row.
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---
 .../camel/component/rest/DefaultRestRegistry.java  | 14 ++++++++++----
 .../java/org/apache/camel/spi/RestRegistry.java    |  8 ++++++++
 .../apache/camel/impl/console/RestDevConsole.java  |  4 ++++
 .../dsl/jbang/core/commands/tui/CamelMonitor.java  | 22 ++++++++++++++++++++--
 4 files changed, 42 insertions(+), 6 deletions(-)

diff --git 
a/components/camel-rest/src/main/java/org/apache/camel/component/rest/DefaultRestRegistry.java
 
b/components/camel-rest/src/main/java/org/apache/camel/component/rest/DefaultRestRegistry.java
index 8d50ad31c8b6..9a33bb386ca0 100644
--- 
a/components/camel-rest/src/main/java/org/apache/camel/component/rest/DefaultRestRegistry.java
+++ 
b/components/camel-rest/src/main/java/org/apache/camel/component/rest/DefaultRestRegistry.java
@@ -53,8 +53,7 @@ public class DefaultRestRegistry extends ServiceSupport 
implements RestRegistry,
             String consumes, String produces, String inType, String outType, 
String routeId, String description) {
         RestServiceEntry entry = new RestServiceEntry(
                 consumer, false, contractFirst, url, baseUrl, basePath, 
uriTemplate, method, consumes, produces, inType,
-                outType,
-                description);
+                outType, routeId, description);
         List<RestService> list = registry.computeIfAbsent(consumer, c -> new 
ArrayList<>());
         list.add(entry);
     }
@@ -64,7 +63,7 @@ public class DefaultRestRegistry extends ServiceSupport 
implements RestRegistry,
             Consumer consumer, boolean contractFirst, String url, String 
baseUrl, String basePath, String method,
             String produces, String description) {
         RestServiceEntry entry = new RestServiceEntry(
-                consumer, true, contractFirst, url, baseUrl, basePath, null, 
method, null, produces, null, null,
+                consumer, true, contractFirst, url, baseUrl, basePath, null, 
method, null, produces, null, null, null,
                 description);
         List<RestService> list = specs.computeIfAbsent(consumer, c -> new 
ArrayList<>());
         list.add(entry);
@@ -203,12 +202,13 @@ public class DefaultRestRegistry extends ServiceSupport 
implements RestRegistry,
         private final String produces;
         private final String inType;
         private final String outType;
+        private final String routeId;
         private final String description;
 
         private RestServiceEntry(Consumer consumer, boolean specification, 
boolean contractFirst, String url, String baseUrl,
                                  String basePath,
                                  String uriTemplate, String method, String 
consumes, String produces,
-                                 String inType, String outType, String 
description) {
+                                 String inType, String outType, String 
routeId, String description) {
             this.consumer = consumer;
             this.specification = specification;
             this.contractFirst = contractFirst;
@@ -221,6 +221,7 @@ public class DefaultRestRegistry extends ServiceSupport 
implements RestRegistry,
             this.produces = produces;
             this.inType = inType;
             this.outType = outType;
+            this.routeId = routeId;
             this.description = description;
         }
 
@@ -298,6 +299,11 @@ public class DefaultRestRegistry extends ServiceSupport 
implements RestRegistry,
             return status.name();
         }
 
+        @Override
+        public String getRouteId() {
+            return routeId;
+        }
+
         @Override
         public String getDescription() {
             return description;
diff --git 
a/core/camel-api/src/main/java/org/apache/camel/spi/RestRegistry.java 
b/core/camel-api/src/main/java/org/apache/camel/spi/RestRegistry.java
index 1b3d774153f2..a812401b6e95 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/RestRegistry.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestRegistry.java
@@ -53,6 +53,14 @@ public interface RestRegistry extends StaticService {
          */
         String getState();
 
+        /**
+         * Gets the route id that this REST service is using
+         *
+         * @since 4.21
+         */
+        @Nullable
+        String getRouteId();
+
         /**
          * Gets the absolute url to the REST service (baseUrl + uriTemplate)
          */
diff --git 
a/core/camel-console/src/main/java/org/apache/camel/impl/console/RestDevConsole.java
 
b/core/camel-console/src/main/java/org/apache/camel/impl/console/RestDevConsole.java
index d233f1abfab3..bb912ecfa374 100644
--- 
a/core/camel-console/src/main/java/org/apache/camel/impl/console/RestDevConsole.java
+++ 
b/core/camel-console/src/main/java/org/apache/camel/impl/console/RestDevConsole.java
@@ -91,7 +91,11 @@ public class RestDevConsole extends AbstractDevConsole {
                 jo.put("url", rs.getUrl());
                 jo.put("method", rs.getMethod());
                 jo.put("contractFirst", rs.isContractFirst());
+                jo.put("specification", rs.isSpecification());
                 jo.put("state", rs.getState());
+                if (rs.getRouteId() != null) {
+                    jo.put("routeId", rs.getRouteId());
+                }
                 if (rs.getConsumes() != null) {
                     jo.put("consumes", rs.getConsumes());
                 }
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java
index a3f5798a1bc0..0dc6c7f1242d 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java
@@ -3547,13 +3547,18 @@ public class CamelMonitor extends CamelCommand {
             spans.add(Span.styled(info.httpServer, 
Style.EMPTY.fg(Color.CYAN)));
             spans.add(Span.raw("    "));
         }
-        long restCount = info.httpEndpoints.stream().filter(e -> 
e.fromRest).count();
+        long restCount = info.httpEndpoints.stream().filter(e -> e.fromRest && 
!e.specification).count();
+        long specCount = info.httpEndpoints.stream().filter(e -> 
e.specification).count();
         long httpCount = info.httpEndpoints.stream().filter(e -> !e.fromRest 
&& !e.management).count();
         long mgmtCount = info.httpEndpoints.stream().filter(e -> 
e.management).count();
         if (restCount > 0) {
             spans.add(Span.styled("REST: ", Style.EMPTY.fg(Color.GREEN)));
             spans.add(Span.raw(restCount + "  "));
         }
+        if (specCount > 0) {
+            spans.add(Span.styled("Spec: ", Style.EMPTY.fg(Color.MAGENTA)));
+            spans.add(Span.raw(specCount + "  "));
+        }
         if (httpCount > 0) {
             spans.add(Span.styled("HTTP: ", Style.EMPTY.fg(Color.CYAN)));
             spans.add(Span.raw(httpCount + "  "));
@@ -3591,6 +3596,8 @@ public class CamelMonitor extends CamelCommand {
             String source;
             if (ep.management) {
                 source = "Mgmt";
+            } else if (ep.specification) {
+                source = "API Spec";
             } else if (ep.fromRest) {
                 source = ep.contractFirst ? "REST(contract)" : "REST(code)";
             } else {
@@ -3603,7 +3610,9 @@ public class CamelMonitor extends CamelCommand {
                     Cell.from(consumes),
                     Cell.from(produces),
                     Cell.from(Span.styled(source,
-                            ep.fromRest ? Style.EMPTY.fg(Color.GREEN) : 
Style.EMPTY.fg(Color.CYAN))),
+                            ep.specification ? Style.EMPTY.fg(Color.MAGENTA)
+                                    : ep.fromRest ? Style.EMPTY.fg(Color.GREEN)
+                                    : Style.EMPTY.fg(Color.CYAN))),
                     Cell.from(Span.styled(state,
                             "Stopped".equals(state) ? 
Style.EMPTY.fg(Color.LIGHT_RED) : Style.EMPTY))));
         }
@@ -3670,12 +3679,17 @@ public class CamelMonitor extends CamelCommand {
         String sourceStr;
         if (ep.management) {
             sourceStr = "Platform-HTTP (management)";
+        } else if (ep.specification) {
+            sourceStr = "REST DSL (API specification - " + (ep.contractFirst ? 
"contract-first" : "code-first") + ")";
         } else if (ep.fromRest) {
             sourceStr = "REST DSL (" + (ep.contractFirst ? "contract-first" : 
"code-first") + ")";
         } else {
             sourceStr = "Platform-HTTP";
         }
         addDetailLine(lines, "Source", sourceStr);
+        if (ep.routeId != null) {
+            addDetailLine(lines, "Route", ep.routeId);
+        }
         if (ep.state != null) {
             addDetailLine(lines, "State", ep.state);
         }
@@ -5403,6 +5417,8 @@ public class CamelMonitor extends CamelCommand {
                     ep.produces = rj.getString("produces");
                     ep.description = rj.getString("description");
                     ep.contractFirst = 
Boolean.TRUE.equals(rj.get("contractFirst"));
+                    ep.specification = 
Boolean.TRUE.equals(rj.get("specification"));
+                    ep.routeId = rj.getString("routeId");
                     ep.state = rj.getString("state");
                     ep.inType = rj.getString("inType");
                     ep.outType = rj.getString("outType");
@@ -5741,6 +5757,8 @@ public class CamelMonitor extends CamelCommand {
         // REST DSL only
         boolean fromRest;
         boolean contractFirst;
+        boolean specification; // true = OpenAPI/Swagger spec endpoint
+        String routeId;
         String description;
         String inType;
         String outType;

Reply via email to