From 87b188533eb5bc1a789a2503899759fb47039dfa Mon Sep 17 00:00:00 2001 From: Arpan Chakraborty Date: Wed, 18 Mar 2026 22:53:52 +0530 Subject: [PATCH] docs: update README.md in context of #206 Signed-off-by: Arpan Chakraborty --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 36fc0754..d7c26494 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ For example: import ai.docling.serve.api.DoclingServeApi; import ai.docling.serve.api.convert.request.ConvertDocumentRequest; import ai.docling.serve.api.convert.request.source.HttpSource; -import ai.docling.serve.api.convert.response.ConvertDocumentResponse; +import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse; DoclingServeApi doclingServeApi = DoclingServeApi.builder() .baseUrl("") @@ -67,10 +67,25 @@ ConvertDocumentRequest request = ConvertDocumentRequest.builder() ) .build(); -ConvertDocumentResponse response = doclingServeApi.convertSource(request); +InBodyConvertDocumentResponse response = (InBodyConvertDocumentResponse) doclingServeApi.convertSource(request); System.out.println(response.getDocument().getMarkdownContent()); ``` +If you're unsure of the concrete type returned by the convert API, you can handle it dynamically using the `getResponseType()` method: + +```java +import ai.docling.serve.api.convert.response.ResponseType; + +// ... your code to create and configure the request ... + +var result = doclingServeApi.convertSource(request); + +switch(result.getResponseType()) { + case ResponseType.IN_BODY -> // Response is InBodyConvertDocumentResponse + case ResponseType.ZIP_ARCHIVE -> // Response is ZipArchiveConvertDocumentResponse + case ResponseType.PRE_SIGNED_URL -> // Response is PreSignedUrlConvertDocumentResponse +} +``` More [usage information](https://docling-project.github.io/docling-java) is available in the docs. ## Get help and support