Commit eb4dbfe5 authored by Jerome Royan's avatar Jerome Royan
Browse files

Update patches for OpenAPI-generator 7.5.0 based on Json format for request...

Update patches for OpenAPI-generator 7.5.0 based on Json format for request parameters. Support several uuid and capabilities for RelocInformation
parent 8dad9685
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
#!/bin/bash
patch -u ../api/DefaultApi.h -i fixHeaderModelIssue.patch
patch -u ../api/DefaultApi.cpp -i fixCppModelIssue.patch
patch -u ../api/RelocalizationInformationApi.cpp -i fixRelocInfoJSONIssue.patch
patch -u ../api/TrackablesApi.cpp -i fixCppTrackable.patch
patch -u ../api/WorldAnchorsApi.cpp -i fixCppWorldAnchor.patch
patch -u ../api/WorldLinksApi.cpp -i fixCppWorldLink.patch
patch -u ../api/RelocalizationInformationApi.cpp -i fixCppRelocalizationInformation.patch
patch -u ../model/WorldLink.cpp -i fixCppWorldLinkModel.patch
patch -u ../model/WorldAnchor.cpp -i fixCppWorldAnchorModel.patch
patch -u ../model/Trackable.cpp -i fixCppTrackableModel.patch
+68 −0
Original line number Diff line number Diff line
--- ../../../world-storage-cpp-server/EtsiServerGen/api/RelocalizationInformationApi.cpp	2024-04-25 11:26:25.741693040 +0200
+++ ../../../../world-storage-cpp-serverRestBed/EtsiServerGen/api/RelocalizationInformationApi.cpp	2024-04-24 17:42:01.508637971 +0200
@@ -20,7 +20,7 @@
 #include <boost/property_tree/json_parser.hpp>
 #include <boost/lexical_cast.hpp>
--- RelocalizationInformationApi_origin.cpp	2024-05-17 22:17:55.668925905 +0200
+++ RelocalizationInformationApi.cpp	2024-05-17 22:19:17.209012284 +0200
@@ -22,7 +22,7 @@
 #include <boost/algorithm/string.hpp>
 
 #include "RelocalizationInformationApi.h"
-
+#include <iostream>
 #include "RelocalizationInformationApi.h"
 
 namespace org {
@@ -155,21 +155,36 @@
 namespace openapitools {
 namespace server {
@@ -155,21 +155,29 @@
 
 void RelocalizationInformationResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session)
 {
-    const auto request = session->get_request();
-    // Getting the query params
+    std::cout << "start handler_GET_internal\n" ;
+
     const auto request = session->get_request();
     // Getting the query params
-    std::string uuids_raw = request->get_query_parameter("uuids");
-    std::vector<RelocalizationInformationParam> uuids;
+    std::multimap<std::string, std::string> uuids_raw = request->get_query_parameters("uuids");
     std::vector<RelocalizationInformationParam> uuids;
-    std::vector<std::string> uuids_temp;
-    boost::split(uuids_temp, uuids_raw, boost::is_any_of(","));
-    std::transform(uuids_temp.begin(), uuids_temp.end(), std::back_inserter(uuids), [](const auto& i){ RelocalizationInformationParam ret; ret.fromString(i); return ret;});
-    std::string capabilities_raw = request->get_query_parameter("capabilities");
-    std::vector<Capability> capabilities;
+    for (auto it = uuids_raw.begin(); it != uuids_raw.end(); it++)
+    {
+        RelocalizationInformationParam relocInformationParam;
+        relocInformationParam.fromJsonString(it->second);        
+        uuids.push_back(relocInformationParam);
+     }
+    std::multimap<std::string, std::string> capabilities_raw = request->get_query_parameters("capabilities");
     std::vector<Capability> capabilities;
-    std::vector<std::string> capabilities_temp;
-    boost::split(capabilities_temp, capabilities_raw, boost::is_any_of(","));
-    std::transform(capabilities_temp.begin(), capabilities_temp.end(), std::back_inserter(capabilities), [](const auto& i){ Capability ret; ret.fromString(i); return ret;});
-    // Getting the headers
-    std::string token = request->get_header("token", "");
-    
+const auto request = session->get_request();
+// Getting the query params
+std::string uuids_raw = request->get_query_parameter("uuids");
+std::vector<RelocalizationInformationParam> uuids;
+std::vector<std::string> uuids_temp;
+boost::split(uuids_temp, uuids_raw, boost::is_any_of(";"));
+for (auto& uuid_str : uuids_temp) {
+    std::replace(uuid_str.begin(), uuid_str.end(), '(', '{');
+    std::replace(uuid_str.begin(), uuid_str.end(), ')', '}');
+    RelocalizationInformationParam ret;
+    ret.fromJsonString(uuid_str);
+    uuids.push_back(ret);
+}
+
+std::string capabilities_raw = request->get_query_parameter("capabilities");
+std::vector<Capability> capabilities;
+std::vector<std::string> capabilities_temp;
+boost::split(capabilities_temp, capabilities_raw, boost::is_any_of(";"));
+for (auto& cap_str : capabilities_temp) {
+    std::replace(cap_str.begin(), cap_str.end(), '(', '{');
+    std::replace(cap_str.begin(), cap_str.end(), ')', '}');
+    Capability ret;
+    ret.fromJsonString(cap_str);
+    capabilities.push_back(ret);
+    for (auto it = capabilities_raw.begin(); it != capabilities_raw.end(); it++)
+    {
+        Capability capability;
+        capability.fromJsonString(it->second);
+        capabilities.push_back(capability);
+     }
+
+// Getting the headers
+std::string token = request->get_header("token", "");
+
     // Getting the headers
     std::string token = request->get_header("token", "");
-    
+
     int status_code = 500;
     GetRelocalizationInformation_200_response resultObject = GetRelocalizationInformation_200_response{};
     std::string result = "";
@@ -209,7 +224,7 @@
@@ -209,7 +217,7 @@
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Invalid UUID supplied.";
     
@@ -70,7 +57,7 @@
         returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders);
         return;
     }
@@ -217,7 +232,7 @@
@@ -217,7 +225,7 @@
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Not found, could not find UUID in database.";
     
+30 −35
Original line number Diff line number Diff line
--- ../../../world-storage-cpp-server/EtsiServerGen/api/TrackablesApi.cpp	2024-04-15 17:47:05.542444638 +0200
+++ ../api/TrackablesApi.cpp	2024-04-22 18:14:43.144871367 +0200
--- TrackablesApi_origin.cpp	2024-05-17 13:51:16.050339055 +0200
+++ TrackablesApi.cpp	2024-05-17 11:14:41.058333100 +0200
@@ -20,9 +20,12 @@
 #include <boost/property_tree/json_parser.hpp>
 #include <boost/lexical_cast.hpp>
@@ -28,11 +28,10 @@
     return model;
 }
 
@@ -159,86 +169,102 @@
@@ -159,88 +169,102 @@
     session->close(status, result, { {"Connection", "close"} });
 }
 
