···5566# Migrating
7788-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.
88+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 an issue with migration, please [open an issue](https://github.com/hey-api/openapi-ts/issues).
991010## @next
1111···4949### Deprecated `name`
50505151This config option is deprecated and will be removed.
5252+5353+## v0.39.0
5454+5555+### Single `enums.gen.ts` file
5656+5757+Enums are now exported from a single file. If you used imports from `model.ts`, you can change it to `enums.gen.ts`.
5858+5959+```js
6060+import { Enum } from 'client/models' // [!code --]
6161+import { Enum } from 'client/enums.gen.ts' // [!code ++]
6262+```
6363+6464+Enums are no longer exported from `index.ts`. If you used imports from index file, you will need to move enums into their own import statement.
6565+6666+```js
6767+import { Enum, DefaultService } from 'client' // [!code --]
6868+import { Enum } from 'client/enums.gen.ts' // [!code ++]
6969+import { DefaultService } from 'client/services' // [!code ++]
7070+```
52715372## v0.38.0
5473···140159141160## OpenAPI TypeScript Codegen
142161143143-`openapi-ts` was originally forked from Ferdi Koomen's [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen). Therefore, we want you to be able to migrate your openapi-typescript-codegen projects. Migration should be relatively straightforward if you follow the release notes on this page. If you run into an issue with migration, please [open an issue](https://github.com/hey-api/openapi-ts/issues).
144144-145145-### Changed
146146-147147-- `exportSchemas` is `true` by default (see [v0.27.36](#v0-27-36))
148148-- `useOptions` is `true` by default (see [v0.27.38](#v0-27-38))
149149-150150-### Removed
151151-152152-- `useUnionTypes` has been removed (see [v0.27.24](#v0-27-24))
153153-- `indent` has been removed (see [v0.27.26](#v0-27-26))
154154-- `postfixModels` has been removed (see [v0.35.0](#v0-35-0))
162162+`openapi-ts` was originally forked from Ferdi Koomen's [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen). Therefore, we want you to be able to migrate your projects. Migration should be relatively straightforward if you follow the release notes on this page. Start here and scroll up to the release you're migrating to.
+11-4
packages/openapi-ts/src/compiler/index.ts
···11-import { type PathOrFileDescriptor, writeFileSync } from 'node:fs';
11+import { writeFileSync } from 'node:fs';
2233import ts from 'typescript';
44···1515 private _headers: Array<string> = [];
1616 private _imports: Array<ts.Node> = [];
1717 private _items: Array<ts.Node | string> = [];
1818+ private _path: string = '';
18191920 public add(...nodes: Array<ts.Node | string>): void {
2021 this._items = [...this._items, ...nodes];
···29303031 public addNamedImport(...params: Parameters<typeof module.createNamedImportDeclarations>): void {
3132 this._imports = [...this._imports, compiler.import.named(...params)];
3333+ }
3434+3535+ public setPath(path: string) {
3636+ this._path = path;
3737+ return this;
3238 }
33393440 public toString(seperator: string = '\n') {
···4349 return output.join(seperator);
4450 }
45514646- public write(file: PathOrFileDescriptor, seperator: string = '\n') {
4747- if (!this._items.length) {
5252+ public write(seperator = '\n') {
5353+ // TODO: throw if path is not set. do not throw if items are empty
5454+ if (!this._items.length || !this._path) {
4855 return;
4956 }
5050- writeFileSync(file, this.toString(seperator));
5757+ writeFileSync(this._path, this.toString(seperator));
5158 }
5259}
5360
···11-export { ApiError } from './core/ApiError';
22-export { CancelablePromise, CancelError } from './core/CancelablePromise';
33-export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI';
44-export * from './models';
55-export * from './schemas';
66-export * from './services';