changeset 5394:002ba12a8bee

fix openapi & cheatsheet visitors to include trailing 'path' in /instances/{id}/content/{path} url
author Alain Mazy <am@osimis.io>
date Tue, 03 Oct 2023 11:55:43 +0200
parents c5c00bee291a
children c1037a755cee
files OrthancFramework/Sources/RestApi/RestApi.cpp
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/RestApi/RestApi.cpp	Tue Oct 03 11:33:59 2023 +0200
+++ b/OrthancFramework/Sources/RestApi/RestApi.cpp	Tue Oct 03 11:55:43 2023 +0200
@@ -138,6 +138,7 @@
 
     protected:
       virtual bool HandleCall(RestApiCall& call,
+                              const std::string& path,
                               const std::set<std::string>& uriArgumentsNames) = 0;
   
     public:
@@ -194,7 +195,7 @@
           try
           {
             ok = (resource.Handle(call) &&
-                  HandleCall(call, uriArgumentsNames));
+                  HandleCall(call, path, uriArgumentsNames));
           }
           catch (OrthancException& e)
           {
@@ -232,7 +233,7 @@
           try
           {
             ok = (resource.Handle(call) &&
-                  HandleCall(call, uriArgumentsNames));
+                  HandleCall(call, path, uriArgumentsNames));
           }
           catch (OrthancException& e)
           {
@@ -269,7 +270,7 @@
           try
           {
             ok = (resource.Handle(call) &&
-                  HandleCall(call, uriArgumentsNames));
+                  HandleCall(call, path, uriArgumentsNames));
           }
           catch (OrthancException& e)
           {
@@ -307,7 +308,7 @@
           try
           {
             ok = (resource.Handle(call) &&
-                  HandleCall(call, uriArgumentsNames));
+                  HandleCall(call, path, uriArgumentsNames));
           }
           catch (OrthancException& e)
           {
@@ -366,10 +367,9 @@
 
     protected:
       virtual bool HandleCall(RestApiCall& call,
+                              const std::string& path,
                               const std::set<std::string>& uriArgumentsNames) ORTHANC_OVERRIDE
       {
-        const std::string path = Toolbox::FlattenUri(call.GetFullUri());
-
         Json::Value v;
         if (call.GetDocumentation().FormatOpenApi(v, uriArgumentsNames, path))
         {
@@ -684,9 +684,10 @@
 
     protected:
       virtual bool HandleCall(RestApiCall& call,
+                              const std::string& _path,
                               const std::set<std::string>& uriArgumentsNames) ORTHANC_OVERRIDE
       {
-        Path& path = paths_[ Toolbox::FlattenUri(call.GetFullUri()) ];
+        Path& path = paths_[ _path ];
 
         path.AddMethod(call.GetMethod(), call.GetDocumentation().GetTag(), call.GetDocumentation().IsDeprecated());