Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
"recommended": true
}
},
"overrides": [
{
"include": ["src/vendor-typestubs.d.ts"],
"linter": {
"rules": {
"suspicious": {
"noExplicitAny": "off"
}
}
}
}
],
"formatter": {
"enabled": true,
"indentStyle": "space",
Expand Down
14 changes: 9 additions & 5 deletions docs/src/content/docs/guides/cli-options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Initial page value to infinite query. The default value is `1`.

## Client Options

Due to the generated clients (Under the `openapi/requests` directory) being based on Hey API, you can pass some options to the Hey API client generator.
The generated clients (under the `openapi/requests` directory) are produced by `@hey-api/openapi-ts` using its plugins system. The CLI options below are mapped to the corresponding plugin configurations.

You can find what options are passed to the Hey API client generator in the [generate](https://github.com/7nohe/openapi-react-query-codegen/blob/main/src/generate.mts) function.
You can see the current configuration in the [generate](https://github.com/7nohe/openapi-react-query-codegen/blob/main/src/generate.mts) function.

### -c, --client \<value\>

Expand All @@ -43,15 +43,15 @@ More details about the clients can be found in [Hey API Documentation](https://h

### --format \<value\>

Process output folder with formatter? The default value is `false`.
Process the generated queries output folder (`openapi/queries`) with a formatter. The `openapi/requests` directory generated by `@hey-api/openapi-ts` is not affected by this option. The default value is `false`.
The available options are:

- `biome`
- `prettier`

### --lint \<value\>

Process output folder with linter? The default value is `false`.
Process the generated queries output folder (`openapi/queries`) with a linter. The `openapi/requests` directory generated by `@hey-api/openapi-ts` is not affected by this option. The default value is `false`.
The available options are:

- `biome`
Expand All @@ -71,10 +71,14 @@ The available options are:

### --useDateType

> **Deprecated:** This option is currently accepted but has no effect. It will be removed in a future version.

Use Date type instead of string for date. The default value is `false`.

### --debug

> **Deprecated:** This option is currently accepted but has no effect. It will be removed in a future version.

Run in debug mode? The default value is `false`.

### --noSchemas
Expand All @@ -83,7 +87,7 @@ Disable generating JSON schemas. The default value is `false`.

### --schemaTypes \<value\>

Type of JSON schema. The default value is `json`.
Type of JSON schema. Only applies when `--noSchemas` is not set. The default value is `json`.
The available options are:

- `json`
Expand Down
13 changes: 12 additions & 1 deletion docs/src/content/docs/guides/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ openapi/
│ ├── queries.ts
│ └── suspense.ts
└── requests
├── client/
├── core/
├── client.gen.ts
├── index.ts
├── schemas.gen.ts
├── sdk.gen.ts
├── services.gen.ts
└── types.gen.ts
```
Expand Down Expand Up @@ -107,6 +110,7 @@ import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
// services.gen.ts is a backward-compatibility shim that re-exports from client.gen and sdk.gen
import { client } from "../openapi/requests/services.gen";

client.setConfig({
Expand Down Expand Up @@ -180,6 +184,13 @@ export default App;
- suspenses.ts Generated suspense hooks
- prefetch.ts Generated prefetch functions
- requests Output code generated by `@hey-api/openapi-ts`
- client/ Hey API client implementation (internal)
- core/ Hey API core utilities (internal)
- client.gen.ts Client instance and configuration
- sdk.gen.ts SDK functions (primary service functions)
- services.gen.ts Backward-compatibility shim (re-exports from client.gen and sdk.gen)
- types.gen.ts Generated TypeScript types
- index.ts Barrel file

</FileTree>

Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/guides/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function App() {
export default App;
```

Optionally, you can also use the pure ts client in `openapi/requests/services.gen.ts` to customize your query.
Optionally, you can also use the pure TypeScript client to customize your query. The SDK functions are defined in `openapi/requests/sdk.gen.ts` and are also available via the backward-compatible `openapi/requests/services.gen.ts` shim.

```tsx
import { useQuery } from "@tanstack/react-query";
Expand Down
1 change: 1 addition & 0 deletions examples/nextjs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test:generated": "tsc -p ./tsconfig.json --noEmit"
},
"dependencies": {
"@hey-api/client-fetch": "^0.6.0",
"@tanstack/react-query": "^5.59.13",
"@tanstack/react-query-devtools": "^5.32.1",
"next": "^14.2.3",
Expand Down
1 change: 1 addition & 0 deletions examples/nextjs-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
3 changes: 0 additions & 3 deletions examples/react-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "./App.css";
import { useState } from "react";

import { createClient } from "@hey-api/client-fetch";
import {
UseFindPetsKeyFn,
useAddPet,
Expand All @@ -13,8 +12,6 @@ import { SuspenseParent } from "./components/SuspenseParent";
import { queryClient } from "./queryClient";

function App() {
createClient({ baseUrl: "http://localhost:4010" });

const [tags, _setTags] = useState<string[]>([]);
const [limit, _setLimit] = useState<number>(10);

Expand Down
1 change: 1 addition & 0 deletions examples/tanstack-router-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"vite": "^5.4.4"
},
"dependencies": {
"@hey-api/client-fetch": "^0.6.0",
"@tanstack/react-query": "^5.59.13",
"@tanstack/react-query-devtools": "^5.32.1",
"@tanstack/react-router": "^1.58.7",
Expand Down
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,35 @@
"license": "MIT",
"author": "Daiki Urata (@7nohe)",
"dependencies": {
"@hey-api/client-fetch": "0.4.0",
"@hey-api/openapi-ts": "0.53.8",
"@hey-api/openapi-ts": "0.92.3",
"cross-spawn": "^7.0.3"
},
"devDependencies": {
"@biomejs/biome": "^1.9.3",
"@types/cross-spawn": "^6.0.6",
"@types/node": "^22.7.4",
"@types/semver": "^7.7.1",
"@vitest/coverage-v8": "^1.5.0",
"commander": "^12.0.0",
"lefthook": "^1.6.10",
"rimraf": "^5.0.5",
"ts-morph": "^23.0.0",
"typescript": "^5.5.4",
"ts-morph": "^27.0.2",
"typescript": "^5.9.3",
"vitest": "^1.5.0"
},
"peerDependencies": {
"commander": "12.x",
"ts-morph": "23.x",
"ts-morph": "27.x",
"typescript": "5.x"
},
"packageManager": "pnpm@9.6.0",
"engines": {
"node": ">=14",
"pnpm": ">=9"
},
"pnpm": {
"patchedDependencies": {
"@hey-api/openapi-ts@0.92.3": "patches/@hey-api__openapi-ts@0.92.3.patch"
}
}
}
12 changes: 12 additions & 0 deletions patches/@hey-api__openapi-ts@0.92.3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/dist/index.d.mts b/dist/index.d.mts
index fd805770f0aff4a9f6c57560554908764ed5bdce..af40ec3b83741774a9e0ad82caf0acd3c97a3b55 100644
--- a/dist/index.d.mts
+++ b/dist/index.d.mts
@@ -1354,6 +1354,7 @@ declare class ImplFuncTsDsl<M extends FuncMode = 'arrow'> extends Mixed$27 {
decl(): FuncTsDsl<'decl'>;
/** Switches the function to a function expression form. */
expr(): FuncTsDsl<'expr'>;
+ // @ts-ignore TS2416 - bundled declaration has incorrect base type TsDsl<ArrowFunction>; conditional return is valid at source level
toAst(): M extends 'decl' ? ts.FunctionDeclaration : M extends 'expr' ? ts.FunctionExpression : ts.ArrowFunction;
$validate(): asserts this;
private missingRequiredCalls;
Loading
Loading