Skip to content

Commit 7acc365

Browse files
committed
Merge branch 'main' into 2097-openapi-metadata-support-for-commonjs
2 parents 6126497 + 0c35b32 commit 7acc365

File tree

142 files changed

+28872
-8140
lines changed

Some content is hidden

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

142 files changed

+28872
-8140
lines changed

.changeset/chilly-meals-act.md

-5
This file was deleted.

.changeset/mighty-comics-worry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-react-query": minor
3+
---
4+
5+
Implements useInfiniteQuery() in openapi-react-query

.changeset/purple-walls-repeat.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-typescript": minor
3+
---
4+
5+
Support generating path params for flaky schemas using --generate-path-params option

.changeset/witty-bottles-carry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-react-query": patch
3+
---
4+
5+
[#2098](https://github.com/openapi-ts/openapi-typescript/pull/2098): Fix CJS type issues by pointing to proper d.ts file

docs/cli.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ The following flags are supported in the CLI:
121121
| `--path-params-as-types` | | `false` | Allow dynamic string lookups on the `paths` object |
122122
| `--root-types` | | `false` | Exports types from `components` as root level type aliases |
123123
| `--root-types-no-schema-prefix` | | `false` | Do not add "Schema" prefix to types at the root level (should only be used with --root-types) |
124-
| `--make-paths-enum ` | | `false` | Generate ApiPaths enum for all paths |
124+
| `--make-paths-enum` | | `false` | Generate ApiPaths enum for all paths |
125+
| `--generate-path-params` | | `false` | Generate path parameters for all paths where they are undefined by schema |
125126

126127
### pathParamsAsTypes
127128

@@ -227,3 +228,9 @@ export enum ApiPaths {
227228
```
228229

229230
:::
231+
232+
### generatePathParams
233+
234+
This option is useful for generating path params optimistically when the schema has flaky path parameter definitions.
235+
Checks the path for opening and closing brackets and extracts them as path parameters.
236+
Does not override already defined by schema path parameters.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: useInfiniteQuery
3+
---
4+
5+
# {{ $frontmatter.title }}
6+
7+
The `useInfiniteQuery` method allows you to use the original [useInfiniteQuery](https://tanstack.com/query/latest/docs/framework/react/guides/infinite-queries)
8+
9+
- The result is the same as the original function.
10+
- The `queryKey` is `[method, path, params]`.
11+
- `data` and `error` are fully typed.
12+
- You can pass infinite query options as fourth parameter.
13+
14+
::: tip
15+
You can find more information about `useInfiniteQuery` on the [@tanstack/react-query documentation](https://tanstack.com/query/latest/docs/framework/react/guides/infinite-queries).
16+
:::
17+
18+
## Example
19+
20+
::: code-group
21+
22+
```tsx [src/app.tsx]
23+
import { $api } from "./api";
24+
const PostList = () => {
25+
const { data, fetchNextPage, hasNextPage, isFetching } =
26+
$api.useInfiniteQuery(
27+
"get",
28+
"/posts",
29+
{
30+
params: {
31+
query: {
32+
limit: 10,
33+
},
34+
},
35+
},
36+
{
37+
getNextPageParam: (lastPage) => lastPage.nextPage,
38+
initialPageParam: 0,
39+
}
40+
);
41+
42+
return (
43+
<div>
44+
{data?.pages.map((page, i) => (
45+
<div key={i}>
46+
{page.items.map((post) => (
47+
<div key={post.id}>{post.title}</div>
48+
))}
49+
</div>
50+
))}
51+
{hasNextPage && (
52+
<button onClick={() => fetchNextPage()} disabled={isFetching}>
53+
{isFetching ? "Loading..." : "Load More"}
54+
</button>
55+
)}
56+
</div>
57+
);
58+
};
59+
60+
export const App = () => {
61+
return (
62+
<ErrorBoundary fallbackRender={({ error }) => `Error: ${error.message}`}>
63+
<MyComponent />
64+
</ErrorBoundary>
65+
);
66+
};
67+
```
68+
69+
```ts [src/api.ts]
70+
import createFetchClient from "openapi-fetch";
71+
import createClient from "openapi-react-query";
72+
import type { paths } from "./my-openapi-3-schema"; // generated by openapi-typescript
73+
74+
const fetchClient = createFetchClient<paths>({
75+
baseUrl: "https://myapi.dev/v1/",
76+
});
77+
export const $api = createClient(fetchClient);
78+
```
79+
80+
:::
81+
82+
## Api
83+
84+
```tsx
85+
const query = $api.useInfiniteQuery(
86+
method,
87+
path,
88+
options,
89+
infiniteQueryOptions,
90+
queryClient
91+
);
92+
```
93+
94+
**Arguments**
95+
96+
- `method` **(required)**
97+
- The HTTP method to use for the request.
98+
- The method is used as key. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information.
99+
- `path` **(required)**
100+
- The pathname to use for the request.
101+
- Must be an available path for the given method in your schema.
102+
- The pathname is used as key. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information.
103+
- `options`
104+
- The fetch options to use for the request.
105+
- Only required if the OpenApi schema requires parameters.
106+
- The options `params` are used as key. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information.
107+
- `infiniteQueryOptions`
108+
- The original `useInfiniteQuery` options.
109+
- [See more information](https://tanstack.com/query/latest/docs/framework/react/reference/useInfiniteQuery)
110+
- `queryClient`
111+
- The original `queryClient` option.
112+
- [See more information](https://tanstack.com/query/latest/docs/framework/react/reference/useInfiniteQuery)

docs/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"update-contributors": "node scripts/update-contributors.js"
1010
},
1111
"devDependencies": {
12-
"@shikijs/vitepress-twoslash": "^1.26.1",
12+
"@shikijs/vitepress-twoslash": "^1.29.1",
1313
"openapi-metadata": "workspace:*",
14-
"vite": "^6.0.7",
15-
"vitepress": "1.5.0"
14+
"vite": "^6.0.11",
15+
"vitepress": "1.6.3"
1616
}
1717
}

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
"devDependencies": {
2222
"@biomejs/biome": "^1.9.4",
2323
"@changesets/changelog-github": "^0.5.0",
24-
"@changesets/cli": "^2.27.11",
25-
"@playwright/test": "^1.49.1",
24+
"@changesets/cli": "^2.27.12",
25+
"@playwright/test": "^1.50.0",
2626
"@size-limit/preset-small-lib": "^11.1.6",
27-
"@types/node": "^22.10.5",
27+
"@types/node": "^22.10.10",
2828
"del-cli": "^5.1.0",
2929
"prettier": "^3.4.2",
3030
"size-limit": "^11.1.6",
31-
"turbo": "^2.3.3",
32-
"typescript": "^5.7.2",
31+
"turbo": "^2.3.4",
32+
"typescript": "^5.7.3",
3333
"vitest": "^2.1.8"
3434
},
3535
"size-limit": [

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
"@types/react": "^18.3.18",
1616
"@types/react-dom": "^18.3.5",
1717
"openapi-typescript": "workspace:^",
18-
"typescript": "^5.7.2"
18+
"typescript": "^5.7.3"
1919
}
2020
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
},
1414
"devDependencies": {
1515
"@sveltejs/adapter-auto": "^3.3.1",
16-
"@sveltejs/kit": "^2.15.1",
16+
"@sveltejs/kit": "^2.16.1",
1717
"@sveltejs/vite-plugin-svelte": "^5.0.3",
1818
"openapi-typescript": "workspace:^",
19-
"svelte": "^5.16.1",
19+
"svelte": "^5.19.3",
2020
"svelte-check": "^3.8.6",
2121
"tslib": "^2.8.1",
22-
"typescript": "^5.7.2",
23-
"vite": "^6.0.7"
22+
"typescript": "^5.7.3",
23+
"vite": "^6.0.11"
2424
}
2525
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"@vitejs/plugin-vue": "^5.2.1",
2020
"@vue/tsconfig": "^0.5.1",
2121
"openapi-typescript": "workspace:^",
22-
"typescript": "^5.7.2",
23-
"vite": "^6.0.7",
22+
"typescript": "^5.7.3",
23+
"vite": "^6.0.11",
2424
"vue-tsc": "^2.2.0"
2525
}
2626
}

packages/openapi-fetch/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@
7979
"node-forge": "^1.3.1",
8080
"openapi-typescript": "workspace:^",
8181
"openapi-typescript-codegen": "^0.25.0",
82-
"openapi-typescript-fetch": "^2.0.0",
82+
"openapi-typescript-fetch": "^2.1.0",
8383
"superagent": "^10.1.1",
84-
"typescript": "^5.7.2",
85-
"undici": "^6.21.0",
86-
"vite": "^6.0.7"
84+
"typescript": "^5.7.3",
85+
"undici": "^6.21.1",
86+
"vite": "^6.0.11"
8787
}
8888
}

packages/openapi-react-query/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# openapi-react-query
22

3+
## 0.2.10
4+
5+
### Patch Changes
6+
7+
- [#2105](https://github.com/openapi-ts/openapi-typescript/pull/2105) [`af0e72f`](https://github.com/openapi-ts/openapi-typescript/commit/af0e72f16f1515f2953a719d7f58c76ec27637ea) Thanks [@HagenMorano](https://github.com/HagenMorano)! - [#1845](https://github.com/openapi-ts/openapi-typescript/pull/2105): The return value of the `select` property is now considered when inferring the `data` type.
8+
39
## 0.2.9
410

511
### Patch Changes

packages/openapi-react-query/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "openapi-react-query",
33
"description": "Fast, type-safe @tanstack/react-query client to work with your OpenAPI schema.",
4-
"version": "0.2.9",
4+
"version": "0.2.10",
55
"author": {
66
"name": "Martin Paucot",
77
"email": "[email protected]"
@@ -18,7 +18,7 @@
1818
"default": "./dist/index.js"
1919
},
2020
"require": {
21-
"types": "./dist/index.d.cts",
21+
"types": "./dist/index.d.ts",
2222
"default": "./dist/index.cjs"
2323
}
2424
},
@@ -65,8 +65,8 @@
6565
"openapi-typescript-helpers": "workspace:^"
6666
},
6767
"devDependencies": {
68-
"@tanstack/react-query": "^5.62.14",
69-
"@testing-library/react": "^16.1.0",
68+
"@tanstack/react-query": "^5.64.2",
69+
"@testing-library/react": "^16.2.0",
7070
"@types/react": "18.3.1",
7171
"@vitejs/plugin-react": "^4.3.4",
7272
"del-cli": "^5.1.0",

0 commit comments

Comments
 (0)