forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
json-schema-diff.bash
executable file
·36 lines (31 loc) · 1.11 KB
/
json-schema-diff.bash
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
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -o errexit
set -o nounset
set -o pipefail
IFS=$'\n\t'
image_name="$(basename $0):latest"
docker buildx build --load --tag "$image_name" - <<EOF
FROM node:12.18.2
RUN npm install -g [email protected]
ENTRYPOINT ["json-schema-diff"]
EOF
#
# To interprete differences is not obvious (for me), SEE https://www.npmjs.com/package/json-schema-diff
#
# TIPS to debug
# 1. create the dst json-schema manually through the pydantic type (see Makefile recipies in models-library)
# 2. resolve both src/dst using json-resolver (see https://github.com/davidkelley/json-dereference-cli
# callable from ./scripts/json-schema-dereference.bash schema.json schema-deref.json)
# 3. compare both files in vscode
#
input_1="$(basename "$1")"
input_2="$(basename "$2")"
echo "json-schema-diff between source '$input_1' -> destination '$input_2' schemas:"
echo " source: '$1'"
echo " destination: '$2'"
docker run --rm \
-v "$(realpath "$1")":/src/"$input_1" \
-v "$(realpath "$2")":/src/"$input_2" \
"$image_name" \
"/src/$input_1" "/src/$input_2"