-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate.sh
37 lines (29 loc) · 1.42 KB
/
generate.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
#!/bin/bash
# clean models and docs before generating
find ./src/FingerprintPro.ServerSdk/Model -type f ! -name "DictionaryModel.cs" -exec rm {} +
find ./docs -type f ! -name "DecryptionKey.md" ! -name "Sealed.md" ! -name "WebhookValidation.md" -exec rm {} +
# jar was downloaded from here https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.34/
java -jar ./bin/swagger-codegen-cli.jar generate -t ./template -l csharp -i ./res/fingerprint-server-api.yaml -o ./ -c config.json
dotnet format
platform=$(uname)
# Fix for codegen generating override in ToJson for models that extend Dictionary
declare -a files=("./src/FingerprintPro.ServerSdk/Model/RawDeviceAttributes.cs" "./src/FingerprintPro.ServerSdk/Model/WebhookRawDeviceAttributes.cs" "./src/FingerprintPro.ServerSdk/Model/Tag.cs")
for i in "${files[@]}"
do
(
# Model file fix
if [ "$platform" = "Darwin" ]; then
sed -i '' 's/public override string ToJson()/public string ToJson()/' "$i"
sed -i '' 's/: Dictionary/: DictionaryModel/' "$i"
else
sed -i 's/public override string ToJson()/public string ToJson()/' "$i"
sed -i 's/: Dictionary/: DictionaryModel/' "$i"
fi
)
done
# Fix for empty type in RawDeviceAttribute docs
if [ "$platform" = "Darwin" ]; then
sed -i '' 's/\[\*\*\*\*\](\.md)/**JsonElement**/g' docs/RawDeviceAttribute.md
else
sed -i 's/\[\*\*\*\*\](\.md)/**JsonElement**/g' docs/RawDeviceAttribute.md
fi