Skip to content

Commit 9751deb

Browse files
TakehiroTadaclaude
andcommitted
docs: update documentation for hey-api 0.92.3 plugins system
- Map CLI options (--enums, --noOperationId, --noSchemas, --schemaType) to the new @hey-api/openapi-ts plugins API in generate.mts - Mark --useDateType and --debug as deprecated (no equivalent in new API) - Update introduction.mdx with new output directory structure (sdk.gen.ts, client.gen.ts, client/, core/) - Update cli-options.mdx with accurate option descriptions - Update usage.mdx to mention sdk.gen.ts and services.gen.ts shim Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 15f4edc commit 9751deb

File tree

4 files changed

+55
-11
lines changed

4 files changed

+55
-11
lines changed

docs/src/content/docs/guides/cli-options.mdx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Initial page value to infinite query. The default value is `1`.
2727

2828
## Client Options
2929

30-
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.
30+
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.
3131

32-
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.
32+
You can see the current configuration in the [generate](https://github.com/7nohe/openapi-react-query-codegen/blob/main/src/generate.mts) function.
3333

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

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

4444
### --format \<value\>
4545

46-
Process output folder with formatter? The default value is `false`.
46+
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`.
4747
The available options are:
4848

4949
- `biome`
5050
- `prettier`
5151

5252
### --lint \<value\>
5353

54-
Process output folder with linter? The default value is `false`.
54+
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`.
5555
The available options are:
5656

5757
- `biome`
@@ -71,10 +71,14 @@ The available options are:
7171

7272
### --useDateType
7373

74+
> **Deprecated:** This option is currently accepted but has no effect. It will be removed in a future version.
75+
7476
Use Date type instead of string for date. The default value is `false`.
7577

7678
### --debug
7779

80+
> **Deprecated:** This option is currently accepted but has no effect. It will be removed in a future version.
81+
7882
Run in debug mode? The default value is `false`.
7983

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

8488
### --schemaTypes \<value\>
8589

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

8993
- `json`

docs/src/content/docs/guides/introduction.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ openapi/
7777
│ ├── queries.ts
7878
│ └── suspense.ts
7979
└── requests
80+
├── client/
81+
├── core/
82+
├── client.gen.ts
8083
├── index.ts
81-
├── schemas.gen.ts
84+
├── sdk.gen.ts
8285
├── services.gen.ts
8386
└── types.gen.ts
8487
```
@@ -107,6 +110,7 @@ import React from "react";
107110
import ReactDOM from "react-dom/client";
108111
import App from "./App";
109112
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
113+
// services.gen.ts is a backward-compatibility shim that re-exports from client.gen and sdk.gen
110114
import { client } from "../openapi/requests/services.gen";
111115

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

184195
</FileTree>
185196

docs/src/content/docs/guides/usage.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function App() {
2323
export default App;
2424
```
2525

26-
Optionally, you can also use the pure ts client in `openapi/requests/services.gen.ts` to customize your query.
26+
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.
2727

2828
```tsx
2929
import { useQuery } from "@tanstack/react-query";

src/generate.mts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,46 @@ export async function generate(options: LimitedUserConfig, version: string) {
1515
const openApiOutputPath = buildRequestsOutputPath(options.output);
1616
const formattedOptions = formatOptions(options);
1717

18-
// Map old client option to new plugins system
18+
// Map CLI options to new plugins system
1919
const clientPlugin =
2020
formattedOptions.client === "@hey-api/client-axios"
2121
? "@hey-api/client-axios"
2222
: "@hey-api/client-fetch";
23-
const plugins: UserConfig["plugins"] = [
23+
24+
const typescriptPlugin: NonNullable<UserConfig["plugins"]>[number] =
25+
formattedOptions.enums
26+
? {
27+
name: "@hey-api/typescript" as const,
28+
enums: formattedOptions.enums,
29+
}
30+
: "@hey-api/typescript";
31+
32+
const sdkPlugin: NonNullable<UserConfig["plugins"]>[number] =
33+
formattedOptions.noOperationId
34+
? {
35+
name: "@hey-api/sdk" as const,
36+
operationId: false,
37+
}
38+
: "@hey-api/sdk";
39+
40+
const plugins: NonNullable<UserConfig["plugins"]>[number][] = [
2441
clientPlugin,
25-
"@hey-api/typescript",
26-
"@hey-api/sdk",
42+
typescriptPlugin,
43+
sdkPlugin,
2744
];
2845

46+
// Conditionally add schemas plugin
47+
if (!formattedOptions.noSchemas) {
48+
plugins.push(
49+
formattedOptions.schemaType
50+
? {
51+
name: "@hey-api/schemas" as const,
52+
type: formattedOptions.schemaType,
53+
}
54+
: "@hey-api/schemas",
55+
);
56+
}
57+
2958
const config: UserConfig = {
3059
dryRun: false,
3160
input: formattedOptions.input,

0 commit comments

Comments
 (0)