Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
api-generator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scc-net
netvs
api-generator
Commits
1edd7fd9
Commit
1edd7fd9
authored
1 month ago
by
Sebastian Böckelmann
Browse files
Options
Downloads
Patches
Plain Diff
UPD: Use useAxios instead of Axios
parent
f9b118fe
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
net_api_generator/generator.py
+7
-3
7 additions, 3 deletions
net_api_generator/generator.py
net_api_generator/loader.py
+1
-1
1 addition, 1 deletion
net_api_generator/loader.py
with
8 additions
and
4 deletions
net_api_generator/generator.py
+
7
−
3
View file @
1edd7fd9
...
...
@@ -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\t
Axios.$HTTP_METHOD(`${NETVSConfig.NETDB_API_BASE_URL}/${NETVSConfig.NETDB_API_VERSION}/$PATH`, params, (config || {}).netdb_axios_config)
\n
"
"
\t\t
return 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\t
const cnf = {params: undefined}
\n
"
"
\t\t
Object.assign(cnf, (config || {}).netdb_axios_config)
\n
"
"
\t\t
cnf.params = params
\n
"
"
\t\t
return Axios.get(`${NETVSConfig.NETDB_API_BASE_URL}/${NETVSConfig.NETDB_API_VERSION}/$PATH`, cnf)
\n
"
"
\t\t
return 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
"
"
\n
import Axios from
'
a
xios
'
\n
"
"
\n
import
{ use
Axios
}
from
'
@vueuse/integrations/useA
xios
'
\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
'
)
...
...
This diff is collapsed.
Click to expand it.
net_api_generator/loader.py
+
1
−
1
View file @
1edd7fd9
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment