CODEX_ADK/BACKEND/export-openapi.sh
jean-philippe 3fae2fcbe1 Initial commit: CODEX_ADK (Svrnty Console) MVP v1.0.0
This is the initial commit for the CODEX_ADK project, a full-stack AI agent
management platform featuring:

BACKEND (ASP.NET Core 8.0):
- CQRS architecture with 6 commands and 7 queries
- 16 API endpoints (all working and tested)
- PostgreSQL database with 5 entities
- AES-256 encryption for API keys
- FluentValidation on all commands
- Rate limiting and CORS configured
- OpenAPI/Swagger documentation
- Docker Compose setup (PostgreSQL + Ollama)

FRONTEND (Flutter 3.x):
- Dark theme with Svrnty branding
- Collapsible sidebar navigation
- CQRS API client with Result<T> error handling
- Type-safe endpoints from OpenAPI schema
- Multi-platform support (Web, iOS, Android, macOS, Linux, Windows)

DOCUMENTATION:
- Comprehensive API reference
- Architecture documentation
- Development guidelines for Claude Code
- API integration guides
- context-claude.md project overview

Status: Backend ready (Grade A-), Frontend integration pending

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 18:32:38 -04:00

72 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Export OpenAPI specification from running API
# This script starts the API, exports the Swagger JSON, and cleans up
set -e # Exit on error
echo "🚀 Starting Codex API..."
# Start the API in background
cd "$(dirname "$0")"
dotnet run --project Codex.Api/Codex.Api.csproj > /dev/null 2>&1 &
API_PID=$!
echo "⏳ Waiting for API to start (PID: $API_PID)..."
# Wait for API to be ready (max 30 seconds)
MAX_ATTEMPTS=30
ATTEMPT=0
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
if curl -f -s http://localhost:5246/swagger/v1/swagger.json > /dev/null 2>&1; then
echo "✅ API is ready!"
break
fi
ATTEMPT=$((ATTEMPT + 1))
echo " Attempt $ATTEMPT/$MAX_ATTEMPTS..."
sleep 1
done
# Check if process is still running
if ! kill -0 $API_PID 2>/dev/null; then
echo "❌ API failed to start"
exit 1
fi
# Check if we timed out
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
echo "❌ API did not respond within 30 seconds"
kill $API_PID 2>/dev/null || true
exit 1
fi
echo "📥 Downloading OpenAPI specification..."
# Export the swagger.json from HTTP endpoint (HTTPS not enabled in development)
if curl -f -s http://localhost:5246/swagger/v1/swagger.json -o docs/openapi.json; then
echo "✅ OpenAPI spec exported to docs/openapi.json"
# Pretty print some stats
ENDPOINTS=$(grep -o '"paths"' docs/openapi.json | wc -l)
FILE_SIZE=$(du -h docs/openapi.json | cut -f1)
echo "📊 Specification size: $FILE_SIZE"
echo "📊 Documented: $(grep -o '"/api/' docs/openapi.json | wc -l | tr -d ' ') endpoint(s)"
else
echo "❌ Failed to download OpenAPI spec"
kill $API_PID 2>/dev/null || true
exit 1
fi
echo "🛑 Stopping API..."
kill $API_PID 2>/dev/null || true
# Wait for process to terminate
wait $API_PID 2>/dev/null || true
echo "✨ Done! OpenAPI specification is ready at docs/openapi.json"
echo ""
echo "📝 Remember to:"
echo " 1. Review the generated openapi.json"
echo " 2. Update CHANGELOG.md if there are breaking changes"
echo " 3. Notify frontend teams of API updates"