zrok/bin/generate_rest.sh

57 lines
1.9 KiB
Bash
Raw Normal View History

2022-07-22 16:52:36 +02:00
#!/bin/bash
set -euo pipefail
command -v swagger >/dev/null 2>&1 || {
2022-08-02 17:59:25 +02:00
echo >&2 "command 'swagger' not installed. see: https://github.com/go-swagger/go-swagger for installation"
2022-07-22 16:52:36 +02:00
exit 1
}
2022-08-02 17:59:25 +02:00
command -v openapi >/dev/null 2>&1 || {
echo >&2 "command 'openapi' not installed. see: https://www.npmjs.com/package/openapi-client for installation"
2024-03-25 19:54:05 +01:00
exit 1
2022-08-02 17:59:25 +02:00
}
2023-10-17 18:24:43 +02:00
command -v swagger-codegen 2>&1 || {
2024-03-25 21:08:49 +01:00
echo >&2 "command 'swagger-codegen' not installed. see: https://github.com/swagger-api/swagger-codegen for installation"
2024-03-25 19:54:05 +01:00
exit 1
}
command -v openapi-generator-cli 2>&1 || {
2024-03-25 21:08:49 +01:00
echo >&2 "command 'openapi-generator-cli' not installed. see: https://www.npmjs.com/package/@openapitools/openapi-generator-cli for installation"
2024-03-25 19:54:05 +01:00
exit 1
}
command -v realpath 2>&1 || {
2024-03-25 21:08:49 +01:00
echo >&2 "command 'realpath' not installed. see: https://www.npmjs.com/package/realpath for installation"
2024-03-25 19:54:05 +01:00
exit 1
2023-10-17 18:24:43 +02:00
}
2022-07-22 16:52:36 +02:00
scriptPath=$(realpath $0)
scriptDir=$(dirname "$scriptPath")
zrokDir=$(realpath "$scriptDir/..")
zrokSpec=$(realpath "$zrokDir/specs/zrok.yml")
2023-10-17 18:24:43 +02:00
pythonConfig=$(realpath "$zrokDir/bin/python_config.json")
2022-07-22 16:52:36 +02:00
echo "...generating zrok server"
swagger generate server -P rest_model_zrok.Principal -f "$zrokSpec" -s rest_server_zrok -t "$zrokDir" -m "rest_model_zrok" --exclude-main
2022-07-22 16:52:36 +02:00
echo "...generating zrok client"
swagger generate client -P rest_model_zrok.Principal -f "$zrokSpec" -c rest_client_zrok -t "$zrokDir" -m "rest_model_zrok"
2022-08-02 17:59:25 +02:00
echo "...generating web console js client"
2022-08-02 19:23:31 +02:00
openapi -s specs/zrok.yml -o ui/src/api -l js
echo "...generating agent console js client"
openapi-generator-cli generate -i agent/agentGrpc/agent.swagger.json -o agent/agentUiTs/src/api -g typescript-fetch
echo "...generating ts client"
2024-03-25 21:06:24 +01:00
openapi-generator-cli generate -i specs/zrok.yml -o sdk/nodejs/sdk/src/zrok/api -g typescript-node
2023-10-17 18:24:43 +02:00
echo "...generating python client"
swagger-codegen generate -i specs/zrok.yml -o sdk/python/sdk/zrok -c $pythonConfig -l python
git checkout rest_server_zrok/configure_zrok.go