39 lines
1.5 KiB
Bash
Executable File
39 lines
1.5 KiB
Bash
Executable File
#!/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
|
|
|
|
echo "📋 Step 2: Ensuring frontend container is running..."
|
|
docker compose up -d static-frontend
|
|
|
|
echo "📋 Step 3: Installing/updating frontend dependencies..."
|
|
docker compose exec static-frontend npm install --legacy-peer-deps
|
|
|
|
echo "📋 Step 4: Generating TypeScript types from OpenAPI schema..."
|
|
docker compose exec static-frontend npx openapi-typescript openapi-schema.json -o src/api-types.ts
|
|
|
|
echo "📋 Step 5: Running TypeScript type checking..."
|
|
docker compose exec static-frontend npm run type-check
|
|
|
|
echo "✅ TypeScript generation complete!"
|
|
echo "📄 Generated files:"
|
|
echo " - client/openapi-schema.json (OpenAPI schema)"
|
|
echo " - client/src/api-types.ts (TypeScript types)"
|
|
echo " - client/src/api-client.ts (API client utilities)"
|
|
echo ""
|
|
echo "💡 Usage in your React components:"
|
|
echo " import { apiClient, adminApi, healthApi } from './api-client';"
|
|
echo " import type { LobbyModel, SessionModel } from './api-client';"
|