+
+void extractBodyContentAsync(
+    const std::shared_ptr<restbed::Session>& session,
+    int content_length,
@@ -46,6 +45,7 @@
+            callback(bodyContent);
+        });
+}
+
 void TrackablesResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session)
 {
     const auto request = session->get_request();
@@ -126,6 +126,8 @@
-        return;
-    }
-    defaultSessionClose(session, status_code, result);
-    
-    
+    int content_length = request->get_header("Content-Length", 0);
+   extractBodyContentAsync(session, content_length, [this, session,request](const std::string& bodyContent) {
+            
@@ -208,7 +210,7 @@
 }
 
 // x-extension
@@ -277,8 +303,11 @@
@@ -279,8 +303,11 @@
         if (!acceptTypes.empty()) {
             responseHeaders.insert(std::make_pair("Accept", acceptTypes));
         }
@@ -222,7 +224,7 @@
         return;
     }
     if (status_code == 201) {
@@ -286,17 +315,20 @@
@@ -288,17 +315,20 @@
         if (!acceptTypes.empty()) {
             responseHeaders.insert(std::make_pair("Accept", acceptTypes));
         }
@@ -248,7 +250,7 @@
         return;
     }
     defaultSessionClose(session, status_code, result);
@@ -304,8 +336,11 @@
@@ -308,8 +338,11 @@
 // x-extension
 void TrackablesResource::handler_PUT_internal(const std::shared_ptr<restbed::Session> session) {
     const auto request = session->get_request();
@@ -261,27 +263,15 @@
     auto trackable = extractJsonModelBodyParam<Trackable>(bodyContent);
     // Getting the headers
     std::string token = request->get_header("token", "");
@@ -342,35 +377,36 @@
@@ -346,7 +379,6 @@
             responseHeaders.insert(std::make_pair("Accept", acceptTypes));
         }
     
-        result = resultObject;
-        returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders);
+        auto result = resultObject;
+        returnResponse(session, 200, result, responseHeaders);
         returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders);
         return;
     }
     if (status_code == 400) {
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Bad request.";
     
-        result = resultObject;
-        returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders);
+        auto result = resultObject;
+        returnResponse(session, 400, result, responseHeaders);
         return;
     }
     if (status_code == 404) {
@@ -362,21 +394,19 @@
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Not found, could not find UUID in database.";
     
@@ -297,31 +287,36 @@
     
-        result = resultObject.toJsonString();
-        returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders);
+        
+        returnResponse(session, 0, result, responseHeaders);
         return;
     }
     defaultSessionClose(session, status_code, result);
