File tree Expand file tree Collapse file tree
dotnet/src/Dropbox.SignSandbox
java/src/main/java/com/dropbox/sign_sandbox Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ #
3+ # Copies example files from src_dir to dst_dir, skipping any whose operationId
4+ # exists in openapi-raw.yaml but not in openapi-sdk.yaml (i.e. endpoints hidden
5+ # from the SDK via the x-hideOn: sdk attribute). Matching is by PascalCase
6+ # filename: an operationId "templateUpdate" maps to "TemplateUpdateExample.<ext>".
7+
8+ set -e
9+
10+ DIR=$( cd " $( dirname " $0 " ) " && pwd)
11+ ROOT_DIR=" ${DIR} /.."
12+
13+ SRC_DIR=" $1 "
14+ DST_DIR=" $2 "
15+ EXT=" $3 "
16+
17+ if [[ -z " $SRC_DIR " || -z " $DST_DIR " || -z " $EXT " ]]; then
18+ printf " Usage: copy-examples-filtered <src_dir> <dst_dir> <file_extension>\n"
19+ exit 1
20+ fi
21+
22+ HIDDEN_PASCALS=()
23+ while IFS= read -r OP; do
24+ [ -z " $OP " ] && continue
25+ HIDDEN_PASCALS+=(" $( echo " ${OP: 0: 1} " | tr ' a-z' ' A-Z' ) ${OP: 1} " )
26+ done < <( comm -23 \
27+ <( grep ' operationId:' " ${ROOT_DIR} /openapi-raw.yaml" | sed ' s/.*operationId: //' | sort) \
28+ <( grep ' operationId:' " ${ROOT_DIR} /openapi-sdk.yaml" | sed ' s/.*operationId: //' | sort) )
29+
30+ for FILE in " ${SRC_DIR} " /* ." ${EXT} " ; do
31+ [ -f " $FILE " ] || continue
32+ BASENAME=$( basename " $FILE " " .$EXT " )
33+
34+ SKIP=0
35+ for PASCAL in " ${HIDDEN_PASCALS[@]} " ; do
36+ if [ " $BASENAME " = " ${PASCAL} Example" ]; then
37+ SKIP=1
38+ printf " Skipping (hidden from SDK): %s\n" " $( basename " $FILE " ) "
39+ break
40+ fi
41+ done
42+
43+ if [ $SKIP -eq 0 ]; then
44+ cp " $FILE " " $DST_DIR /"
45+ fi
46+ done
Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ printf "\n"
1414
1515bash " ${DIR} /bin/php" ./bin/generate-oas.php
1616
17- cp " ${DIR} /examples/ " * .cs " ${DIR} /sandbox/dotnet/src/Dropbox.SignSandbox/ "
18- cp " ${DIR} /examples/ " * .java " ${DIR} /sandbox/java/src/main/java/com/dropbox/sign_sandbox/ "
19- cp " ${DIR} /examples/ " * .php " ${DIR} /sandbox/php/src/ "
20- cp " ${DIR} /examples/ " * .py " ${DIR} /sandbox/python/src/ "
21- cp " ${DIR} /examples/ " * .rb " ${DIR} /sandbox/ruby/src/ "
22- cp " ${DIR} /examples/ " * .ts " ${DIR} /sandbox/node/src/ "
17+ " ${DIR} /bin/copy- examples-filtered " " ${DIR} /examples " " ${DIR} /sandbox/dotnet/src/Dropbox.SignSandbox" cs
18+ " ${DIR} /bin/copy- examples-filtered " " ${DIR} /examples " " ${DIR} /sandbox/java/src/main/java/com/dropbox/sign_sandbox" java
19+ " ${DIR} /bin/copy- examples-filtered " " ${DIR} /examples " " ${DIR} /sandbox/php/src" php
20+ " ${DIR} /bin/copy- examples-filtered " " ${DIR} /examples " " ${DIR} /sandbox/python/src" py
21+ " ${DIR} /bin/copy- examples-filtered " " ${DIR} /examples " " ${DIR} /sandbox/ruby/src" rb
22+ " ${DIR} /bin/copy- examples-filtered " " ${DIR} /examples " " ${DIR} /sandbox/node/src" ts
2323
2424printf " Success!\n"
Original file line number Diff line number Diff line change @@ -122,17 +122,17 @@ function copy_files()
122122 cp -r " ${DIR} /openapi-sdk.yaml" " ${SDK_DIR} /openapi-sdk.yaml"
123123
124124 if [[ " ${SDK} " == " dotnet" ]]; then
125- cp -r " ${DIR} /examples/ " * .cs " ${SDK_DIR} /examples/ "
125+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /examples" " ${SDK_DIR} /examples" cs
126126 elif [[ " ${SDK} " == " java-v2" ]] || [[ " ${SDK} " == " java-v1" ]]; then
127- cp -r " ${DIR} /examples/ " * .java " ${SDK_DIR} /examples/ "
127+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /examples" " ${SDK_DIR} /examples" java
128128 elif [[ " ${SDK} " == " node" ]]; then
129- cp -r " ${DIR} /examples/ " * .ts " ${SDK_DIR} /examples/ "
129+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /examples" " ${SDK_DIR} /examples" ts
130130 elif [[ " ${SDK} " == " php" ]]; then
131- cp -r " ${DIR} /examples/ " * .php " ${SDK_DIR} /examples/ "
131+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /examples" " ${SDK_DIR} /examples" php
132132 elif [[ " ${SDK} " == " python" ]]; then
133- cp -r " ${DIR} /examples/ " * .py " ${SDK_DIR} /examples/ "
133+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /examples" " ${SDK_DIR} /examples" py
134134 elif [[ " ${SDK} " == " ruby" ]]; then
135- cp -r " ${DIR} /examples/ " * .rb " ${SDK_DIR} /examples/ "
135+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /examples" " ${SDK_DIR} /examples" rb
136136 fi
137137
138138 php " ${DIR} /bin/update-sdk-version.php" ${SDK} ${VERSION}
Original file line number Diff line number Diff line change @@ -155,17 +155,17 @@ function copy_examples()
155155 mkdir -p " ${SDK_DIR} /examples"
156156
157157 if [[ " ${SDK} " == " dotnet" ]]; then
158- cp -r " ${DIR} /sandbox/dotnet/src/Dropbox.SignSandbox/ " * .cs " ${SDK_DIR} /examples/ "
158+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /sandbox/dotnet/src/Dropbox.SignSandbox" " ${SDK_DIR} /examples" cs
159159 elif [[ " ${SDK} " == " java-v2" || " ${SDK} " == " java-v1" ]]; then
160- cp -r " ${DIR} /sandbox/java/src/main/java/com/dropbox/sign_sandbox/ " * .java " ${SDK_DIR} /examples/ "
160+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /sandbox/java/src/main/java/com/dropbox/sign_sandbox" " ${SDK_DIR} /examples" java
161161 elif [[ " ${SDK} " == " node" ]]; then
162- cp -r " ${DIR} /sandbox/node/src/ " * .ts " ${SDK_DIR} /examples/ "
162+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /sandbox/node/src" " ${SDK_DIR} /examples" ts
163163 elif [[ " ${SDK} " == " php" ]]; then
164- cp -r " ${DIR} /sandbox/php/src/ " * .php " ${SDK_DIR} /examples/ "
164+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /sandbox/php/src" " ${SDK_DIR} /examples" php
165165 elif [[ " ${SDK} " == " python" ]]; then
166- cp -r " ${DIR} /sandbox/python/src/ " * .py " ${SDK_DIR} /examples/ "
166+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /sandbox/python/src" " ${SDK_DIR} /examples" py
167167 elif [[ " ${SDK} " == " ruby" ]]; then
168- cp -r " ${DIR} /sandbox/ruby/src/ " * .rb " ${SDK_DIR} /examples/ "
168+ " ${DIR} /bin/copy-examples-filtered " " ${DIR} /sandbox/ruby/src" " ${SDK_DIR} /examples" rb
169169 fi
170170}
171171
Original file line number Diff line number Diff line change @@ -7289,6 +7289,7 @@ paths:
72897289 x-hideOn :
72907290 - doc
72917291 - sdk
7292+ x-beta : closed
72927293 ' /template/update_files/{template_id} ' :
72937294 post :
72947295 tags :
Load diff This file was deleted.
Load diff This file was deleted.
Load diff This file was deleted.
Load diff This file was deleted.
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments