From 09c7d0c758253b83d15933114fd0829d66db4276 Mon Sep 17 00:00:00 2001 From: Debasish Bose Date: Sun, 1 Nov 2026 13:16:17 +1100 Subject: [PATCH] canvas: expose erwin XML in the Export menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The erwin exporter shipped CLI-only (mdl export erwin); the canvas Export dropdown — where users actually export — didn't offer it, so the feature wasn't discoverable in the UI. The menu is data-driven (it renders whatever GET /api/export returns), so the fix is server side: add erwin to the advertised format list and to the /api/export/{fmt} dispatch (using the project's export.erwin.naming config, same as the CLI; application/xml, .xml filename). No canvas rebuild needed — the existing bundle picks it up from the API. Verified live: 'erwin XML' now appears in the Export dropdown and downloads an XSD-valid document (.xml). Tests: /api/export lists erwin; /api/export/erwin returns an XML attachment. Server suite 233 passed. --- packages/server/src/mdl_server/app.py | 7 ++++++- packages/server/tests/test_import_export_api.py | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/server/src/mdl_server/app.py b/packages/server/src/mdl_server/app.py index a8fba80..6add840 100644 --- a/packages/server/src/mdl_server/app.py +++ b/packages/server/src/mdl_server/app.py @@ -214,7 +214,7 @@ def export_model(fmt: str, dialect: str = "postgres"): """Export the model to an interchange format. Returns text/plain (or CSV) so the browser can offer it as a download.""" from fastapi.responses import PlainTextResponse - from mdl_emit_erd import emit_csv, emit_dbml, emit_mermaid, emit_sql_ddl + from mdl_emit_erd import emit_csv, emit_dbml, emit_erwin, emit_mermaid, emit_sql_ddl model = _load().model try: @@ -224,6 +224,10 @@ def export_model(fmt: str, dialect: str = "postgres"): text, media, ext = emit_mermaid(model), "text/plain", "mmd" elif fmt == "dbml": text, media, ext = emit_dbml(model), "text/plain", "dbml" + elif fmt == "erwin": + # the team naming convention (if any) travels in the project config, same as the CLI + text = emit_erwin(model, naming=model.config.export.erwin.naming) + media, ext = "application/xml", "xml" elif fmt == "csv": text, media, ext = emit_csv(model), "text/csv", "csv" elif fmt == "contract": @@ -260,6 +264,7 @@ def export_formats() -> JSONResponse: }, {"id": "mermaid", "label": "Mermaid erDiagram"}, {"id": "dbml", "label": "DBML (dbdiagram.io)"}, + {"id": "erwin", "label": "erwin XML"}, {"id": "csv", "label": "CSV (spreadsheet)"}, {"id": "contract", "label": "Data contract (ODCS)"}, {"id": "cypher", "label": "Neo4j Cypher"}, diff --git a/packages/server/tests/test_import_export_api.py b/packages/server/tests/test_import_export_api.py index c2c0ae7..acf216b 100644 --- a/packages/server/tests/test_import_export_api.py +++ b/packages/server/tests/test_import_export_api.py @@ -31,7 +31,18 @@ def client(model_dir): def test_export_formats_list(client): body = client.get("/api/export").json() ids = {f["id"] for f in body["formats"]} - assert {"sql", "mermaid", "dbml", "csv"} <= ids + assert {"sql", "mermaid", "dbml", "erwin", "csv"} <= ids + + +def test_export_erwin(client): + """The Export menu's erwin option serves a downloadable erwin XML document.""" + r = client.get("/api/export/erwin") + assert r.status_code == 200 + assert r.headers["content-type"].startswith("application/xml") + assert 'filename="' in r.headers["content-disposition"] and ".xml" in ( + r.headers["content-disposition"] + ) + assert r.text.lstrip().startswith("