generated from api-platform/api-platform
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to persist OpenAPI frol localhost
Run this script: it reads locahost/docs.json, and upate docs/openapi.json if necessary.
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
# Default values | ||
default_url=https://localhost/docs.json | ||
default_output_file_path="docs/openapi.json" | ||
|
||
url="${1:-$default_url}" | ||
output_file_path="${2:-$default_output_file_path}" | ||
|
||
# Use curl to fetch the JSON data from the provided URL | ||
json_data=$(curl -s "$url") | ||
|
||
# Check if the curl command was successful | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to fetch JSON data from $url" | ||
exit 1 | ||
fi | ||
|
||
# Write the JSON data to the specified output file | ||
echo "$json_data" > "$output_file_path" | ||
|
||
# Check if the write operation was successful | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to write JSON data to $output_file_path" | ||
exit 1 | ||
fi | ||
|
||
echo "JSON data successfully copied from $url to $output_file_path" | ||
|
||
# how to use it: | ||
# bash docs/persist.sh "http://example.com.docs.json" "docs/test.json" | ||
# or with default values: bash docs/persist.sh |