diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aab4f7e2..519787eba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # @hey-api/openapi-ts +## 0.29.2 + +### Patch Changes + +- Fix export types as type only when using useLegacyEnums ([#160](https://github.com/hey-api/openapi-ts/pull/160)) + +## 0.29.1 + +### Patch Changes + +- Properly export enums when using useLegacyEnums ([#158](https://github.com/hey-api/openapi-ts/pull/158)) + ## 0.29.0 ### Minor Changes diff --git a/package.json b/package.json index 3345f6ff0..5faa289c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hey-api/openapi-ts", - "version": "0.29.0", + "version": "0.29.2", "type": "module", "description": "Turn your OpenAPI specification into a beautiful TypeScript client", "homepage": "https://github.com/hey-api/openapi-ts/", diff --git a/src/utils/write/models.ts b/src/utils/write/models.ts index a64ad4935..af8150cc5 100644 --- a/src/utils/write/models.ts +++ b/src/utils/write/models.ts @@ -47,6 +47,10 @@ const exportsModels = (config: Config, client: Client) => { const enumExportsString = enumExports.map(name => enumName(name)).join(', '); result = [...result, `export { ${enumExportsString} } from '${path + model.name}';`]; } + if (config.useLegacyEnums && model.enum.length) { + result = [`export { ${importedModel} } from '${path + model.name}';`]; + } + return result.join('\n'); }); return output.join('\n'); diff --git a/test/__snapshots__/v3-legacy-enums/test/generated/v3_legacy_enums/models/index.ts.snap b/test/__snapshots__/v3-legacy-enums/test/generated/v3_legacy_enums/models/index.ts.snap index 562e14a02..07fe10bec 100644 --- a/test/__snapshots__/v3-legacy-enums/test/generated/v3_legacy_enums/models/index.ts.snap +++ b/test/__snapshots__/v3-legacy-enums/test/generated/v3_legacy_enums/models/index.ts.snap @@ -37,12 +37,12 @@ export type { DictionaryWithDictionary } from './DictionaryWithDictionary'; export type { DictionaryWithProperties } from './DictionaryWithProperties'; export type { DictionaryWithReference } from './DictionaryWithReference'; export type { DictionaryWithString } from './DictionaryWithString'; -export type { Enum1 } from './Enum1'; +export { Enum1 } from './Enum1'; export type { EnumFromDescription } from './EnumFromDescription'; -export type { EnumWithExtensions } from './EnumWithExtensions'; -export type { EnumWithNumbers } from './EnumWithNumbers'; -export type { EnumWithReplacedCharacters } from './EnumWithReplacedCharacters'; -export type { EnumWithStrings } from './EnumWithStrings'; +export { EnumWithExtensions } from './EnumWithExtensions'; +export { EnumWithNumbers } from './EnumWithNumbers'; +export { EnumWithReplacedCharacters } from './EnumWithReplacedCharacters'; +export { EnumWithStrings } from './EnumWithStrings'; export type { File } from './File'; export type { FreeFormObjectWithAdditionalPropertiesEqEmptyObject } from './FreeFormObjectWithAdditionalPropertiesEqEmptyObject'; export type { FreeFormObjectWithAdditionalPropertiesEqTrue } from './FreeFormObjectWithAdditionalPropertiesEqTrue'; @@ -66,8 +66,8 @@ export type { ModelWithEnumWithHyphen } from './ModelWithEnumWithHyphen'; export type { ModelWithInteger } from './ModelWithInteger'; export type { ModelWithNestedArrayEnums } from './ModelWithNestedArrayEnums'; export type { ModelWithNestedArrayEnumsData } from './ModelWithNestedArrayEnumsData'; -export type { ModelWithNestedArrayEnumsDataBar } from './ModelWithNestedArrayEnumsDataBar'; -export type { ModelWithNestedArrayEnumsDataFoo } from './ModelWithNestedArrayEnumsDataFoo'; +export { ModelWithNestedArrayEnumsDataBar } from './ModelWithNestedArrayEnumsDataBar'; +export { ModelWithNestedArrayEnumsDataFoo } from './ModelWithNestedArrayEnumsDataFoo'; export type { ModelWithNestedCompositionEnums } from './ModelWithNestedCompositionEnums'; export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; export type { ModelWithNestedProperties } from './ModelWithNestedProperties';