Skip to content

Commit 5d81c80

Browse files
authored
Merge pull request #2141 from hey-api/feat/sdk-graph
feat(sdk): add `classStructure` option supporting dot or slash `operationId` notation when generating class-based SDKs
2 parents 159b9b7 + 557769d commit 5d81c80

File tree

125 files changed

+8949
-59563
lines changed

Some content is hidden

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

125 files changed

+8949
-59563
lines changed

.changeset/cold-snails-end.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@hey-api/openapi-ts': minor
3+
---
4+
5+
feat(sdk): add `classStructure` option supporting dot or slash `operationId` notation when generating class-based SDKs
6+
7+
### Added `sdk.classStructure` option
8+
9+
When generating class-based SDKs, we now try to infer the ideal structure using `operationId` keywords. If you'd like to preserve the previous behavior, set `classStructure` to `off`.
10+
11+
```js
12+
export default {
13+
input: 'https://get.heyapi.dev/hey-api/backend',
14+
output: 'src/client',
15+
plugins: [
16+
// ...other plugins
17+
{
18+
classStructure: 'off',
19+
name: '@hey-api/sdk',
20+
},
21+
],
22+
};
23+
```

docs/openapi-ts/migrating.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,38 @@ This config option is deprecated and will be removed in favor of [clients](./cli
2727

2828
This config option is deprecated and will be removed.
2929

30+
## v0.72.0
31+
32+
### Added `sdk.classStructure` option
33+
34+
When generating class-based SDKs, we now try to infer the ideal structure using `operationId` keywords. If you'd like to preserve the previous behavior, set `classStructure` to `off`.
35+
36+
```js
37+
export default {
38+
input: 'https://get.heyapi.dev/hey-api/backend',
39+
output: 'src/client',
40+
plugins: [
41+
// ...other plugins
42+
{
43+
classStructure: 'off', // [!code ++]
44+
name: '@hey-api/sdk',
45+
},
46+
],
47+
};
48+
```
49+
3050
## v0.71.0
3151

3252
### Renamed `sdk.serviceNameBuilder` option
3353

3454
This option has been renamed to `sdk.classNameBuilder` to better represent its functionality. Additionally, it's no longer set by default. To preserve the previous behavior, update your configuration.
3555

3656
```js
37-
import { defaultPlugins } from '@hey-api/openapi-ts';
38-
3957
export default {
4058
input: 'https://get.heyapi.dev/hey-api/backend',
4159
output: 'src/client',
4260
plugins: [
43-
...defaultPlugins,
61+
// ...other plugins
4462
{
4563
classNameBuilder: '{{name}}Service', // [!code ++]
4664
name: '@hey-api/sdk',
@@ -259,14 +277,12 @@ The Fetch API client will return raw response body as `ReadableStream` when `Con
259277
When generating SDKs, you now have to specify `transformer` in order to modify response data. By default, adding `@hey-api/transformers` to your plugins will only produce additional output. To preserve the previous functionality, set `sdk.transformer` to `true`.
260278

261279
```js
262-
import { defaultPlugins } from '@hey-api/openapi-ts';
263-
264280
export default {
265281
client: '@hey-api/client-fetch',
266282
input: 'https://get.heyapi.dev/hey-api/backend',
267283
output: 'src/client',
268284
plugins: [
269-
...defaultPlugins,
285+
// ...other plugins
270286
{
271287
dates: true,
272288
name: '@hey-api/transformers',
@@ -302,15 +318,13 @@ export default {
302318
`@hey-api/schemas` has been removed from the default plugins. To continue using it, add it to your plugins array.
303319

304320
```js
305-
import { defaultPlugins } from '@hey-api/openapi-ts';
306-
307321
export default {
308322
client: '@hey-api/client-fetch',
309323
experimentalParser: true,
310324
input: 'https://get.heyapi.dev/hey-api/backend',
311325
output: 'src/client',
312326
plugins: [
313-
...defaultPlugins,
327+
// ...other plugins
314328
'@hey-api/schemas', // [!code ++]
315329
],
316330
};

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client.gen.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient,
1313
*/
1414
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515

16-
export const client = createClient(createConfig<ClientOptions>({
17-
baseUrl: 'http://localhost:3000/base'
18-
}));
16+
export const client = createClient(createConfig<ClientOptions>());

0 commit comments

Comments
 (0)