-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·72 lines (62 loc) · 1.55 KB
/
entrypoint.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
#!/bin/bash
set -e
set -u
do_resolve=$1
do_validate=$2
do_prettify=$3
raw=$4
resolved=$5
docs=$6
title=$7
bundle=$8
# Resolving the schemas.
if [[ $do_resolve == "true" ]]
then
echo "[LOG] Resolving schemas from $raw to $resolved"
mkdir -p $resolved
python3 /scripts/resolve_allOf.py $raw $resolved
echo ""
fi
# Validating the schemas.
all_json=$(find $resolved -type f -name "*.json")
if [[ $do_validate == "true" ]]
then
echo "[LOG] Validating schemas from $resolved"
for x in ${all_json}
do
echo "Validating $x"
check-jsonschema --check-metaschema $x
done
echo ""
fi
# Generating pretty HTMLs.
if [[ $do_prettify == "true" ]]
then
echo "[LOG] Prettifying schemas from $resolved to $docs"
mkdir -p $docs
for x in ${all_json}
do
base=$(basename $x | sed "s/.json/.html/")
dir=$(dirname $x | xargs basename)
mkdir -p $docs/$dir
tmp=${docs}/${dir}/tmp-${base}.json
echo "Prettifying $x"
python3 /scripts/nest_allOf.py ${x} ${tmp}
generate-schema-doc \
--config description_is_markdown=true \
--config collapse_long_descriptions=false \
${tmp} ${docs}/${dir}/${base}
cp $x ${docs}/${dir}
rm ${tmp}
done
# Creating a landing page.
python3 /scripts/create_landing_page.py "$title" $docs > $docs/index.html
echo ""
fi
# Creating a bundle at the target.
if [[ $bundle != "" ]]
then
echo "[LOG] Bundling schemas from $resolved to $bundle"
tar -czvf $bundle $resolved
echo ""
fi