This is an automated email from the ASF dual-hosted git repository.
Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git
The following commit(s) were added to refs/heads/main by this push:
new 86b6586d Fix docling example metadata extraction writing invalid JSON
86b6586d is described below
commit 86b6586da9506134eabc5bf5864d983000d5e643
Author: croway <[email protected]>
AuthorDate: Thu Sep 3 19:24:02 2026 +0200
Fix docling example metadata extraction writing invalid JSON
The document-metadata-extractor route used docling:EXTRACT_STRUCTURED_DATA
as the endpoint URI path, but camel-docling only dispatches on the
"operation" query parameter (or the CamelDoclingOperation header) - the
URI path segment is descriptive only. Without it, the endpoint silently
fell back to its CONVERT_TO_MARKDOWN default, so the "metadata" route was
actually just converting to markdown and writing it into a .json file.
Also add the missing operation query parameter, and marshal the
DoclingDocument result to JSON explicitly (EXTRACT_STRUCTURED_DATA returns
a structured object, not JSON text, and camel-docling has no built-in
type converter for it), via camel-jackson.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hs6c6LpuL8ZZ3gaSXwt7CS
---
docling/pom.xml | 4 ++++
.../apache/camel/example/springboot/docling/DoclingServeRoute.java | 6 ++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/docling/pom.xml b/docling/pom.xml
index d38db59f..f6ce0648 100644
--- a/docling/pom.xml
+++ b/docling/pom.xml
@@ -79,6 +79,10 @@
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-file-starter</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>camel-jackson-starter</artifactId>
+ </dependency>
<!-- test -->
<dependency>
diff --git
a/docling/src/main/java/org/apache/camel/example/springboot/docling/DoclingServeRoute.java
b/docling/src/main/java/org/apache/camel/example/springboot/docling/DoclingServeRoute.java
index bfa27ab7..569aaec1 100644
---
a/docling/src/main/java/org/apache/camel/example/springboot/docling/DoclingServeRoute.java
+++
b/docling/src/main/java/org/apache/camel/example/springboot/docling/DoclingServeRoute.java
@@ -17,6 +17,7 @@
package org.apache.camel.example.springboot.docling;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.dataformat.JsonLibrary;
import org.springframework.stereotype.Component;
@Component
@@ -28,7 +29,7 @@ public class DoclingServeRoute extends RouteBuilder {
from("file:{{documents.directory}}?delete=true&include=.*\\.(pdf|docx|pptx|html|md)$")
.routeId("document-to-markdown-converter")
.log("Processing document: ${header.CamelFileName}")
-
.to("docling:CONVERT_TO_MARKDOWN?useDoclingServe=true&doclingServeUrl={{docling.serve.url}}&contentInBody=true")
+
.to("docling:convert-to-markdown?operation=CONVERT_TO_MARKDOWN&useDoclingServe=true&doclingServeUrl={{docling.serve.url}}&contentInBody=true")
.log("Document converted to Markdown: ${header.CamelFileName}")
.setHeader("CamelFileName", simple("${file:name.noext}.md"))
.to("file:{{output.directory}}")
@@ -37,7 +38,8 @@ public class DoclingServeRoute extends RouteBuilder {
from("file:{{documents.directory}}/extract?delete=true&include=.*\\.(pdf|docx|pptx)$")
.routeId("document-metadata-extractor")
.log("Extracting metadata from: ${header.CamelFileName}")
-
.to("docling:EXTRACT_STRUCTURED_DATA?useDoclingServe=true&doclingServeUrl={{docling.serve.url}}&outputFormat=json&contentInBody=true")
+
.to("docling:extract-structured-data?operation=EXTRACT_STRUCTURED_DATA&useDoclingServe=true&doclingServeUrl={{docling.serve.url}}&contentInBody=true")
+ .marshal().json(JsonLibrary.Jackson)
.log("Metadata extracted from: ${header.CamelFileName}")
.setHeader("CamelFileName", simple("${file:name.noext}.json"))
.to("file:{{output.directory}}/metadata")