@7nohe/openapi-react-query-codegen 4.0.0-beta.6 → 4.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -4
- package/README.md +7 -7
- package/dist/agentsMd.mjs +3 -1
- package/dist/check.mjs +1 -1
- package/dist/runCli.mjs +1 -1
- package/package.json +7 -5
package/AGENTS.md
CHANGED
|
@@ -7,12 +7,12 @@ This file has two parts:
|
|
|
7
7
|
|
|
8
8
|
## Using this package
|
|
9
9
|
|
|
10
|
-
`@7nohe/openapi-react-query-codegen` is a CLI (`openapi-rq`) that reads an OpenAPI spec and generates:
|
|
10
|
+
`@7nohe/openapi-react-query-codegen` is a CLI (`orqc`; `openapi-rq` also works) that reads an OpenAPI spec and generates:
|
|
11
11
|
|
|
12
12
|
1. a TypeScript HTTP client (types, one function per operation and a small fetch or axios runtime) in `<output>/requests/`
|
|
13
13
|
2. TanStack Query v5 hooks and helpers on top of that client in `<output>/queries/`
|
|
14
14
|
|
|
15
|
-
Docs: https://
|
|
15
|
+
Docs: https://orqc.7nohe.dev (summary for LLMs: https://orqc.7nohe.dev/llms.txt)
|
|
16
16
|
|
|
17
17
|
### Install
|
|
18
18
|
|
|
@@ -32,7 +32,7 @@ Only the scoped `@7nohe/openapi-react-query-codegen` package belongs to this pro
|
|
|
32
32
|
Add a script and run it whenever the spec changes:
|
|
33
33
|
|
|
34
34
|
```json
|
|
35
|
-
{ "scripts": { "codegen": "
|
|
35
|
+
{ "scripts": { "codegen": "orqc -i ./openapi.yaml -o ./src/openapi" } }
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
| Flag | Default | Notes |
|
|
@@ -141,7 +141,7 @@ With `--agentsMd` in the codegen script, the generator keeps these instructions,
|
|
|
141
141
|
### CI drift check: `--check`
|
|
142
142
|
|
|
143
143
|
```bash
|
|
144
|
-
|
|
144
|
+
orqc -i ./openapi.yaml -o ./src/openapi --check
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
Generates into a temporary directory (`.openapi-rq-check-*` inside `<output>/queries`, removed afterwards), compares it with `<output>/requests` and `<output>/queries`, and changes no existing file. `--format`/`--lint` rules that target the output directory by path also apply to the temporary copy; a rule that names an exact file or depth from the project root (`src/openapi/queries/*.ts`) does not, so write such rules as `src/openapi/queries/**`. Each file is `added` (would be created), `modified` or `removed` (no longer generated).
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/js/%407nohe%2Fopenapi-react-query-codegen)
|
|
6
6
|
|
|
7
|
-
📖 **[Documentation](https://
|
|
7
|
+
📖 **[Documentation](https://orqc.7nohe.dev)** · [Migrating to v3](https://orqc.7nohe.dev/guides/migrating-to-v3/) · [Coming from openapi-react-query](https://orqc.7nohe.dev/guides/migrating-from-openapi-react-query/)
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
## Quick start
|
|
19
19
|
|
|
20
20
|
> [!NOTE]
|
|
21
|
-
> v4 is in beta, and this README describes it. Install it with `@beta`; a plain `npm install` still gets v3, whose README and docs are in the [`v3` branch](https://github.com/7nohe/openapi-react-query-codegen/tree/v3). What changes from v3 is in [Migrating to v4](https://
|
|
21
|
+
> v4 is in beta, and this README describes it. Install it with `@beta`; a plain `npm install` still gets v3, whose README and docs are in the [`v3` branch](https://github.com/7nohe/openapi-react-query-codegen/tree/v3). What changes from v3 is in [Migrating to v4](https://orqc.7nohe.dev/guides/migrating-to-v4/).
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
npm install -D @7nohe/openapi-react-query-codegen@beta
|
|
25
|
-
npx
|
|
25
|
+
npx orqc -i ./petstore.yaml
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
```tsx
|
|
@@ -35,10 +35,10 @@ function Pets() {
|
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
See the [documentation](https://
|
|
38
|
+
See the [documentation](https://orqc.7nohe.dev) for CLI options, SSR recipes, and infinite query usage.
|
|
39
39
|
|
|
40
40
|
> [!IMPORTANT]
|
|
41
|
-
>
|
|
41
|
+
> This project publishes only the scoped **`@7nohe/openapi-react-query-codegen`** and its short name **`@7nohe/orqc`**. The unscoped `openapi-react-query-codegen` and `openapi-rq` and the copies under other scopes on npm are published by third parties, not by this project.
|
|
42
42
|
|
|
43
43
|
## How it compares
|
|
44
44
|
|
|
@@ -54,11 +54,11 @@ See the [documentation](https://openapi-react-query-codegen.vercel.app) for CLI
|
|
|
54
54
|
|
|
55
55
|
**Scope**: this library is deliberately React-focused and does not generate API mocks — use Orval if MSW mocks are your priority, or the hey-api plugin if you need non-React frameworks.
|
|
56
56
|
|
|
57
|
-
**Coming from openapi-typescript / openapi-fetch / openapi-react-query?** See the [migration guide](https://
|
|
57
|
+
**Coming from openapi-typescript / openapi-fetch / openapi-react-query?** See the [migration guide](https://orqc.7nohe.dev/guides/migrating-from-openapi-react-query/).
|
|
58
58
|
|
|
59
59
|
## Stability policy
|
|
60
60
|
|
|
61
|
-
The client generator is part of this package, so the generated `requests/` directory and the hooks built on it change together and follow SemVer: breaking output changes only happen in major versions, with a migration guide (see [Migrating to v4](https://
|
|
61
|
+
The client generator is part of this package, so the generated `requests/` directory and the hooks built on it change together and follow SemVer: breaking output changes only happen in major versions, with a migration guide (see [Migrating to v4](https://orqc.7nohe.dev/guides/migrating-to-v4/) if you are coming from v3, where the client was produced by `@hey-api/openapi-ts`).
|
|
62
62
|
|
|
63
63
|
## Requirements
|
|
64
64
|
|
package/dist/agentsMd.mjs
CHANGED
|
@@ -16,6 +16,8 @@ function displayPath(output) {
|
|
|
16
16
|
const inside = relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
17
17
|
return (inside ? relative : output).split(path.sep).join("/");
|
|
18
18
|
}
|
|
19
|
+
// The markers keep the CLI's old name: renaming them would orphan the blocks
|
|
20
|
+
// that earlier versions wrote into projects.
|
|
19
21
|
const begin = (output) => `<!-- openapi-rq:begin ${output} -->`;
|
|
20
22
|
const end = (output) => `<!-- openapi-rq:end ${output} -->`;
|
|
21
23
|
/**
|
|
@@ -34,7 +36,7 @@ export function renderAgentsBlock(output) {
|
|
|
34
36
|
return `${begin(out)}
|
|
35
37
|
## Generated API client (\`${out}\`)
|
|
36
38
|
|
|
37
|
-
\`${out}\` is generated by \`
|
|
39
|
+
\`${out}\` is generated by \`orqc\` (\`@7nohe/openapi-react-query-codegen\`) from the OpenAPI document. Do not edit it: change the document or the flags and generate again. Its files can be very large, so look things up as described here instead of reading them.
|
|
38
40
|
|
|
39
41
|
### Names
|
|
40
42
|
|
package/dist/check.mjs
CHANGED
|
@@ -162,5 +162,5 @@ export async function check(options, version) {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
export function outOfDateError(files) {
|
|
165
|
-
return new CodegenError(ErrorCodes.outputOutOfDate, `Generated output is out of date (${files.length} ${files.length === 1 ? "file differs" : "files differ"}). Re-run
|
|
165
|
+
return new CodegenError(ErrorCodes.outputOutOfDate, `Generated output is out of date (${files.length} ${files.length === 1 ? "file differs" : "files differ"}). Re-run orqc without --check to update it.`, { files });
|
|
166
166
|
}
|
package/dist/runCli.mjs
CHANGED
|
@@ -10,7 +10,7 @@ const defaultIO = {
|
|
|
10
10
|
const defaultDependencies = { generate, check };
|
|
11
11
|
export function buildProgram(version, io, { json }) {
|
|
12
12
|
return new Command()
|
|
13
|
-
.name("
|
|
13
|
+
.name("orqc")
|
|
14
14
|
.version(version)
|
|
15
15
|
.description("Generate React Query code based on OpenAPI")
|
|
16
16
|
.exitOverride()
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@7nohe/openapi-react-query-codegen",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.7",
|
|
4
4
|
"description": "OpenAPI React Query Codegen",
|
|
5
5
|
"bin": {
|
|
6
|
-
"
|
|
6
|
+
"orqc": "dist/cli.mjs",
|
|
7
|
+
"openapi-rq": "dist/cli.mjs",
|
|
8
|
+
"openapi-react-query-codegen": "dist/cli.mjs"
|
|
7
9
|
},
|
|
8
10
|
"private": false,
|
|
9
11
|
"type": "module",
|
|
@@ -47,13 +49,13 @@
|
|
|
47
49
|
"@types/cross-spawn": "^6.0.6",
|
|
48
50
|
"@types/node": "^22.20.1",
|
|
49
51
|
"@types/semver": "^7.7.1",
|
|
50
|
-
"@vitest/coverage-v8": "^
|
|
52
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
51
53
|
"axios": "1.20.0",
|
|
52
54
|
"commander": "^15.0.0",
|
|
53
55
|
"lefthook": "^2.1.10",
|
|
54
56
|
"typescript": "^6.0.3",
|
|
55
|
-
"vite": "^
|
|
56
|
-
"vitest": "^
|
|
57
|
+
"vite": "^8.3.6",
|
|
58
|
+
"vitest": "^5.1.0"
|
|
57
59
|
},
|
|
58
60
|
"peerDependencies": {
|
|
59
61
|
"@tanstack/react-query": "^5.0.0",
|