Skip to content

docs: accurate OpenAPI spec and API.md for all v1 routes#104

Merged
3m1n3nc3 merged 2 commits into
learnault:mainfrom
teethaking:docs/openapi-accuracy
Jul 20, 2026
Merged

docs: accurate OpenAPI spec and API.md for all v1 routes#104
3m1n3nc3 merged 2 commits into
learnault:mainfrom
teethaking:docs/openapi-accuracy

Conversation

@teethaking

@teethaking teethaking commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Closes #65 Closes #71

docs: accurate OpenAPI spec and API.md for all v1 routes

Summary

Makes the OpenAPI spec and checked-in API reference faithful to the running code. Every implemented route now has a corresponding operation with a unique operationId, correct security declarations, accurate request/response schemas, and no fictional fields or stale paths.

Changes

src/config/swagger.ts

  • Fixed servers[].url from /api/api/v1 so Swagger Try-it-out sends requests to the right base path
  • Added all 9 resource tags with descriptions (Health, Auth, Users, Modules, Credentials, Rewards, Referrals, Notifications, Sync, Employer)
  • Extended apis scan to include src/app.ts (health route) and src/routes/**/*.ts
  • Expanded top-level description with auth scheme, rate-limit header format, and error envelope

src/docs/schemas.ts

  • Added all previously missing component schemas: ErrorResponse, PublicUser, UpdateUserInput, ChangePasswordInput, UpdateWalletInput, ReferralCodeResponse, ApplyReferralInput, ApplyReferralResponse, ReferralStats, RegisterDeviceInput, NotificationPreferencesInput, NotificationLog, SyncProgressEvent, SyncCompletionEvent, SyncResult, SyncResponse, CandidateSummary, EmployerSearchResponse, CandidateProfile, ContactCandidateInput, ContactCandidateResponse
  • Fixed enum values to match runtime (learner/employer not LEARNER/EMPLOYER)
  • Corrected CredentialList.meta field names (hasNextPage/hasPrevPage to match actual response)

All controllers

  • Added operationId to all 28 operations
  • Added security: [] override on all public routes (auth endpoints, GET /modules, GET /modules/:id, GET /credentials/verify/:onChainId, GET /users/:id) so they don't inherit the global bearer requirement
  • Fixed stale paths in user.controller.ts: PUT /users/profilePATCH /users/me, added missing GET /users/:id, PATCH /users/password, PATCH /users/wallet operations
  • Added full JSDoc to employer.controller.ts — all three functions were completely undocumented
  • Added $ref: '#/components/schemas/ErrorResponse' to all error response statuses
  • Added description fields with behavioural detail (rate-limit notes, plan gating, idempotency behaviour, score threshold, etc.)

docs/API.md

  • Full rewrite reflecting actual controller behaviour
  • Base URL corrected to /api/v1 throughout (old doc used /v1/ directly and mismatched the mount path)
  • Removed fictional/stale fields: language, asset: "USDC", timeSpent, anonymousId, matchScore, availableForHire
  • Preview/stub routes (PATCH /users/password, PATCH /users/wallet) clearly marked with warnings
  • Added rate-limit table, plan-tier table, error code reference, and per-endpoint behaviour notes

Testing

  • TypeScript diagnostics: no errors on all 13 changed files
  • Swagger UI (/api-docs) will resolve all $ref schema references without broken links
  • No runtime code was modified — all changes are JSDoc comments and the swagger config

Acceptance criteria checklist

  • Every non-health route maps to one OpenAPI operation
  • All operationIds are unique (28 total)
  • Schemas match runtime response shapes
  • No fictional or stale endpoint presented as implemented
  • Public routes carry security: []; protected routes carry bearerAuth
  • docs/API.md matches the spec

- swagger.ts: fix server URL to /api/v1, add all 9 tags, extend
  apis scan to include app.ts for the health route
- schemas.ts: add all previously missing component schemas
  (ErrorResponse, PublicUser, UpdateUserInput, ChangePasswordInput,
  UpdateWalletInput, Referral*, Notification*, Sync*, Employer*);
  fix enum values to match runtime (learner/employer, not LEARNER)
- All controllers: add operationId to every operation (28 total);
  add security:[] override on public routes; fix stale paths in
  user.controller.ts (/users/profile -> /users/me, PUT -> PATCH);
  add JSDoc to employer.controller.ts (was fully undocumented);
  add missing getUserById/changePassword/updateWallet operations;
  add ErrorResponse refs on all error statuses
- docs/API.md: full rewrite reflecting actual runtime behaviour;
  correct base URL to /api/v1; remove fictional fields (language,
  USDC asset, timeSpent, anonymousId); mark stub routes as Preview
@3m1n3nc3
3m1n3nc3 merged commit 0096206 into learnault:main Jul 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Complete OpenAPI and Checked-In API Documentation Feature: Introduce Typed Status Enums and Transition Guards

2 participants