feat(openapi-fetch): enable middleware request param module augmentation #2527
+8
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Decided to open PR in lieu of issue.
I just changed the
.d.tsfile manually and extracted theMiddlewareRequestParamsinto their own interface. It opens up the possibility for using TS module augmentation to add parameters to theparamsproperty and use those in the middleware.My use-case is changing authentication logic based on a variable that isn't passed through to the API being invoked.
How to Review
Look at the file, I guess? 🤗
Also, I would be open to going deeper in a follow-up PR to look into how the client facing types could mirror the custom parameter added, if this is indeed an avenue you're open to exploring.
Checklist
(skipped all since it's just a small TS update and I didn't pull to local)
docs/updated (if necessary)pnpm run update:examplesrun (only applicable for openapi-typescript)