Skip to content

Conversation

@lindseystead
Copy link

Fixes #2517

Removed nested onError function that caused TypeScript error "Cannot find name 'onError'". The correct syntax is to directly return an Error instance from the onError method, not nest another onError function inside it.

Changes

  • Fixed incorrect onError syntax in docs/openapi-fetch/middleware-auth.md
  • Fixed incorrect onError syntax in docs/openapi-fetch/api.md

The documentation examples now correctly show:
async onError({ error }) {
// wrap errors thrown by fetch
return new Error("Oops, fetch failed", { cause: error });
},Instead of the incorrect nested function syntax that caused TypeScript errors.

How to Review

  1. Check that the onError examples in both files now match the correct pattern shown in the test files (packages/openapi-fetch/test/middleware/middleware.test.ts)
  2. Verify the syntax aligns with the actual implementation in packages/openapi-fetch/src/index.js
  3. Confirm the examples are consistent with other onError examples already in the same documentation files (lines 128-130 in middleware-auth.md)

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

Fixes openapi-ts#2517

Removed nested onError function that caused TypeScript error.
The correct syntax is to directly return an Error instance from
the onError method, not nest another onError function inside it.
@lindseystead lindseystead requested a review from a team as a code owner November 28, 2025 18:33
@lindseystead lindseystead requested a review from kerwanp November 28, 2025 18:33
@netlify
Copy link

netlify bot commented Nov 28, 2025

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 35abf54

@changeset-bot
Copy link

changeset-bot bot commented Nov 28, 2025

🦋 Changeset detected

Latest commit: 35abf54

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
openapi-fetch Patch
openapi-react-query Patch
swr-openapi Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lindseystead
Copy link
Author

The failing CI tests are in packages/openapi-typescript/test/node-api.test.ts and seem to be due to a 404 from https://raw.githubusercontent.com/Redocly/redocly-cli/.../openapi.yaml, which looks unrelated to this docs-only change. Let me know if you'd like me to adjust anything.

@sacha-c
Copy link

sacha-c commented Dec 3, 2025

The failing CI tests are in packages/openapi-typescript/test/node-api.test.ts and seem to be due to a 404 from https://raw.githubusercontent.com/Redocly/redocly-cli/.../openapi.yaml, which looks unrelated to this docs-only change. Let me know if you'd like me to adjust anything.

Indeed, I've address this in a separate PR a few weeks back which is awaiting review: #2522

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.

Middleware OnError wrap docs wrong

2 participants