-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgenerate-api.sh
More file actions
executable file
·53 lines (46 loc) · 1.29 KB
/
generate-api.sh
File metadata and controls
executable file
·53 lines (46 loc) · 1.29 KB
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
47
48
49
50
51
52
53
#!/bin/bash
echo "Generating UAPI from OpenAPI spec"
# Check if argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <openapi-spec-file>"
exit 1
fi
# Check if openapi-generator is installed
if ! command -v openapi-generator &> /dev/null
then
echo "openapi-generator could not be found"
echo "Please install openapi-generator-cli"
echo "https://openapi-generator.tech/docs/installation"
exit
fi
# Clearing old generated files
echo "clearing old generated files"
find ./api -name "*.go" -type f -delete
# Generate UAPI
openapi-generator generate \
-i $1 \
-g go \
-o ./api \
--package-name api \
--git-user-id "yohan460" \
--git-repo-id "go-jamf-api" \
--global-property=apiTests=false \
--type-mappings=integer=int64 \
--additional-properties=packageName=api,enumClassPrefix=true,structPrefix=true,generateInterfaces=true,isGoSubmodule=true \
--skip-validate-spec
returncode=$?
echo "Return code: $returncode"
if [[ "${returncode}" != "0" ]]; then
echo "Failed to generate UAPI"
exit 1
fi
# Perform cleanup
rm ./api/git_push.sh
rm ./api/go.mod
rm ./api/go.sum
rm ./api/.gitignore
# Patch reserved go file name suffixes
echo "Patching reserved go file name suffixes"
for file in api/*ios.go; do
mv "$file" "${file%ios.go}ios_.go"
done