openai/openai-python

Public

mirrored fromhttps://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2bba15e71817a75e9b8517e09cb244bc144b50d0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

scripts/mock

52lines · modecode

1#!/usr/bin/env bash
2
3set -e
4
5cd "$(dirname "$0")/.."
6
7if [[ -n "$1" && "$1" != '--'* ]]; then
8 URL="$1"
9 shift
10else
11 URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)"
12fi
13
14# Check if the URL is empty
15if [ -z "$URL" ]; then
16 echo "Error: No OpenAPI spec path/url provided or found in .stats.yml"
17 exit 1
18fi
19
20echo "==> Starting mock server with URL ${URL}"
21
22# Run steady mock on the given spec
23if [ "$1" == "--daemon" ]; then
24 # Pre-install the package so the download doesn't eat into the startup timeout
25 npm exec --package=@stdy/cli@0.22.1 -- steady --version
26
27 npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &
28
29 # Wait for server to come online via health endpoint (max 30s)
30 echo -n "Waiting for server"
31 attempts=0
32 while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do
33 if ! kill -0 $! 2>/dev/null; then
34 echo
35 cat .stdy.log
36 exit 1
37 fi
38 attempts=$((attempts + 1))
39 if [ "$attempts" -ge 300 ]; then
40 echo
41 echo "Timed out waiting for Steady server to start"
42 cat .stdy.log
43 exit 1
44 fi
45 echo -n "."
46 sleep 0.1
47 done
48
49 echo
50else
51 npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
52fi