Skip to content

Commit 9214aea

Browse files
authored
Merge branch 'main' into feat/ofetch
2 parents 100b9a3 + 1512832 commit 9214aea

File tree

1,389 files changed

+15380
-14641
lines changed

Some content is hidden

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

1,389 files changed

+15380
-14641
lines changed

.changeset/beige-rocks-remain.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(plugin): every plugin extends Plugin.Hooks interface

.changeset/eleven-beans-sort.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix(renderer): group and sort imported modules
6+
7+
### TypeScript renderer
8+
9+
We ship a dedicated TypeScript renderer for `.ts` files. This release improves the renderer's ability to group and sort imported modules, resulting in a more polished output.

.changeset/healthy-experts-grow.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix(config): add `output.fileName` option
6+
7+
## File Name
8+
9+
You can customize the naming and casing pattern for files using the `fileName` option.
10+
11+
```js
12+
export default {
13+
input: 'hey-api/backend', // sign up at app.heyapi.dev
14+
output: {
15+
fileName: '{{name}}',
16+
path: 'src/client',
17+
},
18+
};
19+
```
20+
21+
By default, we append every file name with a `.gen` suffix to highlight it's automatically generated. You can customize or disable this suffix using the `fileName.suffix` option.
22+
23+
```js
24+
export default {
25+
input: 'hey-api/backend', // sign up at app.heyapi.dev
26+
output: {
27+
fileName: {
28+
suffix: '.gen',
29+
},
30+
path: 'src/client',
31+
},
32+
};
33+
```

.changeset/rare-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(axios): remove duplicate `baseURL` when using relative values

.changeset/selfish-hornets-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/codegen-core': minor
3+
---
4+
5+
feat: Symbol API

