mirror of
https://github.com/suitenumerique/docs.git
synced 2026-09-06 09:47:52 +02:00
⬆️(backend) upgrade docspec to v3.0.0 and adapt converter API
Summary - Bump docspec Docker image from `2.6.3` to `3.0.0` and adapt `DocSpecConverter` to the new API (raw body upload with explicit `Content-Type`/`Accept` headers instead of multipart form) Important **The Docker image (`ghcr.io/docspecio/api:3.0.0`) must be updated alongside the code changes.** The new request format is incompatible with v2.x — deploying only the code without updating the image (or vice versa) will break document conversion.
This commit is contained in:
@@ -49,7 +49,7 @@ class Converter:
|
||||
|
||||
if content_type == mime_types.DOCX and accept == mime_types.YJS:
|
||||
blocknote_data = self.docspec.convert(
|
||||
data, mime_types.DOCX, mime_types.BLOCKNOTE
|
||||
data, content_type, mime_types.BLOCKNOTE
|
||||
)
|
||||
return self.ydoc.convert(
|
||||
blocknote_data, mime_types.BLOCKNOTE, mime_types.YJS
|
||||
@@ -66,8 +66,11 @@ class DocSpecConverter:
|
||||
|
||||
response = requests.post(
|
||||
url,
|
||||
headers={"Accept": mime_types.BLOCKNOTE},
|
||||
files={"file": ("document.docx", data, content_type)},
|
||||
headers={
|
||||
"Content-Type": content_type,
|
||||
"Accept": mime_types.BLOCKNOTE,
|
||||
},
|
||||
data=data,
|
||||
timeout=settings.CONVERSION_API_TIMEOUT,
|
||||
verify=settings.CONVERSION_API_SECURE,
|
||||
)
|
||||
|
||||
@@ -110,8 +110,11 @@ def test_docspec_convert_success(mock_post, settings):
|
||||
# Verify the request was made correctly
|
||||
mock_post.assert_called_once_with(
|
||||
"http://docspec.test/convert",
|
||||
headers={"Accept": mime_types.BLOCKNOTE},
|
||||
files={"file": ("document.docx", docx_data, mime_types.DOCX)},
|
||||
headers={
|
||||
"Content-Type": mime_types.DOCX,
|
||||
"Accept": mime_types.BLOCKNOTE,
|
||||
},
|
||||
data=docx_data,
|
||||
timeout=5,
|
||||
verify=False,
|
||||
)
|
||||
|
||||
@@ -178,7 +178,7 @@ docSpec:
|
||||
image:
|
||||
repository: ghcr.io/docspecio/api
|
||||
pullPolicy: IfNotPresent
|
||||
tag: "2.6.3"
|
||||
tag: "3.0.1"
|
||||
|
||||
probes:
|
||||
liveness:
|
||||
|
||||
@@ -154,7 +154,7 @@ docSpec:
|
||||
image:
|
||||
repository: ghcr.io/docspecio/api
|
||||
pullPolicy: IfNotPresent
|
||||
tag: "2.6.3"
|
||||
tag: "3.0.1"
|
||||
|
||||
probes:
|
||||
liveness:
|
||||
|
||||
@@ -768,7 +768,7 @@ docSpec:
|
||||
image:
|
||||
repository: ghcr.io/docspecio/api
|
||||
pullPolicy: IfNotPresent
|
||||
tag: "2.6.3"
|
||||
tag: "3.0.1"
|
||||
|
||||
## @param docSpec.command Override the docSpec container command
|
||||
command: []
|
||||
|
||||
Reference in New Issue
Block a user