Skip to content

Commit eda1829

Browse files
authored
Merge pull request #1936 from seriouslag/chore/update-to-vitest-3
chore(test): update to vitest 3
2 parents b885405 + ba2e5ca commit eda1829

File tree

118 files changed

+3207
-3343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+3207
-3343
lines changed

.changeset/sharp-kangaroos-try.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
fix: add return type to TanStack Query mutations

examples/openapi-ts-axios/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@
2222
},
2323
"devDependencies": {
2424
"@hey-api/openapi-ts": "workspace:*",
25+
"@config/vite-base": "workspace:*",
2526
"@types/react": "19.0.1",
2627
"@types/react-dom": "19.0.1",
27-
"@typescript-eslint/eslint-plugin": "7.18.0",
28-
"@typescript-eslint/parser": "7.15.0",
29-
"@vitejs/plugin-react": "4.3.1",
28+
"@typescript-eslint/eslint-plugin": "8.29.1",
29+
"@typescript-eslint/parser": "8.29.1",
30+
"@vitejs/plugin-react": "4.4.0-beta.1",
3031
"autoprefixer": "10.4.19",
3132
"eslint": "9.17.0",
32-
"eslint-plugin-react-hooks": "4.6.2",
33+
"eslint-plugin-react-hooks": "5.2.0",
3334
"eslint-plugin-react-refresh": "0.4.7",
3435
"postcss": "8.4.41",
3536
"prettier": "3.4.2",
3637
"tailwindcss": "3.4.9",
37-
"typescript": "5.5.3",
38-
"vite": "6.0.13"
38+
"typescript": "5.8.3",
39+
"vite": "6.2.6"
3940
}
4041
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { createViteConfig } from '@config/vite-base';
12
import react from '@vitejs/plugin-react';
2-
import { defineConfig } from 'vite';
33

44
// https://vitejs.dev/config/
5-
export default defineConfig({
5+
export default createViteConfig({
66
plugins: [react()],
77
});
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"openapi": "3.1.0",
3+
"info": {
4+
"title": "Petstore API",
5+
"version": "1.0.0",
6+
"description": "A sample API that uses a petstore as an example"
7+
},
8+
"servers": [
9+
{
10+
"url": "http://localhost:3000/v3"
11+
}
12+
],
13+
"paths": {
14+
"/pets/{petId}": {
15+
"get": {
16+
"summary": "Find pet by ID",
17+
"operationId": "showPetById",
18+
"parameters": [
19+
{
20+
"name": "petId",
21+
"in": "path",
22+
"required": true,
23+
"schema": {
24+
"type": "string"
25+
}
26+
}
27+
],
28+
"responses": {
29+
"200": {
30+
"description": "Pet found",
31+
"content": {
32+
"application/json": {
33+
"schema": {
34+
"type": "object",
35+
"properties": {
36+
"id": {
37+
"type": "string"
38+
},
39+
"name": {
40+
"type": "string"
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}
47+
}
48+
}
49+
},
50+
"/pets": {
51+
"get": {
52+
"summary": "List all pets",
53+
"operationId": "listPets",
54+
"responses": {
55+
"200": {
56+
"description": "A list of pets",
57+
"content": {
58+
"application/json": {
59+
"schema": {
60+
"type": "array",
61+
"items": {
62+
"type": "object",
63+
"properties": {
64+
"id": {
65+
"type": "string"
66+
},
67+
"name": {
68+
"type": "string"
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
75+
}
76+
}
77+
},
78+
"post": {
79+
"summary": "Create a pet",
80+
"operationId": "createPets",
81+
"responses": {
82+
"201": {
83+
"description": "Pet created"
84+
}
85+
}
86+
}
87+
}
88+
}
89+
}

examples/openapi-ts-fastify/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
},
1616
"devDependencies": {
1717
"@hey-api/openapi-ts": "workspace:*",
18+
"@config/vite-base": "workspace:*",
1819
"eslint": "9.17.0",
1920
"prettier": "3.4.2",
20-
"typescript": "5.5.3",
21-
"vitest": "1.6.0"
21+
"typescript": "5.8.3",
22+
"vite": "6.2.6",
23+
"vitest": "3.1.1"
2224
}
2325
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { buildServer } from './server';
22

3-
const fastify = buildServer();
4-
5-
fastify.listen({ port: 3000 }, function (err) {
6-
if (err) {
7-
fastify.log.error(err);
8-
process.exit(1);
9-
}
3+
buildServer().then((fastify) => {
4+
fastify.listen({ port: 3000 }, function (err) {
5+
if (err) {
6+
fastify.log.error(err);
7+
process.exit(1);
8+
}
9+
});
1010
});

examples/openapi-ts-fastify/src/server.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
import { readFileSync } from 'node:fs';
2+
import { join } from 'node:path';
3+
14
import Fastify from 'fastify';
25
import glue from 'fastify-openapi-glue';
36

47
import { serviceHandlers } from './handlers';
58

6-
export const buildServer = () => {
9+
export const buildServer = async () => {
710
const fastify = Fastify();
811

9-
const specification = fetch(
10-
'https://gist.githubusercontent.com/seriousme/55bd4c8ba2e598e416bb5543dcd362dc/raw/cf0b86ba37bb54bf1a6bf047c0ecf2a0ce4c62e0/petstore-v3.1.json',
11-
)
12-
.then((reply) => reply.json())
13-
.then((data) => data);
14-
console.log(specification);
12+
const specificationPath = join(__dirname, '..', 'openapi.json');
13+
const specificationJson = JSON.parse(
14+
readFileSync(specificationPath, 'utf-8'),
15+
);
1516

1617
fastify.register(glue, {
1718
prefix: 'v3',
1819
serviceHandlers,
19-
specification,
20+
specification: specificationJson,
2021
});
2122

2223
return fastify;

examples/openapi-ts-fastify/test/pets.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('/pet/findByTags', () => {
88
let server: FastifyInstance;
99

1010
beforeAll(async () => {
11-
server = buildServer();
11+
server = await buildServer();
1212
await server.listen();
1313

1414
// @ts-ignore

examples/openapi-ts-fastify/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"esModuleInterop": true,
1010
"skipLibCheck": true,
1111
"baseUrl": "."
12-
}
12+
},
13+
"references": [{ "path": "./tsconfig.node.json" }]
1314
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"skipLibCheck": true,
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
7+
"allowSyntheticDefaultImports": true,
8+
"strict": true
9+
},
10+
"include": ["vite.config.ts"]
11+
}

0 commit comments

Comments
 (0)