-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.sh
executable file
·46 lines (36 loc) · 1.01 KB
/
script.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
if [ $# == 0 ]; then
echo "No command specified. Available commands: generate, push"
exit
fi
command=$1
cmdline=$@
echo "-->OpenAPI Generator Postman run ($cmdline)"
if [[ $command == "generate" ]]
then
cmdparams="${cmdline#*generate}"
elif [[ $command == "push" ]]
then
if [[ $POSTMAN_API_KEY == "" ]]
then
echo "ERROR: define postmanApiKey when running [push] command "
exit
fi
cmdparams="${cmdline#*push}"
fi
statusCode=$(java -jar /openapi-generator-postman-v2.jar generate -g com.adyen.codegen.postman.PostmanV2Generator $cmdparams)
if [[ ! $statusCode ]]
then
echo "Error during Postman generation"
exit 1
fi
output_file=$(find /usr/src/app -name "postman.json" | sort -nr | head -n 1)
if [[ $command == "push" ]]
then
echo "--> Pushing to Postman"
var=$(cat "$output_file")
echo '{"collection": '"$var"' }' | curl -X POST \
--header 'Content-Type: application/json' \
--header 'X-API-Key: '"${POSTMAN_API_KEY}"'' \
-d @- "https://api.getpostman.com/collections"
fi