.changeset/two-buses-dance.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@hey-api/openapi-ts': minor
3+
---
4+
5+
feat: Symbol API
6+
7+
### Symbol API
8+
9+
This release improves the Symbol API, which adds the capability to place symbols in arbitrary files. We preserved the previous output structure for all plugins except Angular.
10+
11+
You can preserve the previous Angular output by writing your own [placement function](https://heyapi.dev/openapi-ts/configuration/parser#hooks-symbols).
12+
13+
### Removed `output` plugin option
14+
15+
Due to the Symbol API release, this option has been removed from the Plugin API.

docs/.vitepress/config/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export default defineConfig({
262262
text: 'Custom',
263263
},
264264
],
265-
text: 'Guides and Concepts',
265+
text: 'Plugins',
266266
},
267267
{
268268
items: [

docs/openapi-ts/configuration/output.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,78 @@ export default {
3434

3535
:::
3636

37+
## File Name
38+
39+
You can customize the naming and casing pattern for files using the `fileName` option.
40+
41+
::: code-group
42+
43+
```js [default]
44+
export default {
45+
input: 'hey-api/backend', // sign up at app.heyapi.dev
46+
output: {
47+
fileName: '{{name}}', // [!code ++]
48+
path: 'src/client',
49+
},
50+
};
51+
```
52+
53+
```js [snake_case]
54+
export default {
55+
input: 'hey-api/backend', // sign up at app.heyapi.dev
56+
output: {
57+
fileName: {
58+
case: 'snake_case', // [!code ++]
59+
},
60+
path: 'src/client',
61+
},
62+
};
63+
```
64+
65+
:::
66+
67+
By default, we append every file name with a `.gen` suffix to highlight it's automatically generated. You can customize or disable this suffix using the `fileName.suffix` option.
68+
69+
::: code-group
70+
71+
```js [default]
72+
export default {
73+
input: 'hey-api/backend', // sign up at app.heyapi.dev
74+
output: {
75+
fileName: {
76+
suffix: '.gen', // [!code ++]
77+
},
78+
path: 'src/client',
79+
},
80+
};
81+
```
82+
83+
```js [off]
84+
export default {
85+
input: 'hey-api/backend', // sign up at app.heyapi.dev
86+
output: {
87+
fileName: {
88+
suffix: null, // [!code ++]
89+
},
90+
path: 'src/client',
91+
},
92+
};
93+
```
94+
95+
```js [custom]
96+
export default {
97+
input: 'hey-api/backend', // sign up at app.heyapi.dev
98+
output: {
99+
fileName: {
100+
suffix: '.generated', // [!code ++]
101+
},
102+
path: 'src/client',
103+
},
104+
};
105+
```
106+
107+
:::
108+
37109
## Format
38110

39111
To format your output folder contents, set `output.format` to a valid formatter.

docs/openapi-ts/configuration/parser.md

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,36 @@ export default {
460460

461461
## Hooks
462462

463-
Hooks affect runtime behavior but aren’t tied to any single plugin. They can be configured globally via `parser.hooks` or per plugin through the `~hooks` property.
463+
Hooks affect runtime behavior but aren’t tied to any single plugin. They can be configured globally via `hooks` or per plugin through the `~hooks` property.
464+
465+
::: code-group
466+
467+
```js [parser]
468+
export default {
469+
input: 'hey-api/backend', // sign up at app.heyapi.dev
470+
output: 'src/client',
471+
parser: {
472+
hooks: {}, // configure global hooks here // [!code ++]
473+
},
474+
};
475+
```
476+
477+
```js [plugin]
478+
export default {
479+
input: 'hey-api/backend', // sign up at app.heyapi.dev
480+
output: 'src/client',
481+
plugins: [
482+
{
483+
name: '@tanstack/react-query',
484+
'~hooks': {}, // configure plugin hooks here // [!code ++]
485+
},
486+
],
487+
};
488+
```
489+
490+
:::
491+
492+
We always use the first hook that returns a value. If a hook returns no value, we fall back to less specific hooks until one does.
464493

465494
### Operations {#hooks-operations}
466495

@@ -478,12 +507,12 @@ By default, DELETE, PATCH, POST, and PUT operations are classified as `mutation`
478507

479508
Imagine your API has a POST `/search` endpoint that accepts a large payload. By default, it's classified as a `mutation`, but in practice it behaves like a `query`, and your [state management](/openapi-ts/state-management) plugin should generate query hooks.
480509

481-
You can fix this by classifying the operation as `query` in a matcher. If a matcher returns no value, we fall back to less specific matchers until one does.
510+
You can achieve this by classifying the operation as `query` in a matcher.
482511

483512
::: code-group
484513

485514
<!-- prettier-ignore-start -->
486-
```js [parser]
515+
```js [isQuery]
487516
export default {
488517
input: 'hey-api/backend', // sign up at app.heyapi.dev
489518
output: 'src/client',
@@ -502,29 +531,56 @@ export default {
502531
```
503532
<!-- prettier-ignore-end -->
504533
<!-- prettier-ignore-start -->
505-
```js [plugin]
534+
```js [getKind]
506535
export default {
507536
input: 'hey-api/backend', // sign up at app.heyapi.dev
508537
output: 'src/client',
509-
plugins: [
510-
{
511-
name: '@tanstack/react-query',
512-
'~hooks': {
513-
operations: {
514-
getKind: (op) => {
515-
if (op.method === 'post' && op.path === '/search') { // [!code ++]
516-
return ['query']; // [!code ++]
517-
} // [!code ++]
518-
},
538+
parser: {
539+
hooks: {
540+
operations: {
541+
getKind: (op) => {
542+
if (op.method === 'post' && op.path === '/search') { // [!code ++]
543+
return ['query']; // [!code ++]
544+
} // [!code ++]
519545
},
520546
},
521547
},
522-
],
548+
},
523549
};
524550
```
525551
<!-- prettier-ignore-end -->
526552

527553
:::
528554

555+
### Symbols {#hooks-symbols}
556+
557+
Each symbol can have a placement function deciding its output location.
558+
559+
#### Example: Alphabetic sort
560+
561+
While we work on a better example, let's imagine a world where it's desirable to place every symbol in a file named after its initial letter. For example, a function named `Foo` should end up in the file `f.ts`.
562+
563+
You can achieve this by using the symbol's name.
564+
565+
<!-- prettier-ignore-start -->
566+
```js [getKind]
567+
export default {
568+
input: 'hey-api/backend', // sign up at app.heyapi.dev
569+
output: 'src/client',
570+
parser: {
571+
hooks: {
572+
symbols: {
573+
getFilePath: (symbol) => {
574+
if (symbol.name) { // [!code ++]
575+
return symbol.name[0]?.toLowerCase(); // [!code ++]
576+
} // [!code ++]
577+
},
578+
},
579+
},
580+
},
581+
};
582+
```
583+
<!-- prettier-ignore-end -->
584+
529585
<!--@include: ../../partials/examples.md-->
530586
<!--@include: ../../partials/sponsors.md-->

docs/openapi-ts/get-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Launch demo
2121

2222
- runs in CLI, Node.js 18+, or npx
2323
- works with OpenAPI 2.0, 3.0, and 3.1
24-
- customizable types and SDKs
24+
- core plugins for types, SDKs, and schemas
2525
- clients for your runtime (Fetch API, Angular, Axios, Next.js, Nuxt, etc.)
2626
- plugin ecosystem to reduce third-party boilerplate
2727
- custom plugins and custom clients

0 commit comments

Comments
 (0)