This repository was archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_models.sh
More file actions
70 lines (50 loc) · 1.51 KB
/
generate_models.sh
File metadata and controls
70 lines (50 loc) · 1.51 KB
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
#!/bin/bash
# create venv
python3 -m venv venv-datagen
source venv-datagen/bin/activate
# delete content if the path exists
[ -d "raw/" ] && rm -rf raw/*
# create folder if it doesn't exist
if [ ! -d "raw/" ]
then
mkdir raw/
fi
# install code generator
pip install datamodel-code-generator
basename="s2-ws-json/s2-json-schema"
# run code generator
mkdir -p raw/common
# common types
for schema_type in 'schemas' 'messages'
do
mkdir -p "raw/common/$schema_type"
for entry in "s2-ws-json/s2-json-schema/$schema_type/"*
do
if [[ $entry == *+(FRBC|PPBC|PEBC|DDBC|OMBC)* ]]; then
continue
fi
echo "$entry"
filename=$(basename ${entry})
filename=${filename/.schema.json/.py}
datamodel-codegen --use-title-as-name --input-file-type jsonschema --input $entry --output raw/common/$schema_type/$filename
done
done
# operation modes messages and schemas
for mode in "FRBC" "PPBC" "PEBC" "DDBC" "OMBC"
do
mkdir -p "raw/$mode"
for schema_type in 'schemas' 'messages'
do
mkdir -p "raw/$mode/$schema_type"
for entry in "s2-ws-json/s2-json-schema/$schema_type/$mode."*
do
echo "$entry"
filename=$(basename ${entry})
filename=${filename/schema.json/py}
filename=${filename/$mode./}
datamodel-codegen --use-title-as-name --input-file-type jsonschema --input $entry --output raw/$mode/$schema_type/$filename
done
done
done
# clean
rm -rf venv-datagen/