You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
You can customize the naming and casing pattern for files using the `fileName` option.
10
+
11
+
```js
12
+
exportdefault {
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
+
exportdefault {
25
+
input:'hey-api/backend', // sign up at app.heyapi.dev
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.
Copy file name to clipboardExpand all lines: docs/openapi-ts/configuration/output.md
+72Lines changed: 72 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,78 @@ export default {
34
34
35
35
:::
36
36
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
+
exportdefault {
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
+
exportdefault {
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
+
exportdefault {
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
+
exportdefault {
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
+
exportdefault {
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
+
37
109
## Format
38
110
39
111
To format your output folder contents, set `output.format` to a valid formatter.
Copy file name to clipboardExpand all lines: docs/openapi-ts/configuration/parser.md
+71-15Lines changed: 71 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -460,7 +460,36 @@ export default {
460
460
461
461
## Hooks
462
462
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
+
exportdefault {
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
+
exportdefault {
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.
464
493
465
494
### Operations {#hooks-operations}
466
495
@@ -478,12 +507,12 @@ By default, DELETE, PATCH, POST, and PUT operations are classified as `mutation`
478
507
479
508
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.
480
509
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.
482
511
483
512
::: code-group
484
513
485
514
<!-- prettier-ignore-start -->
486
-
```js [parser]
515
+
```js [isQuery]
487
516
exportdefault {
488
517
input:'hey-api/backend', // sign up at app.heyapi.dev
489
518
output:'src/client',
@@ -502,29 +531,56 @@ export default {
502
531
```
503
532
<!-- prettier-ignore-end -->
504
533
<!-- prettier-ignore-start -->
505
-
```js [plugin]
534
+
```js [getKind]
506
535
exportdefault {
507
536
input:'hey-api/backend', // sign up at app.heyapi.dev
508
537
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 ++]
519
545
},
520
546
},
521
547
},
522
-
],
548
+
},
523
549
};
524
550
```
525
551
<!-- prettier-ignore-end -->
526
552
527
553
:::
528
554
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
+
exportdefault {
568
+
input:'hey-api/backend', // sign up at app.heyapi.dev
Copy file name to clipboardExpand all lines: docs/openapi-ts/migrating.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,22 @@ description: Migrating to @hey-api/openapi-ts.
7
7
8
8
While we try to avoid breaking changes, sometimes it's unavoidable in order to offer you the latest features. This page lists changes that require updates to your code. If you run into a problem with migration, please [open an issue](https://github.com/hey-api/openapi-ts/issues).
9
9
10
+
## v0.84.0
11
+
12
+
### Symbol API
13
+
14
+
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.
15
+
16
+
You can preserve the previous Angular output by writing your own [placement function](/openapi-ts/configuration/parser#hooks-symbols).
17
+
18
+
### TypeScript renderer
19
+
20
+
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.
21
+
22
+
### Removed `output` plugin option
23
+
24
+
Due to the Symbol API release, this option has been removed from the Plugin API.
0 commit comments