-
Notifications
You must be signed in to change notification settings - Fork 20
feat(api): support /v1/convert/source/batch endpoint #545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
edeandrea
merged 1 commit into
docling-project:main
from
edeandrea:feat/batch-convert-endpoint
Jun 15, 2026
+569
−6
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...e-api/src/main/java/ai/docling/serve/api/convert/request/BatchConvertDocumentRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| package ai.docling.serve.api.convert.request; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.annotation.JsonSetter; | ||
| import com.fasterxml.jackson.annotation.Nulls; | ||
|
|
||
| import ai.docling.serve.api.convert.request.options.ConvertDocumentOptions; | ||
| import ai.docling.serve.api.convert.request.source.Source; | ||
| import ai.docling.serve.api.convert.request.target.Target; | ||
|
|
||
| /** | ||
| * Represents a request to batch convert document sources. The batch endpoint processes multiple | ||
| * documents asynchronously and returns a task ID for tracking progress. Sources can be HTTP URLs | ||
| * or S3 buckets, and results are delivered to a presigned URL or S3 target. | ||
| * | ||
| * <p>This class is serialized into JSON to conform to the API specification using | ||
| * {@link JsonProperty} annotations. Fields with {@code null} values or empty collections | ||
| * are omitted from the serialized JSON using {@link JsonInclude}. | ||
| */ | ||
| @JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
| @tools.jackson.databind.annotation.JsonDeserialize(builder = BatchConvertDocumentRequest.Builder.class) | ||
| @lombok.extern.jackson.Jacksonized | ||
| @lombok.Builder(toBuilder = true) | ||
| @lombok.Getter | ||
| @lombok.ToString | ||
| public class BatchConvertDocumentRequest { | ||
| /** | ||
| * List of document sources to be converted. | ||
| * Each source can be an HTTP URL or S3 reference. | ||
| * | ||
| * @param sources the list of document sources | ||
| * @return the list of document sources | ||
| */ | ||
| @JsonProperty("sources") | ||
| @JsonSetter(nulls = Nulls.AS_EMPTY) | ||
| @lombok.Singular | ||
| private List<Source> sources; | ||
|
|
||
| /** | ||
| * Target specification for where the converted documents should be delivered. | ||
| * Must be either a {@link ai.docling.serve.api.convert.request.target.PresignedUrlTarget} | ||
| * or {@link ai.docling.serve.api.convert.request.target.S3Target}. | ||
| * | ||
| * @param target the output target | ||
| * @return the output target | ||
| */ | ||
| @JsonProperty("target") | ||
| @lombok.NonNull | ||
| private Target target; | ||
|
|
||
| /** | ||
| * Options controlling the document conversion process. | ||
| * Includes settings for OCR, output formats, processing pipelines, and more. | ||
| * | ||
| * @param options the conversion options | ||
| * @return the conversion options | ||
| */ | ||
| @JsonProperty("options") | ||
| @lombok.NonNull | ||
| @lombok.Builder.Default | ||
| private ConvertDocumentOptions options = ConvertDocumentOptions.builder().build(); | ||
|
|
||
| /** | ||
| * Webhook callbacks for receiving progress notifications during batch processing. | ||
| * | ||
| * @param callbacks the list of callback specifications | ||
| * @return the list of callback specifications | ||
| */ | ||
| @JsonProperty("callbacks") | ||
| @JsonSetter(nulls = Nulls.AS_EMPTY) | ||
| @lombok.Singular | ||
| private List<CallbackSpec> callbacks; | ||
|
|
||
| /** | ||
| * Builder for creating {@link BatchConvertDocumentRequest} instances. | ||
| * Generated by Lombok's {@code @Builder} annotation. | ||
| * | ||
| * <p>Builder methods: | ||
| * <ul> | ||
| * <li>{@code source(Source)} - Add a single document source</li> | ||
| * <li>{@code sources(List<Source>)} - Set the list of document sources</li> | ||
| * <li>{@code target(Target)} - Set the output target</li> | ||
| * <li>{@code options(ConvertDocumentOptions)} - Set the conversion options</li> | ||
| * <li>{@code callback(CallbackSpec)} - Add a single callback specification</li> | ||
| * <li>{@code callbacks(List<CallbackSpec>)} - Set the list of callback specifications</li> | ||
| * </ul> | ||
| */ | ||
| @tools.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") | ||
| public static class Builder { } | ||
| } |
58 changes: 58 additions & 0 deletions
58
...ve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/CallbackSpec.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package ai.docling.serve.api.convert.request; | ||
|
|
||
| import java.net.URI; | ||
| import java.util.Map; | ||
|
|
||
| import org.jspecify.annotations.Nullable; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.annotation.JsonSetter; | ||
| import com.fasterxml.jackson.annotation.Nulls; | ||
|
|
||
| /** | ||
| * Represents a webhook callback specification for batch conversion progress notifications. | ||
| * When configured, the server sends POST requests to the specified URL with progress updates | ||
| * as documents are processed. | ||
| */ | ||
| @JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
| @tools.jackson.databind.annotation.JsonDeserialize(builder = CallbackSpec.Builder.class) | ||
| @lombok.extern.jackson.Jacksonized | ||
| @lombok.Builder(toBuilder = true) | ||
| @lombok.Getter | ||
| @lombok.ToString | ||
| public class CallbackSpec { | ||
| /** | ||
| * The webhook URL that receives POST progress updates. | ||
| * | ||
| * @param url the webhook URL | ||
| * @return the webhook URL | ||
| */ | ||
| @JsonProperty("url") | ||
| @lombok.NonNull | ||
| private URI url; | ||
|
|
||
| /** | ||
| * Additional headers sent with callback requests. | ||
| * | ||
| * @param headers the additional headers | ||
| * @return the additional headers | ||
| */ | ||
| @JsonProperty("headers") | ||
| @JsonSetter(nulls = Nulls.AS_EMPTY) | ||
| @lombok.Singular | ||
| private Map<String, Object> headers; | ||
|
|
||
| /** | ||
| * Custom CA certificate (PEM) for endpoint verification. | ||
| * | ||
| * @param caCert the CA certificate in PEM format | ||
| * @return the CA certificate in PEM format | ||
| */ | ||
| @JsonProperty("ca_cert") | ||
| @Nullable | ||
| private String caCert; | ||
|
|
||
| @tools.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") | ||
| public static class Builder { } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ava/ai/docling/serve/api/serialization/Jackson2ValidationErrorDetailListDeserializer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package ai.docling.serve.api.serialization; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonParser; | ||
| import com.fasterxml.jackson.core.JsonToken; | ||
| import com.fasterxml.jackson.databind.DeserializationContext; | ||
| import com.fasterxml.jackson.databind.JsonDeserializer; | ||
|
|
||
| import ai.docling.serve.api.validation.ValidationErrorDetail; | ||
|
|
||
| public class Jackson2ValidationErrorDetailListDeserializer extends JsonDeserializer<List<ValidationErrorDetail>> { | ||
|
|
||
| @Override | ||
| public List<ValidationErrorDetail> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { | ||
| if (p.currentToken() == JsonToken.VALUE_STRING) { | ||
| return List.of(ValidationErrorDetail.builder().message(p.getText()).build()); | ||
| } | ||
|
|
||
| var type = ctxt.getTypeFactory().constructCollectionType(List.class, ValidationErrorDetail.class); | ||
| return ctxt.readValue(p, type); | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
...ava/ai/docling/serve/api/serialization/Jackson3ValidationErrorDetailListDeserializer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package ai.docling.serve.api.serialization; | ||
|
|
||
| import tools.jackson.core.JacksonException; | ||
| import tools.jackson.core.JsonParser; | ||
| import tools.jackson.core.JsonToken; | ||
| import tools.jackson.databind.DeserializationContext; | ||
| import tools.jackson.databind.ValueDeserializer; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import ai.docling.serve.api.validation.ValidationErrorDetail; | ||
|
|
||
| public class Jackson3ValidationErrorDetailListDeserializer extends ValueDeserializer<List<ValidationErrorDetail>> { | ||
|
|
||
| @Override | ||
| public List<ValidationErrorDetail> deserialize(JsonParser p, DeserializationContext ctxt) throws JacksonException { | ||
| if (p.currentToken() == JsonToken.VALUE_STRING) { | ||
| return List.of(ValidationErrorDetail.builder().message(p.getText()).build()); | ||
| } | ||
|
|
||
| var type = ctxt.getTypeFactory().constructCollectionType(List.class, ValidationErrorDetail.class); | ||
| return ctxt.readValue(p, type); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.