-
Notifications
You must be signed in to change notification settings - Fork 12
/
generate.sh
executable file
·110 lines (95 loc) · 2.91 KB
/
generate.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
#
# Purpose: Dockerized light-codegen to generate microservices for light-java-rest, light-java-graphql
# and light-java-hybrid
#
# Author: Eric Broda, Steve Hu
#
# Parameters:
# $1: Framework that include light-java-rest, light-java-graphql, light-java-hybrid-server, light-java-hybrid-service
# $2: Input directory that contains model/schema and config.json
# $3: Output directory for generated code
#
xFRAMEWORK=$1
xINPUTDIR=$2
xOUTPUTDIR=$3
function showHelp {
echo " "
echo "Error: $1"
echo " "
echo " generate.sh [framework] [input-dir] [output-dir]"
echo " "
echo " where [framework] is the light-java framework for the target project"
echo " [input-dir] is the directory path containing the schema/model file and config.json file"
echo " [output-dir] is the directory path where the output for the generated microservice will be located (required)"
echo " "
echo " example 1: ./generate.sh light-rest-4j ~/networknt/model-config/rest/petstore /tmp/petstore"
echo " "
}
if [ -z $1 ]; then
showHelp "[framework] parameter is missing"
exit
fi
if [ -z $2 ]; then
showHelp "[input-dir] parameter is missing"
exit
fi
if [ -z $3 ]; then
showHelp "[output-dir] parameter is missing"
exit
fi
echo "INFO: Generating project, using:"
echo " - framework: $xFRAMEWORK"
echo " - input-dir: $xINPUTDIR"
echo " - output-dir: $xOUTPUTDIR"
# Using networknt capability
echo "INFO: Running: networknt/light-codegen"
if [ $1 = "swagger" ]; then
docker run -it \
-v $xINPUTDIR:/light-api/input \
-v $xOUTPUTDIR:/light-api/out \
networknt/light-codegen \
-f swagger \
-c /light-api/input/config.json \
-m /light-api/input/swagger.json \
-o /light-api/out/generated
fi
if [ $1 = "openapi" ]; then
docker run -it \
-v $xINPUTDIR:/light-api/input \
-v $xOUTPUTDIR:/light-api/out \
networknt/light-codegen \
-f openapi \
-c /light-api/input/config.json \
-m /light-api/input/openapi.yaml \
-o /light-api/out/generated
fi
if [ $1 = "light-graphql-4j" ]; then
docker run -it \
-v $xINPUTDIR:/light-api/input \
-v $xOUTPUTDIR:/light-api/out \
networknt/light-codegen \
-f light-graphql-4j \
-c /light-api/input/config.json \
-o /light-api/out/generated
fi
if [ $1 = "light-hybrid-4j-server" ]; then
docker run -it \
-v $xINPUTDIR:/light-api/input \
-v $xOUTPUTDIR:/light-api/out \
networknt/light-codegen \
-f light-hybrid-4j-server \
-c /light-api/input/config.json \
-o /light-api/out/generated
fi
if [ $1 = "light-hybrid-4j-service" ]; then
docker run -it \
-v $xINPUTDIR:/light-api/input \
-v $xOUTPUTDIR:/light-api/out \
networknt/light-codegen \
-f light-hybrid-4j-service \
-c /light-api/input/config.json \
-m /light-api/input/schema.json \
-o /light-api/out/generated
fi
echo "Code generation is completed"