Skip to content

Commit

Permalink
Merge pull request #157 from mlankamp/legacy_update
Browse files Browse the repository at this point in the history
Correctly export enums in models/index.ts
  • Loading branch information
jordanshatford authored Mar 27, 2024
2 parents 407537f + eafc5c9 commit 6bc449d
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 88 deletions.
7 changes: 5 additions & 2 deletions src/utils/write/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ const exportsModels = (config: Config, client: Client) => {
const importedModel = config.postfixModels
? `${model.name} as ${model.name + config.postfixModels}`
: model.name;
const exp = config.useLegacyEnums ? 'export' : 'export type';
let result = [`${exp} { ${importedModel} } from '${path + model.name}';`];
let result = [`export type { ${importedModel} } from '${path + model.name}';`];
if (config.enums && (model.enum.length || model.enums.length)) {
const names = model.enums.map(enumerator => enumerator.name).filter(Boolean);
const enumExports = names.length ? names : [model.name];
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');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
export { _default } from './_default';
export { AnyOfAnyAndNull } from './AnyOfAnyAndNull';
export { AnyOfArrays } from './AnyOfArrays';
export { ArrayWithAnyOfProperties } from './ArrayWithAnyOfProperties';
export { ArrayWithArray } from './ArrayWithArray';
export { ArrayWithBooleans } from './ArrayWithBooleans';
export { ArrayWithNumbers } from './ArrayWithNumbers';
export { ArrayWithProperties } from './ArrayWithProperties';
export { ArrayWithReferences } from './ArrayWithReferences';
export { ArrayWithStrings } from './ArrayWithStrings';
export { CommentWithBackticks } from './CommentWithBackticks';
export { CommentWithBreaks } from './CommentWithBreaks';
export { CommentWithExpressionPlaceholders } from './CommentWithExpressionPlaceholders';
export { CommentWithQuotes } from './CommentWithQuotes';
export { CommentWithReservedCharacters } from './CommentWithReservedCharacters';
export { CommentWithSlashes } from './CommentWithSlashes';
export { CompositionBaseModel } from './CompositionBaseModel';
export { CompositionExtendedModel } from './CompositionExtendedModel';
export { CompositionWithAllOfAndNullable } from './CompositionWithAllOfAndNullable';
export { CompositionWithAnyOf } from './CompositionWithAnyOf';
export { CompositionWithAnyOfAndNullable } from './CompositionWithAnyOfAndNullable';
export { CompositionWithAnyOfAnonymous } from './CompositionWithAnyOfAnonymous';
export { CompositionWithNestedAnyAndTypeNull } from './CompositionWithNestedAnyAndTypeNull';
export { CompositionWithNestedAnyOfAndNull } from './CompositionWithNestedAnyOfAndNull';
export { CompositionWithOneOf } from './CompositionWithOneOf';
export { CompositionWithOneOfAndComplexArrayDictionary } from './CompositionWithOneOfAndComplexArrayDictionary';
export { CompositionWithOneOfAndNullable } from './CompositionWithOneOfAndNullable';
export { CompositionWithOneOfAndProperties } from './CompositionWithOneOfAndProperties';
export { CompositionWithOneOfAndSimpleArrayDictionary } from './CompositionWithOneOfAndSimpleArrayDictionary';
export { CompositionWithOneOfAndSimpleDictionary } from './CompositionWithOneOfAndSimpleDictionary';
export { CompositionWithOneOfAnonymous } from './CompositionWithOneOfAnonymous';
export { CompositionWithOneOfDiscriminator } from './CompositionWithOneOfDiscriminator';
export { ConstValue } from './ConstValue';
export { DeprecatedModel } from './DeprecatedModel';
export { DictionaryWithArray } from './DictionaryWithArray';
export { DictionaryWithDictionary } from './DictionaryWithDictionary';
export { DictionaryWithProperties } from './DictionaryWithProperties';
export { DictionaryWithReference } from './DictionaryWithReference';
export { DictionaryWithString } from './DictionaryWithString';
export type { _default } from './_default';
export type { AnyOfAnyAndNull } from './AnyOfAnyAndNull';
export type { AnyOfArrays } from './AnyOfArrays';
export type { ArrayWithAnyOfProperties } from './ArrayWithAnyOfProperties';
export type { ArrayWithArray } from './ArrayWithArray';
export type { ArrayWithBooleans } from './ArrayWithBooleans';
export type { ArrayWithNumbers } from './ArrayWithNumbers';
export type { ArrayWithProperties } from './ArrayWithProperties';
export type { ArrayWithReferences } from './ArrayWithReferences';
export type { ArrayWithStrings } from './ArrayWithStrings';
export type { CommentWithBackticks } from './CommentWithBackticks';
export type { CommentWithBreaks } from './CommentWithBreaks';
export type { CommentWithExpressionPlaceholders } from './CommentWithExpressionPlaceholders';
export type { CommentWithQuotes } from './CommentWithQuotes';
export type { CommentWithReservedCharacters } from './CommentWithReservedCharacters';
export type { CommentWithSlashes } from './CommentWithSlashes';
export type { CompositionBaseModel } from './CompositionBaseModel';
export type { CompositionExtendedModel } from './CompositionExtendedModel';
export type { CompositionWithAllOfAndNullable } from './CompositionWithAllOfAndNullable';
export type { CompositionWithAnyOf } from './CompositionWithAnyOf';
export type { CompositionWithAnyOfAndNullable } from './CompositionWithAnyOfAndNullable';
export type { CompositionWithAnyOfAnonymous } from './CompositionWithAnyOfAnonymous';
export type { CompositionWithNestedAnyAndTypeNull } from './CompositionWithNestedAnyAndTypeNull';
export type { CompositionWithNestedAnyOfAndNull } from './CompositionWithNestedAnyOfAndNull';
export type { CompositionWithOneOf } from './CompositionWithOneOf';
export type { CompositionWithOneOfAndComplexArrayDictionary } from './CompositionWithOneOfAndComplexArrayDictionary';
export type { CompositionWithOneOfAndNullable } from './CompositionWithOneOfAndNullable';
export type { CompositionWithOneOfAndProperties } from './CompositionWithOneOfAndProperties';
export type { CompositionWithOneOfAndSimpleArrayDictionary } from './CompositionWithOneOfAndSimpleArrayDictionary';
export type { CompositionWithOneOfAndSimpleDictionary } from './CompositionWithOneOfAndSimpleDictionary';
export type { CompositionWithOneOfAnonymous } from './CompositionWithOneOfAnonymous';
export type { CompositionWithOneOfDiscriminator } from './CompositionWithOneOfDiscriminator';
export type { ConstValue } from './ConstValue';
export type { DeprecatedModel } from './DeprecatedModel';
export type { DictionaryWithArray } from './DictionaryWithArray';
export type { DictionaryWithDictionary } from './DictionaryWithDictionary';
export type { DictionaryWithProperties } from './DictionaryWithProperties';
export type { DictionaryWithReference } from './DictionaryWithReference';
export type { DictionaryWithString } from './DictionaryWithString';
export { Enum1 } from './Enum1';
export { EnumFromDescription } from './EnumFromDescription';
export type { EnumFromDescription } from './EnumFromDescription';
export { EnumWithExtensions } from './EnumWithExtensions';
export { EnumWithNumbers } from './EnumWithNumbers';
export { EnumWithReplacedCharacters } from './EnumWithReplacedCharacters';
export { EnumWithStrings } from './EnumWithStrings';
export { File } from './File';
export { FreeFormObjectWithAdditionalPropertiesEqEmptyObject } from './FreeFormObjectWithAdditionalPropertiesEqEmptyObject';
export { FreeFormObjectWithAdditionalPropertiesEqTrue } from './FreeFormObjectWithAdditionalPropertiesEqTrue';
export { FreeFormObjectWithoutAdditionalProperties } from './FreeFormObjectWithoutAdditionalProperties';
export { ModelCircle } from './ModelCircle';
export { ModelSquare } from './ModelSquare';
export { ModelThatExtends } from './ModelThatExtends';
export { ModelThatExtendsExtends } from './ModelThatExtendsExtends';
export { ModelWithAdditionalPropertiesEqTrue } from './ModelWithAdditionalPropertiesEqTrue';
export { ModelWithArray } from './ModelWithArray';
export { ModelWithArrayReadOnlyAndWriteOnly } from './ModelWithArrayReadOnlyAndWriteOnly';
export { ModelWithBoolean } from './ModelWithBoolean';
export { ModelWithCircularReference } from './ModelWithCircularReference';
export { ModelWithConst } from './ModelWithConst';
export { ModelWithDictionary } from './ModelWithDictionary';
export { ModelWithDuplicateImports } from './ModelWithDuplicateImports';
export { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties';
export { ModelWithEnum } from './ModelWithEnum';
export { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription';
export { ModelWithEnumWithHyphen } from './ModelWithEnumWithHyphen';
export { ModelWithInteger } from './ModelWithInteger';
export { ModelWithNestedArrayEnums } from './ModelWithNestedArrayEnums';
export { ModelWithNestedArrayEnumsData } from './ModelWithNestedArrayEnumsData';
export type { File } from './File';
export type { FreeFormObjectWithAdditionalPropertiesEqEmptyObject } from './FreeFormObjectWithAdditionalPropertiesEqEmptyObject';
export type { FreeFormObjectWithAdditionalPropertiesEqTrue } from './FreeFormObjectWithAdditionalPropertiesEqTrue';
export type { FreeFormObjectWithoutAdditionalProperties } from './FreeFormObjectWithoutAdditionalProperties';
export type { ModelCircle } from './ModelCircle';
export type { ModelSquare } from './ModelSquare';
export type { ModelThatExtends } from './ModelThatExtends';
export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends';
export type { ModelWithAdditionalPropertiesEqTrue } from './ModelWithAdditionalPropertiesEqTrue';
export type { ModelWithArray } from './ModelWithArray';
export type { ModelWithArrayReadOnlyAndWriteOnly } from './ModelWithArrayReadOnlyAndWriteOnly';
export type { ModelWithBoolean } from './ModelWithBoolean';
export type { ModelWithCircularReference } from './ModelWithCircularReference';
export type { ModelWithConst } from './ModelWithConst';
export type { ModelWithDictionary } from './ModelWithDictionary';
export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports';
export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties';
export type { ModelWithEnum } from './ModelWithEnum';
export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription';
export type { ModelWithEnumWithHyphen } from './ModelWithEnumWithHyphen';
export type { ModelWithInteger } from './ModelWithInteger';
export type { ModelWithNestedArrayEnums } from './ModelWithNestedArrayEnums';
export type { ModelWithNestedArrayEnumsData } from './ModelWithNestedArrayEnumsData';
export { ModelWithNestedArrayEnumsDataBar } from './ModelWithNestedArrayEnumsDataBar';
export { ModelWithNestedArrayEnumsDataFoo } from './ModelWithNestedArrayEnumsDataFoo';
export { ModelWithNestedCompositionEnums } from './ModelWithNestedCompositionEnums';
export { ModelWithNestedEnums } from './ModelWithNestedEnums';
export { ModelWithNestedProperties } from './ModelWithNestedProperties';
export { ModelWithNullableObject } from './ModelWithNullableObject';
export { ModelWithNullableString } from './ModelWithNullableString';
export { ModelWithOneOfEnum } from './ModelWithOneOfEnum';
export { ModelWithOrderedProperties } from './ModelWithOrderedProperties';
export { ModelWithPattern } from './ModelWithPattern';
export { ModelWithProperties } from './ModelWithProperties';
export { ModelWithReadOnlyAndWriteOnly } from './ModelWithReadOnlyAndWriteOnly';
export { ModelWithReference } from './ModelWithReference';
export { ModelWithString } from './ModelWithString';
export { NestedAnyOfArraysNullable } from './NestedAnyOfArraysNullable';
export { NonAsciiStringæøåÆØÅöôêÊ字符串 } from './NonAsciiStringæøåÆØÅöôêÊ字符串';
export { NullableObject } from './NullableObject';
export { Pageable } from './Pageable';
export { SimpleBoolean } from './SimpleBoolean';
export { SimpleFile } from './SimpleFile';
export { SimpleInteger } from './SimpleInteger';
export { SimpleParameter } from './SimpleParameter';
export { SimpleReference } from './SimpleReference';
export { SimpleString } from './SimpleString';
export { SimpleStringWithPattern } from './SimpleStringWithPattern';
export type { ModelWithNestedCompositionEnums } from './ModelWithNestedCompositionEnums';
export type { ModelWithNestedEnums } from './ModelWithNestedEnums';
export type { ModelWithNestedProperties } from './ModelWithNestedProperties';
export type { ModelWithNullableObject } from './ModelWithNullableObject';
export type { ModelWithNullableString } from './ModelWithNullableString';
export type { ModelWithOneOfEnum } from './ModelWithOneOfEnum';
export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties';
export type { ModelWithPattern } from './ModelWithPattern';
export type { ModelWithProperties } from './ModelWithProperties';
export type { ModelWithReadOnlyAndWriteOnly } from './ModelWithReadOnlyAndWriteOnly';
export type { ModelWithReference } from './ModelWithReference';
export type { ModelWithString } from './ModelWithString';
export type { NestedAnyOfArraysNullable } from './NestedAnyOfArraysNullable';
export type { NonAsciiStringæøåÆØÅöôêÊ字符串 } from './NonAsciiStringæøåÆØÅöôêÊ字符串';
export type { NullableObject } from './NullableObject';
export type { Pageable } from './Pageable';
export type { SimpleBoolean } from './SimpleBoolean';
export type { SimpleFile } from './SimpleFile';
export type { SimpleInteger } from './SimpleInteger';
export type { SimpleParameter } from './SimpleParameter';
export type { SimpleReference } from './SimpleReference';
export type { SimpleString } from './SimpleString';
export type { SimpleStringWithPattern } from './SimpleStringWithPattern';

0 comments on commit 6bc449d

Please sign in to comment.