owncast/build/gen-api.sh
Gabe Kangas eed34b528e
Update API gen, cleanup, add missing property to status response (#3987)
* fix(api): remove invalid tag properties from components

* chore(api): update api validation/linter to use redocly

* fix(api): add missing streamTitle property to status object. Closes #3983

* chore: add redocly config file

* Commit updated API documentation

---------

Co-authored-by: Owncast <owncast@owncast.online>
2024-10-27 15:36:31 -07:00

38 lines
987 B
Bash
Executable file

#!/bin/bash
# go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest
# setup
package="generated"
folderPath="webserver/handlers/generated"
specPath="openapi.yaml"
# validate scripts are installed
if ! command -v redocly &>/dev/null; then
echo "Please install \`redocly cli\` before running this script: npm install -g @redocly/cli"
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/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest\` to install"
exit 1
fi
# validate schema
npx redocly lint $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