From 1edd7fd9f5d6b0391028e268123999635159b6b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= <gp5761@partner.kit.edu>
Date: Thu, 27 Feb 2025 14:34:02 +0100
Subject: [PATCH] UPD: Use useAxios instead of Axios

---
 net_api_generator/generator.py | 10 +++++++---
 net_api_generator/loader.py    |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/net_api_generator/generator.py b/net_api_generator/generator.py
index 7065718..657227b 100644
--- a/net_api_generator/generator.py
+++ b/net_api_generator/generator.py
@@ -283,6 +283,7 @@ def typescript(output_dir):
                 replace_string = attribute_list_item + "\n"
             code_template = code_template.replace("$ATTRIBUTE_LIST_ITEM", replace_string)
         return code_template
+        return code_template
 
     def generate_param_list_type():
         return "export interface ParamList {\n\t old: string[],\n\t new: string[]\n}"
@@ -326,7 +327,8 @@ def typescript(output_dir):
                              "\t\t\t\t$OLD\n"
                              "\t\t\t}\n"
                              "\t\t}\n"
-                             "\t\tAxios.$HTTP_METHOD(`${NETVSConfig.NETDB_API_BASE_URL}/${NETVSConfig.NETDB_API_VERSION}/$PATH`, params, (config || {}).netdb_axios_config)\n"
+                             "\t\treturn useAxios(`${NETVSConfig.NETDB_API_BASE_URL}/${NETVSConfig.NETDB_API_VERSION}/$PATH`, { method: '$HTTP_METHOD', data: { } })\n"
+                             #"\t\tAxios.$HTTP_METHOD(`${NETVSConfig.NETDB_API_BASE_URL}/${NETVSConfig.NETDB_API_VERSION}/$PATH`, params, (config || {}).netdb_axios_config)\n"
                              "\t}")
 
             code_template = code_template.replace('$METHOD_NAME', api_function.name)
@@ -338,6 +340,7 @@ def typescript(output_dir):
                     function_attribute_replace_string = function_attribute_replace_string.replace("$PARAMETER_OLD_NAME", parameter.name + "_old")
                 else:
                     function_attribute_replace_string = function_attribute_replace_string.replace("$PARAMETER_OLD_NAME: $PARAMETER_TYPE, ", "")
+
                 if parameter.new is not None:
                     function_attribute_replace_string = function_attribute_replace_string.replace("$PARAMETER_NEW_NAME", parameter.name + "_new")
                 else:
@@ -382,7 +385,8 @@ def typescript(output_dir):
                              "\t\tconst cnf = {params: undefined}\n"
                              "\t\tObject.assign(cnf, (config || {}).netdb_axios_config)\n"
                              "\t\tcnf.params = params\n"
-                             "\t\treturn Axios.get(`${NETVSConfig.NETDB_API_BASE_URL}/${NETVSConfig.NETDB_API_VERSION}/$PATH`, cnf)\n"
+                             "\t\treturn useAxios(`${NETVSConfig.NETDB_API_BASE_URL}/${NETVSConfig.NETDB_API_VERSION}/$PATH`, { method: '$HTTP_METHOD', data: { cnf }})\n"
+                             #"\t\treturn Axios.get(`${NETVSConfig.NETDB_API_BASE_URL}/${NETVSConfig.NETDB_API_VERSION}/$PATH`, cnf)\n"
                              "\t}")
             code_template = code_template.replace("$METHOD_NAME", api_function.name)
             for index, parameter in enumerate(api_function.parameters.values()):
@@ -415,7 +419,7 @@ def typescript(output_dir):
 
         import_statements = ("import type {ParamList} from \'./param_list_type\'\n"
                              "import APIUtils from \'@/util/apiutil\'\n"
-                             "\nimport Axios from 'axios'\n"
+                             "\nimport { useAxios } from '@vueuse/integrations/useAxios'\n"
                              "import NETVSConfig from '@/netvs.config' \n\n")
         api_object_code = autogenerated_info + import_statements + generate_api_object(api_object[1]) + "\n\n"
         file = open(os.path.join(output_dir, api_object[0] + '.ts'), 'w')
diff --git a/net_api_generator/loader.py b/net_api_generator/loader.py
index d284739..f3be993 100644
--- a/net_api_generator/loader.py
+++ b/net_api_generator/loader.py
@@ -12,7 +12,7 @@ class Loader(object):
     api_scheme: str = 'https'
     api_host: str = 'api.netdb.scc.kit.edu'
     doku_host: str = 'doku.netdb.scc.kit.edu'
-    api_version: str = '4.0'
+    api_version: str = '4.1'
     version_detail: str = None
     base_dir: str = ''
     _auth: str = None
-- 
GitLab