fork of hey-api/openapi-ts because I need some additional things

Merge pull request #2680 from hey-api/copilot/fix-2679

Fix broken enum exports in index.ts

authored by

Lubos and committed by
GitHub
6476ecb0 9e7ed0b2

+49 -40
+5
.changeset/light-emus-burn.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + fix(typescript): do not mark enums as types
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-PascalCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-camelCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-preserve/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-snake_case/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-PascalCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-camelCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-preserve/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-snake_case/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-PascalCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-camelCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-ignore-null/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-preserve/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-snake_case/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-PascalCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-camelCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-preserve/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-snake_case/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-PascalCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-camelCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-ignore-null/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-preserve/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-snake_case/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-PascalCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-camelCase/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-preserve/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-snake_case/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - export type * from './types.gen'; 3 + export * from './types.gen';
+5 -1
packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts
··· 497 497 schema: IR.SchemaObject; 498 498 }) => { 499 499 const type = schemaToType({ plugin, schema }); 500 + 501 + // Don't tag enums as 'type' since they export runtime artifacts (values) 502 + const isEnum = schema.type === 'enum' && plugin.config.enums.enabled; 503 + 500 504 const symbol = plugin.registerSymbol({ 501 505 exported: true, 502 506 meta: { 503 - kind: 'type', 507 + kind: isEnum ? undefined : 'type', 504 508 }, 505 509 name: buildName({ 506 510 config: plugin.config.definitions,