-    
-    
+   });    
 }
 
 std::pair<int, std::string> TrackablesResource::handler_POST(
@@ -390,9 +426,13 @@
@@ -396,18 +426,24 @@
     return handler_PUT_func(trackable, token);
 }
 
-std::string TrackablesResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
-  const auto request = session->get_request();
-  int content_length = request->get_header("Content-Length", 0);
-  std::string bodyContent;
-  session->fetch(content_length,
+
+
+std::string TrackablesResource::extractBodyContent(
+   const std::shared_ptr<restbed::Session>& session) {
   const auto request = session->get_request();
   int content_length = request->get_header("Content-Length", 0);
+   const auto request = session->get_request();
+   int content_length = request->get_header("Content-Length", 0);
+
   std::string bodyContent;
   session->fetch(content_length,
+   std::string bodyContent;
+   session->fetch(content_length,
                  [&bodyContent](const std::shared_ptr<restbed::Session> session,
@@ -400,8 +440,10 @@
                                 const restbed::Bytes &body) {
                    bodyContent = restbed::String::format(
                        "%.*s\n", (int)body.size(), body.data());
                  });
@@ -333,7 +328,7 @@
 
 std::string TrackablesResource::extractFormParamsFromBody(const std::string& paramName, const std::string& body) {
     const auto uri = restbed::Uri("urlencoded?" + body, true);
@@ -493,24 +535,24 @@
@@ -499,24 +535,24 @@
             responseHeaders.insert(std::make_pair("Accept", acceptTypes));
         }
     
@@ -350,7 +345,7 @@
-        result = resultObject;
-        returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders);
+        auto result = resultObject;
+        returnResponse(session, 400,result, responseHeaders);
+        returnResponse(session, 400,"{}", responseHeaders);
         return;
     }
     if (status_code == 404) {
@@ -360,11 +355,11 @@
-        result = resultObject;
-        returnResponse(session, 404, result.empty() ? "{}" : result, responseHeaders);
+        auto result = resultObject;
+        returnResponse(session, 404, result, responseHeaders);
+        returnResponse(session, 404, "{}", responseHeaders);
         return;
     }
     defaultSessionClose(session, status_code, result);
@@ -556,23 +598,23 @@
@@ -564,23 +600,23 @@
         }
     
         result = resultObject.toJsonString();
+18 −15
Original line number Diff line number Diff line
--- ../../../cpp-server-patch/world-storage-cpp-server/EtsiServerGen/api/WorldAnchorsApi.cpp	2024-04-23 11:31:29.141217249 +0200
+++ ../api/WorldAnchorsApi.cpp	2024-04-22 10:38:47.298434241 +0200
--- WorldAnchorsApi_origin.cpp	2024-05-17 13:51:16.060339191 +0200
+++ WorldAnchorsApi.cpp	2024-05-17 11:17:50.201891700 +0200
@@ -20,7 +20,7 @@
 #include <boost/property_tree/json_parser.hpp>
 #include <boost/lexical_cast.hpp>
@@ -9,7 +9,7 @@
 #include "WorldAnchorsApi.h"
 
 namespace org {
@@ -159,11 +159,26 @@
@@ -159,11 +159,27 @@
     session->close(status, result, { {"Connection", "close"} });
 }
 
@@ -26,6 +26,7 @@
+            callback(bodyContent);
+        });
+}
+
 void WorldAnchorsResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session)
 {
     const auto request = session->get_request();
@@ -37,7 +38,7 @@
     auto worldAnchor = extractJsonModelBodyParam<WorldAnchor>(bodyContent);
     // Getting the headers
     std::string token = request->get_header("token", "");
@@ -234,11 +249,12 @@
@@ -234,13 +250,12 @@
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Unexpected error.";
     
@@ -47,11 +48,13 @@
         return;
     }
     defaultSessionClose(session, status_code, result);
-    
-    
+    });   
 }
 
 // x-extension
@@ -278,7 +294,11 @@
@@ -280,7 +295,11 @@
             responseHeaders.insert(std::make_pair("Accept", acceptTypes));
         }
     
@@ -64,7 +67,7 @@
         return;
     }
     if (status_code == 201) {
@@ -287,16 +307,20 @@
@@ -289,16 +308,19 @@
             responseHeaders.insert(std::make_pair("Accept", acceptTypes));
         }
     
@@ -84,12 +87,11 @@
     
-        result = resultObject.toJsonString();
-        returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders);
+        
+        returnResponse(session, 0, result, responseHeaders);
         return;
     }
     defaultSessionClose(session, status_code, result);
