Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface DoclingServeConvertApi {
* Converts the provided document source(s) into a processed document based on the specified options.
*
* @param request the {@link ConvertDocumentRequest} containing the source(s), conversion options, and optional target.
* @return a {@link ConvertDocumentResponse} containing the processed document data, processing details, and any errors.
* @return a {@link ConvertDocumentResponse} describing the convert document response.
* @throws ai.docling.serve.api.validation.ValidationException If request validation fails for any reason.
*/
ConvertDocumentResponse convertSource(ConvertDocumentRequest request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface DoclingServeTaskApi {
TaskStatusPollResponse pollTaskStatus(TaskStatusPollRequest request);

/**
* Converts the result of a completed task into a document format as specified in the request.
* Returns the result of a completed convert task.
*
* This method processes the task result identified by the unique task ID provided in
* the request, performs any necessary transformation, and returns a response
Expand Down
Original file line number Diff line number Diff line change
@@ -1,90 +1,34 @@
package ai.docling.serve.api.convert.response;

import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
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 com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

/**
* Response returned by the Convert API for a single conversion request.
* Abstract response returned by the Convert API for a single conversion request.
*
* <p>Serialization uses {@link JsonInclude.Include#NON_EMPTY}, so nulls and empty
* collections/strings are omitted from JSON output.</p>
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@tools.jackson.databind.annotation.JsonDeserialize(builder = ConvertDocumentResponse.Builder.class)
@lombok.extern.jackson.Jacksonized
@lombok.Builder(toBuilder = true)
@lombok.Getter
@lombok.ToString
public class ConvertDocumentResponse {
/**
* Converted document content.
*
* @param document the converted document
* @return the converted document
*/
@JsonProperty("document")
private DocumentResponse document;

@JsonTypeInfo(
use = JsonTypeInfo.Id.DEDUCTION
)
@JsonSubTypes({
@JsonSubTypes.Type(InBodyConvertDocumentResponse.class),
@JsonSubTypes.Type(PreSignedUrlConvertDocumentResponse.class),
@JsonSubTypes.Type(ZipArchiveConvertDocumentResponse.class)
})
public abstract sealed class ConvertDocumentResponse permits InBodyConvertDocumentResponse, PreSignedUrlConvertDocumentResponse,
ZipArchiveConvertDocumentResponse {
/**
* List of errors that occurred during conversion.
* Type of response
*
* @param errors the list of errors
* @return the list of errors
* @return the response type
*/
@JsonProperty("errors")
@JsonSetter(nulls = Nulls.AS_EMPTY)
@lombok.Singular
private List<ErrorItem> errors;
@JsonProperty("response_type")
public abstract ResponseType getResponseType();

/**
* Total processing time in seconds.
*
* @param processingTime the processing time in seconds
* @return the processing time in seconds
*/
@JsonProperty("processing_time")
private Double processingTime;

/**
* Conversion status (success, failure, partial_success, etc.).
*
* @param status the conversion status
* @return the conversion status
*/
@JsonProperty("status")
private String status;

/**
* Detailed timing information for processing stages.
*
* @param timings the map of timing information
* @return the map of timing information
*/
@JsonProperty("timings")
@JsonSetter(nulls = Nulls.AS_EMPTY)
@lombok.Singular
private Map<String, Object> timings;

/**
* Builder for creating {@link ConvertDocumentResponse} instances.
* Generated by Lombok's {@code @Builder} annotation.
*
* <p>Builder methods:
* <ul>
* <li>{@code document(DocumentResponse)} - Set the converted document</li>
* <li>{@code error(ErrorItem)} - Add a single error (use with @Singular)</li>
* <li>{@code errors(List<ErrorItem>)} - Set the list of errors</li>
* <li>{@code processingTime(Double)} - Set the processing time in seconds</li>
* <li>{@code status(String)} - Set the conversion status</li>
* <li>{@code timing(String, Object)} - Add a single timing entry (use with @Singular)</li>
* <li>{@code timings(Map<String, Object>)} - Set the map of timing information</li>
* </ul>
*/
@tools.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "")
public static class Builder { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package ai.docling.serve.api.convert.response;

import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;

/**
* Response for single document conversions with in-body content delivery.
*
* <p>This response type is returned when:</p>
* <ul>
* <li>The conversion request contains a single source file</li>
* <li>The target type is {@link ai.docling.serve.api.convert.request.target.InBodyTarget}</li>
* </ul>
*
* <p>The converted document content is included directly in the response body,
* along with conversion status, processing time, errors, and detailed timing
* information for each processing stage.</p>
*
* <p>Serialization uses {@link JsonInclude.Include#NON_EMPTY}, so nulls and empty
* collections/strings are omitted from JSON output.</p>
*
* @see ConvertDocumentResponse
* @see ResponseType#InBodyConvertDocumentResponse
* @see ai.docling.serve.api.convert.request.target.InBodyTarget
* @see DocumentResponse
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@tools.jackson.databind.annotation.JsonDeserialize(builder = InBodyConvertDocumentResponse.Builder.class)
@lombok.extern.jackson.Jacksonized
@lombok.Builder(toBuilder = true)
@lombok.Getter
@lombok.ToString
public final class InBodyConvertDocumentResponse extends ConvertDocumentResponse {
/**
* Converted document content.
*
* @param document the converted document
* @return the converted document
*/
@JsonProperty("document")
private DocumentResponse document;

/**
* List of errors that occurred during conversion.
*
* @param errors the list of errors
* @return the list of errors
*/
@JsonProperty("errors")
@JsonSetter(nulls = Nulls.AS_EMPTY)
@lombok.Singular
private List<ErrorItem> errors;

/**
* Total processing time in seconds.
*
* @param processingTime the processing time in seconds
* @return the processing time in seconds
*/
@JsonProperty("processing_time")
private Double processingTime;

/**
* Conversion status (success, failure, partial_success, etc.).
*
* @param status the conversion status
* @return the conversion status
*/
@JsonProperty("status")
private String status;

/**
* Detailed timing information for processing stages.
*
* @param timings the map of timing information
* @return the map of timing information
*/
@JsonProperty("timings")
@JsonSetter(nulls = Nulls.AS_EMPTY)
@lombok.Singular
private Map<String, Object> timings;

@Override
@lombok.ToString.Include
public ResponseType getResponseType() {
return ResponseType.InBodyConvertDocumentResponse;
}

/**
* Builder for creating {@link InBodyConvertDocumentResponse} instances.
* Generated by Lombok's {@code @Builder} annotation.
*
* <p>Builder methods:
* <ul>
* <li>{@code document(DocumentResponse)} - Set the converted document</li>
* <li>{@code error(ErrorItem)} - Add a single error (use with @Singular)</li>
* <li>{@code errors(List<ErrorItem>)} - Set the list of errors</li>
* <li>{@code processingTime(Double)} - Set the processing time in seconds</li>
* <li>{@code status(String)} - Set the conversion status</li>
* <li>{@code timing(String, Object)} - Add a single timing entry (use with @Singular)</li>
* <li>{@code timings(Map<String, Object>)} - Set the map of timing information</li>
* </ul>
*/
@tools.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "")
public static class Builder { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package ai.docling.serve.api.convert.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Response for document conversions with S3 or PUT target types.
*
* <p>This response type is returned when the conversion request specifies
* an S3 target or PUT target. The converted documents are stored in the
* specified location.
* The response includes processing statistics and conversion metrics.</p>
*
* <p>Use cases:</p>
* <ul>
* <li>Target type is {@link ai.docling.serve.api.convert.request.target.S3Target}</li>
* <li>Target type is {@link ai.docling.serve.api.convert.request.target.PutTarget}</li>
* </ul>
*
* <p>Serialization uses {@link JsonInclude.Include#NON_EMPTY}, so nulls and empty
* collections/strings are omitted from JSON output.</p>
*
* @see ConvertDocumentResponse
* @see ResponseType#PreSignedUrlConvertDocumentResponse
* @see ai.docling.serve.api.convert.request.target.S3Target
* @see ai.docling.serve.api.convert.request.target.PutTarget
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@tools.jackson.databind.annotation.JsonDeserialize(builder = PreSignedUrlConvertDocumentResponse.Builder.class)
@lombok.extern.jackson.Jacksonized
@lombok.Builder(toBuilder = true)
@lombok.Getter
@lombok.ToString
public final class PreSignedUrlConvertDocumentResponse extends ConvertDocumentResponse {

/**
* Total processing time in seconds.
*
* @param processingTime the processing time in seconds
* @return the processing time in seconds
*/
@JsonProperty("processing_time")
private Double processingTime;

/**
* Number of attempted conversions
*
* @param numSucceeded the number of attempted conversions
* @return the number of attempted conversions
*/
@JsonProperty("num_converted")
private Integer numConverted;

/**
* Number of successful conversions
*
* @param numSucceeded the number of successful conversions
* @return the number of successful conversions
*/
@JsonProperty("num_succeeded")
private Integer numSucceeded;

/**
* Number of failed conversions
*
* @param numSucceeded the number of failed conversions
* @return the number of failed conversions
*/
@JsonProperty("num_failed")
private Integer numFailed;

@Override
@lombok.ToString.Include
public ResponseType getResponseType() {
return ResponseType.PreSignedUrlConvertDocumentResponse;
}

/**
* Builder for creating {@link PreSignedUrlConvertDocumentResponse} instances.
* Generated by Lombok's {@code @Builder} annotation.
*
* <p>Builder methods:
* <ul>
* <li>{@code processingTime(Double)} - Set the processing time in seconds</li>
* <li>{@code numConverted(Integer)} - Set the number of successful conversions</li>
* <li>{@code numFailed(Integer)} - Set the number of failed conversions</li>
* <li>{@code numConverted(Integer)} - Set the number of attempted conversions</li>
* </ul>
*/
@tools.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "")
public static class Builder { }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ai.docling.serve.api.convert.response;

import com.fasterxml.jackson.annotation.JsonProperty;

public enum ResponseType {
@JsonProperty("in_body") InBodyConvertDocumentResponse,
@JsonProperty("zip_archive") ZipArchiveConvertDocumentResponse,
@JsonProperty("presigned_url") PreSignedUrlConvertDocumentResponse
}
Loading