Skip to content

[High] Publish OpenAPI 3 specification and enforce API contract tests in CI #165

Description

@robertocarlous

Labels: priority/high, area/api, documentation, feature

Body:

## Summary
NeuroWealth has a growing REST surface (`/api/auth`, `/api/portfolio`, `/api/deposit`, `/api/vault`, `/api/admin`, etc.) but no machine-readable API contract. This slows frontend development, makes breaking changes likely, and blocks third-party integrations.

## Problem
- No OpenAPI/Swagger spec exists in the repo
- Response shapes vary (`{ error }` vs `{ success, data }` vs nested `transaction`)
- Zod validators exist per-route but are not exported as API documentation
- New contributors must read route files to understand request/response contracts

## User story
**As a** frontend or integrator developer,  
**I want** an accurate OpenAPI document for all public endpoints,  
**so that** I can generate clients, validate payloads, and catch breaking API changes in CI.

## Proposed solution
### Phase 1 — Spec generation
- Add `openapi.yaml` (or `docs/openapi.yaml`) covering:
  - Auth (`/api/auth/challenge`, `/verify`, `/logout`)
  - Portfolio, transactions, deposit, withdraw, vault
  - Health (`/health/live`, `/health/ready`)
  - Public vs authenticated vs admin routes clearly tagged
- Document auth scheme: `Bearer JWT`
- Include standard error schema:
  ```json
  { "error": "string", "details": "optional array/object" }

  ## Acceptance criteria

 OpenAPI 3.1 spec committed and versioned
 All public /api/* routes documented with request/response schemas
 Security schemes documented (Bearer, Admin token, Internal token)
 CI job validates spec syntax and runs contract tests on key endpoints
 README links to API docs and contribution guide for updating spec
 Breaking change policy documented (semver for API surface)

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions