Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed May 7, 2024
1 parent fca6253 commit 2157ac0
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 3 deletions.
1 change: 1 addition & 0 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
configured_endpoints: 1266
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e202d9b1bb049167a2efb5c3981c53af7bab82b6411bbbd684557eef5b435880.yml
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const config: JestConfigWithTsJest = {
'<rootDir>/deno/',
'<rootDir>/deno_tests/',
],
testPathIgnorePatterns: ['scripts'],
};

export default config;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"private": false,
"scripts": {
"test": "bin/check-test-server && yarn jest",
"test": "./scripts/test",
"build": "bash ./build",
"prepack": "echo 'to pack, run yarn build && (cd dist; yarn pack)' && exit 1",
"prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1",
Expand Down
34 changes: 34 additions & 0 deletions scripts/mock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

if [ -z "$1" ]; then
URL="$1"
shift
else
URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)"
fi

# Check if the URL is empty
if [ -z "$URL" ]; then
echo "Error: No OpenAPI spec path/url provided or found in .stats.yml"
exit 1
fi

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec prism mock "$URL" &> .prism.log &

# Wait for server to come online
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
echo -n "."
sleep 0.1
done

if grep -q "✖ fatal" ".prism.log"; then
cat .prism.log
exit 1
fi

echo
else
npm exec prism mock "$URL"
fi
29 changes: 29 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

function prism_is_running() {
curl --silent "http://localhost:4010" >/dev/null 2>&1
}

kill_server_on_port() {
pids=$(lsof -t -i tcp:"$1" || echo "")
if [ "$pids" != "" ]; then
kill "$pids"
echo "Stopped $pids."
fi
}

if ! prism_is_running; then
# When we exit this script, make sure to kill the background mock server process
trap 'kill_server_on_port 4010' EXIT

# Start the dev server
./scripts/mock --daemon

# Sanity check and print a nice error message
if ! ./bin/check-test-server; then
exit
fi
fi

# Run tests
./node_modules/.bin/jest
8 changes: 6 additions & 2 deletions src/resources/zones/zones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,18 @@ export interface Zone {
*/
name: string;

/**
* The name servers Cloudflare assigns to a zone
*/
name_servers: Array<string>;

/**
* DNS host at the time of switching to Cloudflare
*/
original_dnshost: string | null;

/**
* Original name servers before moving to Cloudflare Notes: Is this only available
* for full zones?
* Original name servers before moving to Cloudflare
*/
original_name_servers: Array<string> | null;

Expand Down

0 comments on commit 2157ac0

Please sign in to comment.