forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-samples.sh
executable file
·65 lines (53 loc) · 1.84 KB
/
generate-samples.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
#!/usr/bin/env bash
# this bash script generates all samples.
# it ensures that all changes are committed into the 'samples/' folder
# shellcheck disable=SC2155
declare cwd="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
declare root="$(cd "$cwd" && cd ../ && pwd)"
declare executable="${root}/modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]; then
(cd "${root}" && mvn -B --no-snapshot-updates clean package -DskipTests=true -Dmaven.javadoc.skip=true -Djacoco.skip=true)
fi
export JAVA_OPTS="${JAVA_OPTS} -ea -server -Duser.timezone=UTC"
export BATCH_OPTS="${BATCH_OPTS:-}"
files=()
args=()
end_option=false
while [[ $# -gt 0 ]]; do
key="$1"
if [ "--" == "$key" ]; then
end_option=true
else
if [[ "$end_option" = true ]]; then
args+=("$1")
else
files+=("$1")
fi
fi
shift
done
header="# START SCRIPT: $0
This script generates all configs under bin/configs by default.
You may generate a targeted script or set of scripts using glob patterns.
For example:
$0 bin/configs/java-*
You may generate a single config with additional options if you use -- to
separate the single config file from the generator arguments.
For example:
$0 bin/configs/java-vertx.yaml -- --global-property debugModels=true
"
echo "$header"
if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then
# shellcheck disable=SC2086
# shellcheck disable=SC2068
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]}
else
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
#sleep 5
if [ ${#files[@]} -eq 0 ]; then
files=("${root}"/bin/configs/*.yaml)
fi
# shellcheck disable=SC2086
# shellcheck disable=SC2068
java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]}
fi