@@ -304,8 +328,10 @@
@@ -308,8 +330,10 @@
 // x-extension
 void WorldAnchorsResource::handler_PUT_internal(const std::shared_ptr<restbed::Session> session) {
     const auto request = session->get_request();
@@ -101,22 +103,23 @@
     auto worldAnchor = extractJsonModelBodyParam<WorldAnchor>(bodyContent);
     // Getting the headers
     std::string token = request->get_header("token", "");
@@ -366,11 +392,12 @@
@@ -370,13 +394,11 @@
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Unexpected error.";
     
-        result = resultObject.toJsonString();
-        returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders);
+        
+        returnResponse(session, 0,  result, responseHeaders);
         return;
     }
     defaultSessionClose(session, status_code, result);
-    
-    
+    });   
 }
 
 std::pair<int, std::string> WorldAnchorsResource::handler_POST(
@@ -563,7 +590,7 @@
@@ -571,7 +593,7 @@
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Invalid UUID supplied.";
     
@@ -125,7 +128,7 @@
         returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders);
         return;
     }
@@ -571,7 +598,7 @@
@@ -579,7 +601,7 @@
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Not found, could not find UUID in database.";
     
@@ -134,7 +137,7 @@
         returnResponse(session, 404, result.empty() ? "{}" : result, responseHeaders);
         return;
     }
@@ -590,6 +617,7 @@
@@ -600,6 +622,7 @@
     return handler_GET_func(worldAnchorUUID, token);
 }
 
+20 −17
Original line number Diff line number Diff line
--- ../../../cpp-server-patch/world-storage-cpp-server/EtsiServerGen/api/WorldLinksApi.cpp	2024-04-23 11:31:29.141217249 +0200
+++ ../api/WorldLinksApi.cpp	2024-04-22 16:21:40.875779442 +0200
@@ -159,11 +159,26 @@
--- WorldLinksApi_origin.cpp	2024-05-17 13:51:16.070339327 +0200
+++ WorldLinksApi.cpp	2024-05-17 11:01:46.566999100 +0200
@@ -159,11 +159,27 @@
     session->close(status, result, { {"Connection", "close"} });
 }
 
@@ -17,6 +17,7 @@
+            callback(bodyContent);
+        });
+}
+
 void WorldLinksResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session)
 {
     const auto request = session->get_request();
@@ -28,22 +29,23 @@
     auto worldLink = extractJsonModelBodyParam<WorldLink>(bodyContent);
     // Getting the headers
     std::string token = request->get_header("token", "");
@@ -234,11 +249,12 @@
@@ -234,13 +250,11 @@
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Unexpected error.";
     
-        result = resultObject.toJsonString();
-        returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders);
+        
+        returnResponse(session, 0, result, responseHeaders);
         return;
     }
     defaultSessionClose(session, status_code, result);
-    
-    
+    });    
 }
 
 // x-extension
@@ -278,7 +294,11 @@
@@ -280,7 +294,11 @@
             responseHeaders.insert(std::make_pair("Accept", acceptTypes));
         }
     
@@ -56,7 +58,7 @@
         return;
     }
     if (status_code == 201) {
@@ -287,16 +307,20 @@
@@ -289,16 +307,19 @@
             responseHeaders.insert(std::make_pair("Accept", acceptTypes));
         }
     
@@ -76,12 +78,11 @@
     
-        result = resultObject.toJsonString();
-        returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders);
+       
+        returnResponse(session, 0, result, responseHeaders);
         return;
     }
     defaultSessionClose(session, status_code, result);
@@ -304,8 +328,10 @@
@@ -308,8 +329,10 @@
 // x-extension
 void WorldLinksResource::handler_PUT_internal(const std::shared_ptr<restbed::Session> session) {
     const auto request = session->get_request();
@@ -93,25 +94,27 @@
     auto worldLink = extractJsonModelBodyParam<WorldLink>(bodyContent);
     // Getting the headers
     std::string token = request->get_header("token", "");
@@ -366,11 +392,12 @@
@@ -370,13 +393,11 @@
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Unexpected error.";
     
-        result = resultObject.toJsonString();
-        returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders);
+        
+        returnResponse(session, 0, result, responseHeaders);
         return;
     }
     defaultSessionClose(session, status_code, result);
-    
-    
+   });       
 }
 
 std::pair<int, std::string> WorldLinksResource::handler_POST(
@@ -563,16 +590,16 @@
@@ -570,17 +591,15 @@
     if (status_code == 400) {
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Invalid UUID supplied.";
     
-    
-        result = resultObject;
-        returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders);
+
@@ -121,7 +124,7 @@
     if (status_code == 404) {
         responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
         result = "Not found, could not find UUID in database.";
     
-    
-        result = resultObject;
-        returnResponse(session, 404, result.empty() ? "{}" : result, responseHeaders);
+       
Loading