This is an automated email from the ASF dual-hosted git repository.

jacopoc pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 6294153cb7abb7d238832bc1d219c2e9c4fcc57e
Author: Jacopo Cappellato <[email protected]>
AuthorDate: Mon Oct 19 10:37:34 2026 +0200

    Fix Redoc failing to load the OpenAPI specification
    
    Since the REST API was split into independent API groups, the OpenAPI
    specification is served at /rest/<api-group-path>/openapi.json, but
    redoc.html still requested /rest/openapi.json, which now returns 404.
    
    Redoc now picks the API group from the page URL, as Swagger UI already
    does: /docs/redoc.html shows the default "api" group and
    /docs/<api-group-path>/redoc.html shows the named group. The Redoc
    script is loaded from an absolute path so that it is also found under
    /docs/<api-group-path>/, and OFBizOpenApiUiFilter now forwards those
    URLs to redoc.html. The docs README lists the per-group URLs for both
    viewers.
    
    Co-Authored-By: Claude Opus 5.5
---
 .../org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiUiFilter.java     | 6 +++---
 framework/rest-api/webapp/docs/README.adoc                       | 8 ++++++--
 framework/rest-api/webapp/docs/redoc.html                        | 9 +++++++--
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git 
a/framework/rest-api/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiUiFilter.java
 
b/framework/rest-api/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiUiFilter.java
index 14f9cb48f6..4466069fa0 100644
--- 
a/framework/rest-api/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiUiFilter.java
+++ 
b/framework/rest-api/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiUiFilter.java
@@ -41,9 +41,9 @@ public class OFBizOpenApiUiFilter implements Filter {
 
         String path = 
request.getRequestURI().substring(request.getContextPath().length());
 
-        // /orderApi/swagger-ui.html
-        if (path.matches("/[^/]+/swagger-ui\\.html")) {
-            request.getRequestDispatcher("/swagger-ui.html")
+        // /orderApi/swagger-ui.html or /orderApi/redoc.html
+        if (path.matches("/[^/]+/(swagger-ui|redoc)\\.html")) {
+            request.getRequestDispatcher(path.substring(path.lastIndexOf('/')))
                     .forward(request, response);
             return;
         }
diff --git a/framework/rest-api/webapp/docs/README.adoc 
b/framework/rest-api/webapp/docs/README.adoc
index 28705c56a9..84e87badab 100644
--- a/framework/rest-api/webapp/docs/README.adoc
+++ b/framework/rest-api/webapp/docs/README.adoc
@@ -7,8 +7,12 @@ They are downloaded and copied into this directory 
automatically when running `.
 
 == Swagger UI
 
-Access: https://localhost:8443/docs/swagger-ui.html
+Access: https://localhost:8443/docs/<api-group-path>/swagger-ui.html
+
+Without an api group path (https://localhost:8443/docs/swagger-ui.html) the 
default "api" group is shown.
 
 == Redoc
 
-Access: https://localhost:8443/docs/redoc.html
+Access: https://localhost:8443/docs/<api-group-path>/redoc.html
+
+Without an api group path (https://localhost:8443/docs/redoc.html) the default 
"api" group is shown.
diff --git a/framework/rest-api/webapp/docs/redoc.html 
b/framework/rest-api/webapp/docs/redoc.html
index 6fa1d23978..4eeca2173f 100644
--- a/framework/rest-api/webapp/docs/redoc.html
+++ b/framework/rest-api/webapp/docs/redoc.html
@@ -36,12 +36,17 @@ under the License.
   </head>
   <body>
   <redoc></redoc>
-  <script src="redoc.standalone.js"> </script>
+  <script src="/docs/redoc.standalone.js"> </script>
   <script>
       if (!window.location.origin) {
         window.location.origin = window.location.protocol + "//" + 
window.location.hostname + (window.location.port ? ':' + window.location.port : 
'');
       }
-      Redoc.init(window.location.origin + '/rest/openapi.json');
+
+      const pathSegments = window.location.pathname.split('/').filter(Boolean);
+      const apiName = pathSegments.length >= 3 ? 
pathSegments[pathSegments.length - 2] : null;
+      const apiGroupPath = apiName ? encodeURIComponent(apiName) + "/" : 
"api/";
+
+      Redoc.init(window.location.origin + "/rest/" + apiGroupPath + 
"openapi.json");
     </script>
   </body>
 </html>

Reply via email to