From 81e52fb37c8e20ad381a2a43a443d06b0e3ad281 Mon Sep 17 00:00:00 2001 From: Eric Antones Date: Wed, 15 Jul 2026 09:39:49 +0200 Subject: [PATCH] [18.0][FIX] base_rest: do not crash the frontend boot outside the Swagger page swagger_ui.js rides web.assets_frontend_lazy, so its whenReady bootstrap runs on every frontend page. Outside the Swagger UI page document.getElementById("swagger-ui") is null and .getAttribute() throws a TypeError in the console on every page load (login included). Guard the bootstrap so it only mounts when the element exists. --- base_rest/__manifest__.py | 2 +- base_rest/static/src/js/components/swagger_ui.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/base_rest/__manifest__.py b/base_rest/__manifest__.py index 0026fa129..9025bf563 100644 --- a/base_rest/__manifest__.py +++ b/base_rest/__manifest__.py @@ -6,7 +6,7 @@ "summary": """ Develop your own high level REST APIs for Odoo thanks to this addon. """, - "version": "18.0.1.1.3", + "version": "18.0.1.1.4", "development_status": "Beta", "license": "LGPL-3", "author": "ACSONE SA/NV, Odoo Community Association (OCA)", diff --git a/base_rest/static/src/js/components/swagger_ui.js b/base_rest/static/src/js/components/swagger_ui.js index a63d1ed8a..4d7c80233 100644 --- a/base_rest/static/src/js/components/swagger_ui.js +++ b/base_rest/static/src/js/components/swagger_ui.js @@ -62,6 +62,9 @@ class SwaggerUI extends Component { whenReady(() => { const swaggerUiEl = document.getElementById("swagger-ui"); + if (!swaggerUiEl) { + return; + } const settings = JSON.parse(swaggerUiEl.getAttribute("data-settings") || "{}"); mount(SwaggerUI, swaggerUiEl, {props: {settings: settings}}); });