Skip to content

Commit 06b809e

Browse files
committed
fix(openapi): modify global not globalThis to prevent other modifications from breaking openapi
1 parent c4b375f commit 06b809e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/openapi.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ export async function openApi<
6969
// This is nuts, but there are testing frameworks or some other things
7070
// that seem to set window in Node. The OpenAPI infra will fail under that
7171
// circumstance.
72-
const window = globalThis.window;
73-
if (window) {
74-
delete (globalThis as { window: unknown }).window;
72+
const _window = global.window;
73+
if (_window) {
74+
delete (global as { window: unknown }).window;
7575
}
7676

7777
app.locals.openApiSpecification = await new OpenAPIFramework({ apiDoc: apiSpec })
@@ -81,8 +81,8 @@ export async function openApi<
8181
app.locals.logger.error(error, 'Failed to parse and load OpenAPI spec');
8282
});
8383

84-
if (window) {
85-
(globalThis as { window: unknown }).window = window;
84+
if (_window) {
85+
(global as { window: unknown }).window = _window;
8686
};
8787

8888
const defaultOptions: OAPIOpts = {

0 commit comments

Comments
 (0)