-
Notifications
You must be signed in to change notification settings - Fork 4
/
patch.sh
executable file
·65 lines (56 loc) · 1.81 KB
/
patch.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
#!/bin/bash
set -e
cp openapi3.yml openapi3-any-of-patch.yml
replaceAnyOf() {
value=$1
newType=$2
echo $value
yaml set openapi3-any-of-patch.yml "components.schemas.$value.type" $newType >tmp.yml
cp tmp.yml openapi3-any-of-patch.yml
yaml set openapi3-any-of-patch.yml "components.schemas.$value.anyOf" >tmp.yml
cp tmp.yml openapi3-any-of-patch.yml
}
replaceXNumberString() {
value=$1
echo $value
yaml set openapi3-any-of-patch.yml "components.schemas.$value.type" x-number-string >tmp.yml
cp tmp.yml openapi3-any-of-patch.yml
}
for value in EmbeddedTransactionInfoDTO.properties.transaction \
TransactionInfoDTO.properties.transaction \
BlockInfoDTO.properties.block \
TransactionInfoDTO.properties.meta \
MerkleStateInfoDTO.properties.tree.items \
MosaicRestrictionDTO \
TransactionStatementDTO.properties.receipts.items \
MosaicRestrictionsPage.properties.data.items \
AccountRestrictionDTO.properties.values.items; do
replaceAnyOf $value object
done
for value in ResolutionEntryDTO.properties.resolved \
ResolutionStatementDTO.properties.unresolved \
MetadataEntryDTO.properties.targetId; do
replaceAnyOf $value string
done
for value in Amount UInt64 FinalizedHeight BlockDuration Difficulty Height Importance Score Timestamp RestrictionValue CosignatureVersion; do
replaceXNumberString $value
done
PATCHFILE="openapi3-any-of-patch.yml"
SED_ARGS_ANYOF_PATCH='/anyOf: ''/d'
case $(uname | tr '[:upper:]' '[:lower:]') in
linux*)
echo "Patch anyof using sed on Linux"
sed -i "$SED_ARGS_ANYOF_PATCH" "$PATCHFILE"
;;
darwin*)
echo "Patch anyof using sed on OSX"
sed -i '' -e "$SED_ARGS_ANYOF_PATCH" "$PATCHFILE"
;;
msys*)
echo "This patch script does not run on Windows"
;;
*)
echo "This patch script does not run on $(uname)"
;;
esac
rm tmp.yml