#!/bin/bash # Comprehensive script to generate TypeScript types from FastAPI OpenAPI schema. # This script coordinates between the server and frontend containers to: # 1. Generate OpenAPI schema from FastAPI server # 2. Generate TypeScript types from the schema # 3. Ensure frontend container dependencies are installed set -e echo "🚀 Starting OpenAPI TypeScript generation process..." # Change to the project directory cd "$(dirname "$0")" echo "📋 Step 1: Generating OpenAPI schema from FastAPI server..." docker compose exec server uv run python3 generate_schema_simple.py docker compose cp server:/client/openapi-schema.json ./client/openapi-schema.json echo "📋 Step 2: Ensuring frontend container is running..." docker compose up -d client echo "📋 Step 3: Installing/updating frontend dependencies..." docker compose exec client npm install --legacy-peer-deps echo "📋 Step 4: Generating TypeScript types from OpenAPI schema..." docker compose exec client npx openapi-typescript openapi-schema.json -o src/api-types.ts echo "📋 Step 5: Automatically updating API client and evolution checker..." docker compose exec client node update-api-client.js echo "📋 Step 6: Running TypeScript type checking..." docker compose exec client npm run type-check echo "📋 Step 7: Testing dynamic path usage..." docker compose exec client npm run test-dynamic-paths echo "📋 Step 8: Running API evolution check..." docker compose exec client node check-api-evolution.js echo "✅ TypeScript generation and API client update complete!" echo "📄 Generated files:" echo " - client/openapi-schema.json (OpenAPI schema)" echo " - client/src/api-types.ts (TypeScript types)" echo "" echo "📄 Updated files:" echo " - client/src/api-client.ts (automatically updated with new endpoints)" echo " - client/src/api-evolution-checker.ts (updated known endpoints)" echo "" echo "💡 Usage in your React components:" echo " import { apiClient, adminApi, healthApi } from './api-client';" echo " import type { LobbyModel, SessionModel } from './api-client';"