Skip to content

fix(openapi): align error schema with nested error contract - #942

Closed
mopxam-art wants to merge 1 commit into
Heliobond:mainfrom
mopxam-art:fix/openapi-error-schema
Closed

mopxam-art wants to merge 1 commit into
Heliobond:mainfrom
mopxam-art:fix/openapi-error-schema

Conversation

@mopxam-art

Copy link
Copy Markdown

Why

src/lib/swagger.ts defined the shared Error schema using the legacy flat shape { error: string }. However, the documented standard across the backend runtime (src/middleware/errors.ts) is { error: { code, message } }. Because openapi.json and packages/api-client are generated from the spec, client consumers were typed to expect a flat string instead of the nested contract, breaking structured error handling.

What

  • Redefined components.schemas.Error in src/lib/swagger.ts to { error: { code: string, message: string } } with required fields and descriptive examples.
  • Added reusable component error responses (BadRequest, Unauthorized, Forbidden, NotFound, Conflict, TooManyRequests, InternalServerError) in components.responses.
  • Documented error response status codes (400, 401, 403, 404, 409, 429, 500) across all 22 operations linking to #/components/schemas/Error.
  • Re-exported openapi.json and regenerated typed client in packages/api-client/src/types.ts.
  • Updated test expectations in src/__tests__/openapi-contract.test.ts to assert the nested error contract.

Verified

  • Added comprehensive unit tests in src/__tests__/openapi-error-schema.test.ts (107 passing) covering boundaries, status codes, operation mappings, invalid payload rejections, and sequential stress validations.
  • All 123 test suites (1,526 tests) passed (npm test).
  • OpenAPI spec verification (npm run openapi:check) and typecheck (npx tsc --noEmit) clean with 0 errors.
  • Client build (npm run api-client:build) and production build (npm run build) succeeded.

Closes #925

Payout coordinate:
USDC (EVM / Base / Arbitrum / ERC20): 0x387c064ccf729a4846b62e95dc6b70e4d4c41e73

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.

OpenAPI Error schema documents the flat legacy shape { error: string } instead of the nested { error: { code, message } } contract

2 participants