chore: convert endpoints do openApi

Merged
GG
6mo ago
+5935-3111

OpenAPI Endpoint Migration

Migrates API endpoints from legacy addRoute to typed .get()/.post() with AJV schema validation for request and response payloads.

Migration Progress

AreaStatusEndpoints
info, stats, mailer✅ Migrated4
push, subscriptions✅ Migrated6
invites, custom-user-status, emoji-custom✅ Migrated8
commands✅ Migrated5
dm/im✅ Migrated12
chat, autotranslate✅ Migrated14
misc (spotlight, shield.svg)✅ Migrated3
rooms✅ Migrated (partial)28
teams✅ Migrated16
users✅ Migrated (partial)24
integrations, moderation✅ Migrated6
channels❌ Remaining42
groups❌ Remaining38
rooms (remaining)❌ Remaining2
users (remaining)❌ Remaining2

~66% migrated — 84 addRoute endpoints remaining (mostly channels and groups).

What's Included

  • Ajv 2020-12 upgrade — enables unevaluatedProperties for stricter schemas
  • Core/rest typings updates — IMeApiUser, ISubscription, IRoom, IIntegration type improvements
  • API framework — forbidden()/unauthorized()/success() signature updates, SuccessStatusCodes support
  • Response validation — $ref schemas for typed responses, validateBadRequestErrorResponse/validateUnauthorizedErrorResponse/validateForbiddenErrorResponse
  • Test updates — assertions updated for new error formats and ajv coercion behavior
  • Client-side fixes — type adjustments for readStateManager, userData, mapSubscriptionFromApi, RoomsTable, EditRoomInfo

Weak Schemas

508 response schemas still use { type: 'object' } without properties or $ref. These are functional but should be strengthened incrementally.

Commits (each migration is independently revertible)

Each commit contains the endpoint migration + its tests + related type fixes:

  1. chore: upgrade Ajv to 2020-12 and update core/rest typings
  2. chore: API framework changes
  3. chore(api): migrate info, stats, mailer
  4. chore(api): migrate push, subscriptions
  5. chore(api): migrate invites, custom-user-status, emoji-custom
  6. chore(api): migrate commands
  7. chore(api): migrate dm/im
  8. chore(api): migrate chat, autotranslate
  9. chore(api): migrate misc
  10. chore(api): migrate rooms
  11. chore(api): migrate teams
  12. chore(api): migrate users
  13. chore(api): migrate integrations, moderation
  14. chore: add migration tracking scripts and docs

Task: ARCH-2063