This repository has been archived by the owner on Jul 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Makefile
69 lines (52 loc) · 2.06 KB
/
Makefile
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
BASE_URL= "https://id.uvci.eu"
SCHEMATA= DCC.schema.json \
DCC.Core.Types.schema.json \
DCC.Types.schema.json \
DCC.ValueSets.schema.json
MERGED_SCHEMA= DCC.combined-schema.json
MERGED_ID= "$(BASE_URL)/$(MERGED_SCHEMA)"
JSON_FILES= *.json \
examples/vaccination/*.json \
examples/test/*.json \
examples/recovery/*.json \
test/invalid/*.json \
test/valid/*.json \
valuesets/*.json
AJV= ./node_modules/.bin/ajv -c ajv-formats --spec=draft2020 --strict=false
test:: compile validate-valuesets validate-examples check-formatting $(MERGED_SCHEMA)
$(AJV) test -s $(MERGED_SCHEMA) -d "examples/vaccination/*.json" --valid
$(AJV) test -s $(MERGED_SCHEMA) -d "examples/recovery/*.json" --valid
$(AJV) test -s $(MERGED_SCHEMA) -d "examples/test/*.json" --valid
$(AJV) test -s $(MERGED_SCHEMA) -d "test/invalid/*.json" --invalid
combined: $(MERGED_SCHEMA)
compile::
@echo "Compiling schemata..."
$(AJV) compile -r "DCC.*.schema.json" -s "DCC.schema.json"
check-formatting::
@echo "Checking JSON formatting..."
@for file in $(JSON_FILES); do \
jq . <$$file >$$file.tmp; \
if ! cmp $$file $$file.tmp; then \
echo "Please reformat $$file"; \
fi; \
rm $$file.tmp; \
done
validate-examples::
$(AJV) validate -r "DCC.*.schema.json" -s "DCC.schema.json" -d "examples/vaccination/*.json"
$(AJV) validate -r "DCC.*.schema.json" -s "DCC.schema.json" -d "examples/recovery/*.json"
$(AJV) validate -r "DCC.*.schema.json" -s "DCC.schema.json" -d "examples/test/*.json"
validate-valid-tests::
$(AJV) validate -r "DCC.*.schema.json" -s "DCC.schema.json" -d "test/valid/*.json"
validate-invalid-tests::
$(AJV) test -r "DCC.*.schema.json" -s "DCC.schema.json" -d "test/invalid/*.json" --invalid
validate-valuesets::
$(AJV) validate -s "valueset.json" -d "valuesets/*.json"
$(MERGED_SCHEMA): $(SCHEMATA)
python3 merge.py --id $(MERGED_ID) $(SCHEMATA) | jq . > $@
$(AJV) compile -s $@
reformat::
for file in $(JSON_FILES); do echo $$file; jq . <$$file >$$file.tmp && mv $$file.tmp $$file; done
install-ajv:
npm install ajv ajv-cli ajv-formats
clean:
rm -f $(MERGED_SCHEMA)