1- #! /bin/bash
1+ #! /usr/ bin/env bash
22set -euo pipefail
33
4- defaultBaseUrl=" https://fingerprintjs.github.io/fingerprint-pro-server-api-openapi"
4+ # Resolve paths relative to the repository root, so the script can be run from
5+ # any working directory.
6+ cd " $( dirname " ${BASH_SOURCE[0]} " ) "
7+
8+ defaultBaseUrl=" https://fingerprintjs.github.io/openapi"
59schemaUrl=" ${1:- $defaultBaseUrl / schemas/ fingerprint-server-api-v4.yaml} "
610examplesBaseUrl=" ${2:- $defaultBaseUrl / examples} "
711
8- mkdir -p ./res
12+ CURL_OPTS=(-fSL --retry 3 --proto-redir ' =https' --connect-timeout 10 --max-time 300)
13+ if [[ " ${TRACE:- } " != " true" && " ${ACTIONS_STEP_DEBUG:- } " != " true" ]]; then
14+ CURL_OPTS+=(-s)
15+ fi
16+
17+ schemaDestination=" ./res/fingerprint-server-api.yaml"
18+ exampleBaseDestination=" ./test/mocks"
19+
20+ mkdir -p " $( dirname " $schemaDestination " ) "
921
10- curl -fSL --retry 3 -o ./res/fingerprint-server-api.yaml " $schemaUrl "
22+ echo " Downloading $schemaUrl to $schemaDestination "
23+ curl " ${CURL_OPTS[@]} " -o " $schemaDestination " " $schemaUrl "
1124
1225examples=(
1326 ' events/search/get_event_search_200.json'
@@ -27,17 +40,15 @@ examples=(
2740 ' errors/429_too_many_requests.json'
2841)
2942
30- baseDestination=" ./test/mocks"
31- mkdir -p " $baseDestination "
32-
3343for example in " ${examples[@]} " ; do
34- destinationPath=" $baseDestination /$example "
35- destinationDir=" $( dirname " $destinationPath " ) "
36- mkdir -p " $destinationDir "
44+ destinationPath=" $exampleBaseDestination /$example "
45+ mkdir -p " $( dirname " $destinationPath " ) "
3746
3847 exampleUrl=" $examplesBaseUrl /$example "
3948 echo " Downloading $exampleUrl to $destinationPath "
40- curl -fSL --retry 3 -o " $destinationPath " " $exampleUrl "
49+ curl " ${CURL_OPTS[@]} " -o " $destinationPath " " $exampleUrl "
4150done
4251
52+ echo " All OpenAPI schema downloads complete."
53+
4354./generate.sh
0 commit comments