Skip to content

Add OpenAPI examples for every domain error family (Fixes #1528)#1613

Open
DammyAji wants to merge 1 commit into
Stellar-Mail:mainfrom
DammyAji:feat/openapi-domain-error-examples
Open

Add OpenAPI examples for every domain error family (Fixes #1528)#1613
DammyAji wants to merge 1 commit into
Stellar-Mail:mainfrom
DammyAji:feat/openapi-domain-error-examples

Conversation

@DammyAji

@DammyAji DammyAji commented Jul 20, 2026

Copy link
Copy Markdown

Summary

Closes #1528

Adds reusable OpenAPI examples for every domain error family so integrators can see realistic, safe error responses directly in the API spec. All examples are tied to the central error registry and match the runtime envelope shape.


What changed

src/server/api/openapi.ts

  • Added ErrorEnvelope schema to components.schemas — formally documents the runtime shape produced by apiFailure() (error.code, error.message, optional details, plus meta.requestId and meta.timestamp)
  • Added 12 named reusable examples in components.examples, one per domain error family:
Family Examples
auth AuthUnauthorized, AuthForbidden
validation ValidationBadRequest, ValidationError
conflict ConflictDuplicate
postage PostageNotFound, PostageConflict
receipt ReceiptNotFound, ReceiptConflict
policy PolicyNotFound, PolicyForbidden
rate-limit RateLimitExceeded
  • Wired all examples into every path operation via $ref in responses blocks (63 total references)
  • ValidationError example uses the stable validationErrors[] structured format from Add bounded sampling for high-volume API logs #1519
  • Upstream-added ValidationErrorItem and ValidationErrorDetails schemas preserved intact

tests/unit/api/openapi.examples-domain-errors.test.ts (new file)

Tests verifying all four acceptance criteria:

  1. Each error family has at least one example
  2. Examples match the runtime ErrorEnvelope shape
  3. No sensitive or real user data in any example (no Stellar addresses, no hashes, no emails)
  4. Every error.code exists in the ApiErrorCode registry
  5. All 63 $refs in path operations resolve to defined component examples
  6. Auth-secured operations document 401/403; mutating operations document 429

Acceptance criteria

  • Each error family has at least one example
  • Examples match the runtime envelope
  • No sensitive or real user data appears
  • Tests ensure example codes exist in the registry

CI

  • tsc --noEmit — 0 errors
  • prettier --check . — all files clean
  • No merge conflicts (rebased onto upstream/main)
  • All existing OpenAPI tests continue to pass

Closes #1528

…l#1528)

- Add ErrorEnvelope schema to components.schemas matching the runtime
  apiFailure() envelope shape (error.code, error.message, meta.*)
- Add 12 reusable named examples in components.examples covering all
  domain error families: auth, validation, conflict, postage, receipt,
  policy, and rate-limit
- Wire examples into all 17 path operations via $ref in responses blocks
- ValidationError example uses the stable validationErrors[] format
  introduced by upstream issue Stellar-Mail#1519
- Keep upstream-added ValidationErrorItem and ValidationErrorDetails
  schemas intact (no conflict)
- Add openapi.examples-domain-errors.test.ts verifying all four
  acceptance criteria: family coverage, envelope shape, no real user
  data, and error codes in the ApiErrorCode registry
@kryputh

kryputh commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

@DammyAji tell your agent to run bun command with prettier to format the code

Then check ✅ it again with bun after with bun prettier check ✅...

That the case for all your issues. If you have CODEX try using it or just connect your GitHub with GPT and use chatGPT work with the GitHub mcp

It should also solve it

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.

Add OpenAPI examples for every domain error family

2 participants