Skip to content

Commit

Permalink
feat: add typescript.exportInlineEnums option
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Nov 22, 2024
1 parent a9cca25 commit 62e37d5
Show file tree
Hide file tree
Showing 27 changed files with 376 additions and 24 deletions.
27 changes: 27 additions & 0 deletions .changeset/funny-laws-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
'@hey-api/openapi-ts': minor
---

feat: add typescript.exportInlineEnums option

### Added `typescript.exportInlineEnums` option

By default, inline enums (enums not defined as reusable components in the input file) will be generated only as inlined union types. You can set `exportInlineEnums` to `true` to treat inline enums as reusable components. When `true`, the exported enums will follow the style defined in `enums`.

This is a breaking change since in the previous versions, inline enums were always treated as reusable components. To preserve your current output, set `exportInlineEnums` to `true`. This feature works only with the experimental parser.

```js
export default {
client: '@hey-api/client-fetch',
experimentalParser: true,
input: 'path/to/openapi.json',
output: 'src/client',
plugins: [
// ...other plugins
{
exportInlineEnums: true, // [!code ++]
name: '@hey-api/typescript',
},
],
};
```
22 changes: 22 additions & 0 deletions docs/openapi-ts/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ import { client } from 'client/sdk.gen'; // [!code ++]

This plugin has been renamed to `@hey-api/typescript`.

### Added `typescript.exportInlineEnums` option

By default, inline enums (enums not defined as reusable components in the input file) will be generated only as inlined union types. You can set `exportInlineEnums` to `true` to treat inline enums as reusable components. When `true`, the exported enums will follow the style defined in `enums`.

This is a breaking change since in the previous versions, inline enums were always treated as reusable components. To preserve your current output, set `exportInlineEnums` to `true`. This feature works only with the experimental parser.

```js
export default {
client: '@hey-api/client-fetch',
experimentalParser: true,
input: 'path/to/openapi.json',
output: 'src/client',
plugins: [
// ...other plugins
{
exportInlineEnums: true, // [!code ++]
name: '@hey-api/typescript',
},
],
};
```

## v0.56.0

### Deprecated `tree` in `@hey-api/types`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const defaultConfig: PluginConfig<Config> = {
_handler: handler,
_handlerLegacy: handlerLegacy,
enums: false,
exportInlineEnums: false,
name: '@hey-api/typescript',
output: 'types',
style: 'preserve',
Expand Down
Loading

0 comments on commit 62e37d5

Please sign in to comment.