Skip to content

Commit a8f2253

Browse files
authored
Fix fetching (#1719)
1 parent 7c7d715 commit a8f2253

File tree

23 files changed

+625
-150
lines changed

23 files changed

+625
-150
lines changed

.changeset/fresh-icons-draw.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-fetch": patch
3+
---
4+
5+
Remove nanoid from dependencies

.changeset/little-snails-shake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-fetch": patch
3+
---
4+
5+
Fix "failed to execute fetch on Window" error

.changeset/twenty-nails-change.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-fetch": patch
3+
---
4+
5+
Revert customFetch API back to `fetch(input: Request)`

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ jobs:
3939
run_install: true
4040
- run: pnpm run build
4141
- run: pnpm test
42+
test-e2e:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: actions/setup-node@v4
47+
with:
48+
node-version: 22
49+
- uses: pnpm/action-setup@v4
50+
with:
51+
version: latest
52+
run_install: true
53+
- run: pnpm exec playwright install --with-deps
54+
- run: pnpm run test-e2e
4255
test-macos:
4356
runs-on: macos-latest
4457
steps:

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@
1212
"lint": "pnpm run -r --parallel --aggregate-output lint",
1313
"format": "pnpm run -r --parallel --aggregate-output format",
1414
"test": "pnpm run -r --parallel --aggregate-output test",
15+
"test-e2e": "pnpm run -r --parallel --aggregate-output test-e2e",
1516
"version": "pnpm run build && changeset version && pnpm i"
1617
},
1718
"devDependencies": {
1819
"@biomejs/biome": "^1.8.1",
1920
"@changesets/changelog-github": "^0.5.0",
2021
"@changesets/cli": "^2.27.5",
22+
"@playwright/test": "^1.44.1",
23+
"@types/node": "^20.14.7",
2124
"del-cli": "^5.1.0",
2225
"prettier": "^3.3.2",
23-
"typescript": "^5.4.5"
26+
"typescript": "^5.4.5",
27+
"vitest": "^1.6.0"
2428
}
2529
}

packages/openapi-fetch/examples/nextjs/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"react-dom": "18.3.1"
1313
},
1414
"devDependencies": {
15-
"@types/node": "20.14.6",
1615
"@types/react": "18.3.1",
1716
"@types/react-dom": "18.3.0",
1817
"openapi-typescript": "workspace:^",

packages/openapi-fetch/examples/vue-3/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
},
1717
"devDependencies": {
1818
"@tsconfig/node20": "^20.1.4",
19-
"@types/node": "^20.14.6",
2019
"@vitejs/plugin-vue": "^5.0.5",
2120
"@vue/tsconfig": "^0.5.1",
2221
"openapi-typescript": "workspace:^",

packages/openapi-fetch/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,17 @@
5454
"build:cjs": "esbuild --bundle src/index.js --format=cjs --outfile=dist/cjs/index.cjs && cp dist/index.d.ts dist/cjs/index.d.cts",
5555
"format": "biome format . --write",
5656
"lint": "biome check .",
57-
"generate-types": "openapi-typescript test/fixtures/api.yaml -o test/fixtures/api.d.ts",
57+
"generate-types": "openapi-typescript -c test/redocly.yaml",
5858
"pretest": "pnpm run generate-types",
5959
"test": "pnpm run \"/^test:/\"",
6060
"test:js": "vitest run",
6161
"test:ts": "tsc --noEmit",
62+
"test-e2e": "playwright test",
63+
"e2e-vite-build": "vite build test/fixtures/e2e",
64+
"e2e-vite-start": "vite preview test/fixtures/e2e",
6265
"version": "pnpm run prepare && pnpm run build"
6366
},
6467
"dependencies": {
65-
"nanoid": "^5.0.7",
6668
"openapi-typescript-helpers": "workspace:^"
6769
},
6870
"devDependencies": {
@@ -76,6 +78,6 @@
7678
"openapi-typescript-fetch": "^2.0.0",
7779
"superagent": "^9.0.2",
7880
"typescript": "^5.4.5",
79-
"vitest": "^1.6.0"
81+
"vite": "^5.3.1"
8082
}
8183
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { defineConfig, devices } from "@playwright/test";
2+
3+
const PORT = Number.parseInt(process.env.PORT || 4173 || "", 10);
4+
5+
export default defineConfig({
6+
testMatch: "test/**/*.e2e.ts",
7+
webServer: {
8+
command: "pnpm run e2e-vite-build && pnpm run e2e-vite-start",
9+
port: PORT,
10+
},
11+
use: {
12+
baseURL: `http://localhost:${PORT}`,
13+
},
14+
projects: [
15+
{
16+
name: "chrome",
17+
use: { ...devices["Desktop Chrome"] },
18+
},
19+
{
20+
name: "firefox",
21+
use: { ...devices["Desktop Firefox"] },
22+
},
23+
{
24+
name: "webkit",
25+
use: { ...devices["Desktop Safari"] },
26+
},
27+
],
28+
});

packages/openapi-fetch/src/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface ClientOptions extends Omit<RequestInit, "headers"> {
1515
/** set the common root URL for all API requests */
1616
baseUrl?: string;
1717
/** custom fetch (defaults to globalThis.fetch) */
18-
fetch?: (input: string, init?: RequestInit) => Promise<Response>;
18+
fetch?: (input: Request) => Promise<Response>;
1919
/** global querySerializer */
2020
querySerializer?: QuerySerializer<unknown> | QuerySerializerOptions;
2121
/** global bodySerializer */

0 commit comments

Comments
 (0)