Skip to content

Refactor: Migrate API Validation to OpenAPI-Based Request/Response Schemas #482

Description

@Smartdevs17

Context

API validation uses ad-hoc Zod schemas scattered across route handlers. There is no single source of truth for API contracts.

Current Limitation/Problem

Request validation is inconsistent. Some routes validate, others do not. There is no generated OpenAPI spec, making client generation and documentation difficult.

Expected Outcome

All API endpoints use OpenAPI 3.1 schemas as the single source of truth, with automatic request validation, response serialization, and documentation generation.

Acceptance Criteria

  • Define OpenAPI schemas for all request/response types
  • Generate Zod validation schemas from OpenAPI definitions
  • Auto-validate all incoming requests against OpenAPI spec
  • Auto-serialize and validate responses
  • Generate OpenAPI spec document from route definitions
  • Expose Swagger UI at /api-docs
  • Catch schema violations in tests via OpenAPI conformance check
  • Support for oneOf, anyOf, allOf composition patterns
  • Deprecation annotations in OpenAPI with sunset headers

Technical Scope

  • packages/api-spec/ - OpenAPI definitions package
  • Code generation from OpenAPI to Zod
  • backend/src/middleware/openapi-validator.ts - validation middleware
  • swagger-ui-express or Scalar for docs UI
  • Test utility: validateResponseAgainstOpenAPI
  • Edge cases: file uploads, binary responses, streaming endpoints

Metadata

Metadata

Assignees

Labels

200-points200 point issueStellar WaveIssues in the Stellar wave programdrips-waveIssues in the Drips Wave programhighHigh complexity issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions