File size: 1,054 Bytes
9d54b72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
RED='\033[0;31m'
NC='\033[0m' # No Color
GREEN='\033[0;32m'


# Get the directory where the script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Get the current working directory
CURRENT_DIR="$(pwd)"

if [[ "$CURRENT_DIR" == "$SCRIPT_DIR" ]]; then
  pushd ../
fi

FILE="./tools/openapi.yaml"

echo "This test should only be done after the entire codebase has been compiled."

if [[ -z "$FILE" ]]; then
  echo "Error: OpenAPI file does not exist in tools directory."
  exit 1
fi

cp ./vcell-rest/target/generated/openapi.yaml "$FILE"

# Check if the file has changes compared to HEAD
if ! git diff --quiet -- "$FILE"; then
  echo ""
  echo -e "${RED}Error: The OpenAPI specification file has changed!"
  echo -e "This can mean some endpoint was created and did not generate clients, or "
  echo -e "an object internal to VCell has changed which the server uses as a DTO.${NC}"
  exit 1
fi

echo -e "${GREEN}Success: OpenAPI spec is up to date.${NC}"

if [[ "$CURRENT_DIR" == "$SCRIPT_DIR" ]]; then
  popd || exit
fi