diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/kiwi.js b/kiwi.js index 00d6536..4452854 100644 --- a/kiwi.js +++ b/kiwi.js @@ -2297,17 +2297,14 @@ var kiwi = exports || kiwi || {}, exports; var definition = schema.definitions[i]; if (definition.kind === 'ENUM') { - lines.push(indent + 'export type ' + definition.name + ' ='); + lines.push(indent + 'export enum ' + definition.name + ' {'); for (var j = 0; j < definition.fields.length; j++) { - lines.push(indent + ' ' + JSON.stringify(definition.fields[j].name) + (j + 1 < definition.fields.length ? ' |' : ';')); + lines.push(indent + ' ' + definition.fields[j].name + ' = ' + JSON.stringify(definition.fields[j].name) + ','); } - if (!definition.fields.length) { - lines.push(indent + ' any;'); - } - - lines.push(''); + lines.push(indent + '}'); + lines.push('') } } diff --git a/test/test-schema.ts b/test/test-schema.ts index f74affd..e193dd7 100644 --- a/test/test-schema.ts +++ b/test/test-schema.ts @@ -1,7 +1,8 @@ export namespace test { - export type Enum = - "A" | - "B"; + export enum Enum { + A = "A", + B = "B", + } export interface EnumStruct { x: Enum;