CODEX_ADK/BACKEND/docs
jean-philippe f5a5c5697c fix: Remove duplicate endpoint registrations breaking Swagger/OpenAPI generation
Resolves Swagger conflict causing OpenAPI export to fail with HTTP 500 error.

Root Cause:
- OpenHarbor.CQRS v8.1.0-rc1 auto-registers and auto-documents ALL ICommandHandler and IQueryHandler implementations
- ManualEndpointRegistration.cs contained duplicate registrations for:
  * Commands: CreateConversation, StartAgentExecution
  * Queries: GetAgentExecution, GetConversation
- Duplicate routes violated OpenAPI 3.0 requirement for unique method/path combinations

Changes:
- Removed duplicate command registrations (lines 30-92)
- Removed duplicate query registrations (lines 44-124)
- Added explanatory comments about framework auto-registration
- File reduced from ~450 lines to ~320 lines

Impact:
-  Swagger endpoint now returns HTTP 200 (was HTTP 500)
-  OpenAPI export successful: docs/openapi.json (34KB, was 524B error)
-  All 16 endpoints properly documented
-  Frontend team can now generate TypeScript client
-  export-openapi.sh script working correctly

Verified:
- Valid OpenAPI 3.0.1 JSON structure
- 6 commands + 4 queries + 6 simple endpoints = 16 total
- No more route conflicts

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 20:19:58 -04:00
..
ARCHITECTURE.md Initial commit: CODEX_ADK (Svrnty Console) MVP v1.0.0 2025-10-26 18:32:38 -04:00
CHANGELOG.md Initial commit: CODEX_ADK (Svrnty Console) MVP v1.0.0 2025-10-26 18:32:38 -04:00
CODE-REVIEW-GUIDE.md feat: Code quality improvements and review infrastructure 2025-10-26 19:26:44 -04:00
COMPLETE-API-REFERENCE.md Initial commit: CODEX_ADK (Svrnty Console) MVP v1.0.0 2025-10-26 18:32:38 -04:00
openapi.json fix: Remove duplicate endpoint registrations breaking Swagger/OpenAPI generation 2025-10-26 20:19:58 -04:00
README.md Initial commit: CODEX_ADK (Svrnty Console) MVP v1.0.0 2025-10-26 18:32:38 -04:00

Codex API Documentation

This directory contains the API contract and documentation for the Codex API.

Files

openapi.json

⚠️ AUTO-GENERATED - DO NOT EDIT MANUALLY

The OpenAPI 3.0 specification for the Codex API. This file is the single source of truth for API contracts.

To regenerate:

./export-openapi.sh

This file should be regenerated whenever:

  • New Commands or Queries are added
  • Existing Commands/Queries are modified
  • Request/response types change
  • Authentication requirements change

ARCHITECTURE.md

High-level design decisions, technology stack, and architectural patterns used in the Codex API.

Update this when:

  • Major architectural changes occur
  • New patterns or frameworks are adopted
  • Infrastructure decisions are made

CHANGELOG.md

Breaking changes only - tracks API contract changes that require client updates.

Update this when:

  • Removing or renaming endpoints
  • Changing request/response schemas in incompatible ways
  • Modifying authentication requirements
  • Any change that would break existing API clients

Workflow

For Backend Developers

  1. Add/modify Commands or Queries with XML documentation:
/// <summary>Describes what this query does</summary>
/// <param name="parameter">Parameter description</param>
/// <response code="200">Success response description</response>
public record MyQuery { }
  1. Build the solution to generate XML documentation:
dotnet build
  1. Export OpenAPI spec:
./export-openapi.sh
  1. Update CHANGELOG.md if you made breaking changes

  2. Commit everything together:

git add .
git commit -m "Add MyQuery endpoint with OpenAPI spec"

For Frontend Developers

  1. Pull latest code to get updated docs/openapi.json

  2. Generate client code (optional):

# Example using openapi-generator
npx @openapitools/openapi-generator-cli generate \
  -i docs/openapi.json \
  -g typescript-fetch \
  -o src/api
  1. Check CHANGELOG.md for breaking changes

OpenAPI Spec Validation

The generated openapi.json includes:

  • All endpoints with HTTP methods
  • Complete request/response schemas
  • XML documentation comments
  • Authentication requirements (Bearer token)
  • API versioning information
  • Parameter descriptions
  • Response codes

CQRS Endpoint Conventions

OpenHarbor.CQRS auto-generates REST endpoints:

  • Commands: POST /api/command/{CommandName}
  • Queries: POST /api/query/{QueryName} or GET /api/query/{QueryName}
  • Dynamic Queries: POST /api/dynamicquery/{QueryItemType}

Example:

  • HealthQueryPOST /api/query/health
  • CreateUserCommandPOST /api/command/createuser

Tools

OpenAPI Validators

# Validate OpenAPI spec
npx @apidevtools/swagger-cli validate docs/openapi.json

Swagger UI

View API documentation locally:

dotnet run --project Codex.Api
# Open: http://localhost:5246/swagger

Questions?

  • Architecture questions: See ARCHITECTURE.md
  • Breaking changes: See CHANGELOG.md
  • API contract: See openapi.json
  • Code examples: See .claude-docs/ directory