mirror of
https://github.com/owncast/owncast.git
synced 2024-11-25 06:12:23 +03:00
42 lines
955 B
Bash
42 lines
955 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
# go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest
|
||
|
|
||
|
# setup
|
||
|
package="generated"
|
||
|
folderPath="handler/generated"
|
||
|
specPath="spec/openapi.yaml"
|
||
|
|
||
|
# validate scripts are installed
|
||
|
if ! command -v swagger-cli &> /dev/null
|
||
|
then
|
||
|
echo "Please install \`swagger-cli\` before running this script"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if ! command -v oapi-codegen &> /dev/null
|
||
|
then
|
||
|
echo "Please install \`oapi-codegen\` before running this script"
|
||
|
echo "Hint: run \`go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest\` to install"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# validate schema
|
||
|
swagger-cli validate $specPath
|
||
|
if [ $? -ne 0 ];
|
||
|
then
|
||
|
echo "Open API specification is not valid"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# cleanup
|
||
|
rm -r $folderPath
|
||
|
mkdir -p $folderPath
|
||
|
|
||
|
# codegen
|
||
|
oapi-codegen -generate types -o $folderPath/$package-types.gen.go -package $package $specPath
|
||
|
oapi-codegen -generate "chi-server" -o $folderPath/$package.gen.go -package $package $specPath
|
||
|
|
||
|
# go
|
||
|
go mod tidy
|