Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Most files in the project are autogenerated by [openapi-generator](https://opena
You need `openapi-generator` to run code generation. There are many ways described in the [readme](https://github.com/OpenAPITools/openapi-generator).
In the project we use Docker image `openapitools/openapi-generator-cli` for code generation.

You can just run `sh ./scripts/generate.sh` script and it will do all the work.
You can just run `./scripts/generate.sh` script and it will do all the work.

To download fresh OpenAPI schema run `sh ./scripts/sync.sh`
To download fresh OpenAPI schema run `./scripts/sync.sh`
### Auto-generated test files and FILES manifest

The generation script cleans fully managed output (`src`, `docs`, `README.md`, and `composer.json`) before running `openapi-generator`. It intentionally preserves `test`, because PHP test files generated by OpenAPI Generator are scaffolding: they are created when missing, but existing test files are not overwritten on later generation runs.
Expand Down
28 changes: 15 additions & 13 deletions scripts/sync.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
#!/bin/bash
#!/usr/bin/env bash

source "$(dirname "${BASH_SOURCE[0]}")/common.sh"

defaultBaseUrl="https://fingerprintjs.github.io/fingerprint-pro-server-api-openapi"
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)
CURL_OPTS=(-fSL --retry 3 --proto-redir '=https' --connect-timeout 10 --max-time 300)
Comment thread
erayaydin marked this conversation as resolved.
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")"

require_cmd curl

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

examples=(
'events/get_event_200.json'
Expand All @@ -40,16 +43,15 @@ examples=(
'errors/500_internal_server_error.json'
)

baseDestination="./test/mocks"

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\`..."
echo "Downloading $exampleUrl to $destinationPath"
curl "${CURL_OPTS[@]}" -o "$destinationPath" "$exampleUrl"
done

echo "All OpenAPI schema downloads complete."

./scripts/generate.sh
Loading