Skip to content

Added global- and request scope middleware distinction to documentation#2833

Open
eirikblekesaune wants to merge 1 commit into
openapi-ts:mainfrom
eirikblekesaune:feature/middleware-global-request-distinction
Open

Added global- and request scope middleware distinction to documentation#2833
eirikblekesaune wants to merge 1 commit into
openapi-ts:mainfrom
eirikblekesaune:feature/middleware-global-request-distinction

Conversation

@eirikblekesaune

Copy link
Copy Markdown

The implementation supports two types of middleware: global per client instance, and middleware per request. The documentation did not mention this distinction.

Changes

Adds section about the distinction between adding middleware to the client instance and to the request call.
This helps users working with server- or BFF-based application to understand the statefulness of middleware for a client instance.

How to Review

Asses whether this addition to the documentation describes the actual implementation in

async function coreFetch(schemaPath, fetchOptions) {
const {
baseUrl: localBaseUrl,
fetch = baseFetch,
Request = CustomRequest,
headers,
params = {},
parseAs = "json",
querySerializer: requestQuerySerializer,
bodySerializer = globalBodySerializer ?? defaultBodySerializer,
pathSerializer: requestPathSerializer,
body,
middleware: requestMiddlewares = [],
...init
} = fetchOptions || {};
let finalBaseUrl = baseUrl;
if (localBaseUrl) {
finalBaseUrl = removeTrailingSlash(localBaseUrl) ?? baseUrl;
}

This adds a conceptual distinction for middleware that is not previously described in the documentation, so ensure that the concepts are rooted in the shared concepts of the contributors.

Checklist

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

The implementation supports two types of middleware: global per client instance, and middleware per request.
The documentation did not mention this distinction.
@eirikblekesaune eirikblekesaune requested a review from a team as a code owner June 22, 2026 08:21
@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 11bab47

@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 11bab47

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

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.

1 participant