-
Notifications
You must be signed in to change notification settings - Fork 22
/
convert.sh
executable file
·31 lines (27 loc) · 971 Bytes
/
convert.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
cd openapi-spec
for file in *.json; do
# Replace host in env and cfg api
sed -e 's/https:\/\/.*\/api\//\https:\/\/{{DT_HOST}}\/api\//g' -i $file
# Create postman collection
openapi2postmanv2 -s $file -o ../specs/$file
# Replace Authentication
sed 's/{{apiKey}}/Api-Token {{DT_TOKEN}}/g' -i ../specs/$file
sed 's/<API Key>/Api-Token {{DT_TOKEN}}/g' -i ../specs/$file
# Replace Collection Names
echo $file
case $file in
"cluster-v1.json")
sed 's/"name":"Dynatrace Cluster API",/"name": "Dynatrace Cluster API v1",/' -i ../specs/$file
;;
"cluster-v2.json" )
sed 's/"name":"Dynatrace Cluster API",/"name": "Dynatrace Cluster API v2",/' -i ../specs/$file
;;
"environment-v1.json" )
sed 's/"name":"Dynatrace Environment API",/"name": "Dynatrace Environment API v1",/' -i ../specs/$file
;;
"environment-v2.json" )
sed 's/"name":"Dynatrace Environment API",/"name": "Dynatrace Environment API v2",/' -i ../specs/$file
;;
esac
done