-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-api.ps1
More file actions
32 lines (27 loc) · 1.23 KB
/
Copy pathgenerate-api.ps1
File metadata and controls
32 lines (27 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# PowerShell script to generate TypeScript API client
Write-Host "🚀 Starting API client generation..." -ForegroundColor Green
# Start the API server in background
Write-Host "📡 Starting API server..." -ForegroundColor Yellow
$apiProcess = Start-Process -FilePath "dotnet" -ArgumentList "run", "--project", "TodoApp.Api" -PassThru -WindowStyle Hidden
# Wait for API server to start
Write-Host "⏳ Waiting for API server to start..." -ForegroundColor Yellow
Start-Sleep -Seconds 10
try {
# Generate TypeScript client
Write-Host "🔧 Generating TypeScript client..." -ForegroundColor Yellow
nswag run nswag.json
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ TypeScript API client generated successfully!" -ForegroundColor Green
Write-Host "📁 Output: TodoApp.Web/src/api/generated/api-client.ts" -ForegroundColor Cyan
} else {
Write-Host "❌ Failed to generate TypeScript client" -ForegroundColor Red
}
} finally {
# Stop the API server
Write-Host "🛑 Stopping API server..." -ForegroundColor Yellow
if ($apiProcess -and !$apiProcess.HasExited) {
$apiProcess.Kill()
$apiProcess.WaitForExit()
}
}
Write-Host "🎉 Generation process completed!" -ForegroundColor Green