Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions sync.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

defaultBaseUrl="https://fingerprintjs.github.io/fingerprint-pro-server-api-openapi"
# Resolve paths relative to the repository root, so the script can be run from
# any working directory.
cd "$(dirname "${BASH_SOURCE[0]}")"

defaultBaseUrl="https://fingerprintjs.github.io/openapi"
schemaUrl="${1:-$defaultBaseUrl/schemas/fingerprint-server-api-v4.yaml}"
examplesBaseUrl="${2:-$defaultBaseUrl/examples}"

mkdir -p ./res
CURL_OPTS=(-fSL --retry 3 --proto-redir '=https' --connect-timeout 10 --max-time 300)
if [[ "${TRACE:-}" != "true" && "${ACTIONS_STEP_DEBUG:-}" != "true" ]]; then
CURL_OPTS+=(-s)
fi

schemaDestination="./res/fingerprint-server-api.yaml"
exampleBaseDestination="./test/mocks"

mkdir -p "$(dirname "$schemaDestination")"

curl -fSL --retry 3 -o ./res/fingerprint-server-api.yaml "$schemaUrl"
echo "Downloading $schemaUrl to $schemaDestination"
curl "${CURL_OPTS[@]}" -o "$schemaDestination" "$schemaUrl"

examples=(
'events/search/get_event_search_200.json'
Expand All @@ -27,17 +40,15 @@ examples=(
'errors/429_too_many_requests.json'
)

baseDestination="./test/mocks"
mkdir -p "$baseDestination"

for example in "${examples[@]}"; do
destinationPath="$baseDestination/$example"
destinationDir="$(dirname "$destinationPath")"
mkdir -p "$destinationDir"
destinationPath="$exampleBaseDestination/$example"
mkdir -p "$(dirname "$destinationPath")"

exampleUrl="$examplesBaseUrl/$example"
echo "Downloading $exampleUrl to $destinationPath"
curl -fSL --retry 3 -o "$destinationPath" "$exampleUrl"
curl "${CURL_OPTS[@]}" -o "$destinationPath" "$exampleUrl"
done

echo "All OpenAPI schema downloads complete."

./generate.sh
Loading