/
nekstep
/
gvcli
Обзор
Документация
Войти
/
nekstep
/
gvcli
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
generate-api
41 строка
1 KB
Oleg Chirukhin
feat(api): new generated api
18 июл 2025, 02:04
18 июл 2025, 02:04
d4710d1
Код
Авторство
О чём код?
#!/usr/bin/env bash set -e # Change to the project root directory (where this script is located) cd "$(dirname "$0")" GEN_DIR="internal/generated-api" OPENAPI_FILE="api/openapi.yaml" # Add Go bin to PATH for this session (always, before checking) export PATH="$PATH:$(go env GOPATH)/bin" # Check if oapi-codegen binary is installed if ! command -v oapi-codegen >/dev/null 2>&1; then echo "oapi-codegen not found, installing..." go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest fi # Ensure oapi-codegen is in go.mod (optional, but keeps dependencies tidy) if ! grep -q 'github.com/oapi-codegen/oapi-codegen' go.mod; then echo "Adding oapi-codegen to go.mod..." go get github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest fi # Remove all previous generated files echo "[INFO] Removing previous generated files in $GEN_DIR..." rm -rf "$GEN_DIR"/* # Recreate the directory if needed mkdir -p "$GEN_DIR" # Generate types/models echo "[INFO] Generating Go types from $OPENAPI_FILE..." oapi-codegen -generate types -o "$GEN_DIR/models.go" -package generated_api "$OPENAPI_FILE" # Generate client echo "[INFO] Generating Go client from $OPENAPI_FILE..." oapi-codegen -generate client -o "$GEN_DIR/client.go" -package generated_api "$OPENAPI_FILE" echo "[SUCCESS] API client and models regenerated in $GEN_DIR."