diff --git a/.changeset/itchy-jobs-report.md b/.changeset/itchy-jobs-report.md new file mode 100644 index 000000000..ae31739a3 --- /dev/null +++ b/.changeset/itchy-jobs-report.md @@ -0,0 +1,6 @@ +--- +"@hey-api/openapi-ts": minor +"@hey-api/docs": patch +--- + +feat: remove enum postfix, use typescript enums in types when generated, export enums from types.gen.ts diff --git a/docs/openapi-ts/configuration.md b/docs/openapi-ts/configuration.md index a0a64f196..4a70d9a85 100644 --- a/docs/openapi-ts/configuration.md +++ b/docs/openapi-ts/configuration.md @@ -173,18 +173,20 @@ You can also prevent your client from being processed by linters by adding your If you need to iterate through possible field values without manually typing arrays, you can export enums with -```js{2} +```js{5} export default { - enums: 'javascript', input: 'path/to/openapi.json', output: 'src/client', + types: { + enums: 'javascript', + }, } ``` This will export enums as plain JavaScript objects. For example, `Foo` would become ```js -export const FooEnum = { +export const Foo = { FOO: 'foo', BAR: 'bar', } as const; @@ -192,11 +194,13 @@ export const FooEnum = { We discourage generating [TypeScript enums](https://www.typescriptlang.org/docs/handbook/enums.html) because they are not standard JavaScript and pose [typing challenges](https://dev.to/ivanzm123/dont-use-enums-in-typescript-they-are-very-dangerous-57bh). If you really need TypeScript enums, you can export them with -```js{2} +```js{5} export default { - enums: 'typescript', input: 'path/to/openapi.json', output: 'src/client', + types: { + enums: 'typescript', + }, } ``` diff --git a/docs/openapi-ts/migrating.md b/docs/openapi-ts/migrating.md index 908d1e637..d8ea3b351 100644 --- a/docs/openapi-ts/migrating.md +++ b/docs/openapi-ts/migrating.md @@ -19,7 +19,6 @@ Currently, `index.ts` file exports all generated artifacts. We will be slowly mo export { ApiError } from './core/ApiError'; export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; -export * from './enums.gen'; // [!code --] export * from './schemas.gen'; // [!code --] export * from './services.gen'; // [!code --] export * from './types.gen'; // [!code --] @@ -28,7 +27,6 @@ export * from './types.gen'; // [!code --] Any non-core related imports should be imported as ```js -import { Enum } from 'client/enums.gen' import { $Schema } from 'client/schemas.gen'; import { DefaultService } from 'client/services.gen'; import type { Model } from 'client/types.gen'; @@ -52,6 +50,51 @@ This config option is deprecated and will be removed in favor of [clients](./cli This config option is deprecated and will be removed in favor of [clients](./clients). +## v0.43.0 + +### Removed `enums.gen.ts` + +This file has been removed. Instead, enums are exported from `types.gen.ts`. If you use imports from `enums.gen.ts`, you should be able to easily find and replace all instances. + +```js +import { Foo } from 'client/enums.gen'; // [!code --] +import { Foo } from 'client/types.gen'; // [!code ++] +``` + +### Removed `Enum` postfix + +Generated enum names are no longer postfixed with `Enum`. You can either alias your imports + +```js +import { FooEnum } from 'client/types.gen'; // [!code --] +import { Foo as FooEnum } from 'client/types.gen'; // [!code ++] + +console.log(FooEnum.value); // only import needs to be changed +``` + +or update all references to enums + +```js +import { FooEnum } from 'client/types.gen'; // [!code --] +import { Foo } from 'client/types.gen'; // [!code ++] + +console.log(Foo.value); // all references need to be changed +``` + +### Moved `enums` + +This config option has been moved. You can now configure enums using the `types.enums` option. + +```js{5} +export default { + input: 'path/to/openapi.json', + output: 'src/client', + types: { + enums: 'javascript', + }, +} +``` + ## v0.42.0 ### Changed `format` diff --git a/packages/openapi-ts/src/index.ts b/packages/openapi-ts/src/index.ts index 0e3f5ab36..eecb79ff2 100644 --- a/packages/openapi-ts/src/index.ts +++ b/packages/openapi-ts/src/index.ts @@ -180,6 +180,7 @@ const getServices = (userConfig: UserConfig): Config['services'] => { const getTypes = (userConfig: UserConfig): Config['types'] => { let types: Config['types'] = { dates: false, + enums: false, export: true, name: 'preserve', }; @@ -253,7 +254,6 @@ const initConfig = async ( base, debug = false, dryRun = false, - enums = false, exportCore = true, format = false, input, @@ -296,7 +296,6 @@ const initConfig = async ( client, debug, dryRun, - enums, exportCore: client.startsWith('@hey-api') ? false : exportCore, format, input, diff --git a/packages/openapi-ts/src/openApi/common/parser/__tests__/operation.spec.ts b/packages/openapi-ts/src/openApi/common/parser/__tests__/operation.spec.ts index b8f30bd32..1f1c55b10 100644 --- a/packages/openapi-ts/src/openApi/common/parser/__tests__/operation.spec.ts +++ b/packages/openapi-ts/src/openApi/common/parser/__tests__/operation.spec.ts @@ -12,7 +12,6 @@ describe('getOperationName', () => { client: 'fetch', debug: false, dryRun: true, - enums: false, exportCore: false, format: false, input: '', @@ -36,7 +35,6 @@ describe('getOperationName', () => { client: 'fetch', debug: false, dryRun: true, - enums: false, exportCore: false, format: false, input: '', diff --git a/packages/openapi-ts/src/openApi/v2/parser/__tests__/getServices.spec.ts b/packages/openapi-ts/src/openApi/v2/parser/__tests__/getServices.spec.ts index e0a18ff37..345cacc2d 100644 --- a/packages/openapi-ts/src/openApi/v2/parser/__tests__/getServices.spec.ts +++ b/packages/openapi-ts/src/openApi/v2/parser/__tests__/getServices.spec.ts @@ -9,7 +9,6 @@ describe('getServices', () => { client: 'fetch', debug: false, dryRun: true, - enums: false, exportCore: true, format: false, input: '', diff --git a/packages/openapi-ts/src/openApi/v3/parser/__tests__/getServices.spec.ts b/packages/openapi-ts/src/openApi/v3/parser/__tests__/getServices.spec.ts index 13023a20c..92a631ef0 100644 --- a/packages/openapi-ts/src/openApi/v3/parser/__tests__/getServices.spec.ts +++ b/packages/openapi-ts/src/openApi/v3/parser/__tests__/getServices.spec.ts @@ -9,7 +9,6 @@ describe('getServices', () => { client: 'fetch', debug: false, dryRun: true, - enums: false, exportCore: true, format: false, input: '', diff --git a/packages/openapi-ts/src/types/config.ts b/packages/openapi-ts/src/types/config.ts index c84ee215c..15f993e2c 100644 --- a/packages/openapi-ts/src/types/config.ts +++ b/packages/openapi-ts/src/types/config.ts @@ -25,11 +25,6 @@ export interface UserConfig { * @default false */ dryRun?: boolean; - /** - * Generate enum definitions? - * @default false - */ - enums?: 'javascript' | 'typescript' | false; /** * Generate core client classes? * @default true @@ -127,6 +122,11 @@ export interface UserConfig { * @default false */ dates?: boolean; + /** + * Generate enum definitions? + * @default false + */ + enums?: 'javascript' | 'typescript' | false; /** * Generate types? * @default true diff --git a/packages/openapi-ts/src/utils/__tests__/handlebars.spec.ts b/packages/openapi-ts/src/utils/__tests__/handlebars.spec.ts index f8dd32e42..07f337db0 100644 --- a/packages/openapi-ts/src/utils/__tests__/handlebars.spec.ts +++ b/packages/openapi-ts/src/utils/__tests__/handlebars.spec.ts @@ -13,7 +13,6 @@ describe('registerHandlebarHelpers', () => { client: 'fetch', debug: false, dryRun: false, - enums: 'javascript', exportCore: true, format: 'prettier', input: '', @@ -21,7 +20,9 @@ describe('registerHandlebarHelpers', () => { output: '', schemas: {}, services: {}, - types: {}, + types: { + enums: 'javascript', + }, useOptions: false, }); registerHandlebarHelpers(); @@ -40,7 +41,6 @@ describe('registerHandlebarTemplates', () => { client: 'fetch', debug: false, dryRun: false, - enums: 'javascript', exportCore: true, format: 'prettier', input: '', @@ -48,7 +48,9 @@ describe('registerHandlebarTemplates', () => { output: '', schemas: {}, services: {}, - types: {}, + types: { + enums: 'javascript', + }, useOptions: false, }); const templates = registerHandlebarTemplates(); diff --git a/packages/openapi-ts/src/utils/enum.ts b/packages/openapi-ts/src/utils/enum.ts index d3f436b7b..d17838c41 100644 --- a/packages/openapi-ts/src/utils/enum.ts +++ b/packages/openapi-ts/src/utils/enum.ts @@ -49,7 +49,8 @@ export const enumName = (client: Client, name?: string) => { /[-_]([a-z])/gi, ($0, $1: string) => $1.toLocaleUpperCase(), ); - const result = `${escapedName.charAt(0).toLocaleUpperCase() + escapedName.slice(1)}Enum`; + const result = + escapedName.charAt(0).toLocaleUpperCase() + escapedName.slice(1); if (client.enumNames.includes(result)) { return null; } diff --git a/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts index e05905a08..584cc6fb1 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts @@ -15,7 +15,6 @@ describe('writeClientClass', () => { client: 'fetch', debug: false, dryRun: false, - enums: 'javascript', exportCore: true, format: false, input: '', @@ -24,7 +23,9 @@ describe('writeClientClass', () => { output: '', schemas: {}, services: {}, - types: {}, + types: { + enums: 'javascript', + }, useOptions: true, }); diff --git a/packages/openapi-ts/src/utils/write/__tests__/client.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/client.spec.ts index e506c5291..a818e9f3d 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/client.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/client.spec.ts @@ -15,7 +15,6 @@ describe('writeClient', () => { client: 'fetch', debug: false, dryRun: false, - enums: 'javascript', exportCore: true, format: 'prettier', input: '', @@ -23,7 +22,9 @@ describe('writeClient', () => { output: './dist', schemas: {}, services: {}, - types: {}, + types: { + enums: 'javascript', + }, useOptions: false, }); diff --git a/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts index 758d6866b..d2dc4486d 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts @@ -28,7 +28,6 @@ describe('writeCore', () => { client: 'fetch', debug: false, dryRun: false, - enums: 'javascript', exportCore: true, format: false, input: '', @@ -37,7 +36,9 @@ describe('writeCore', () => { output: '', schemas: {}, services: {}, - types: {}, + types: { + enums: 'javascript', + }, useOptions: true, }); @@ -82,7 +83,6 @@ describe('writeCore', () => { client: 'fetch', debug: false, dryRun: false, - enums: 'javascript', exportCore: true, format: false, input: '', @@ -91,7 +91,9 @@ describe('writeCore', () => { output: '', schemas: {}, services: {}, - types: {}, + types: { + enums: 'javascript', + }, useOptions: true, }); @@ -119,7 +121,6 @@ describe('writeCore', () => { client: 'fetch', debug: false, dryRun: false, - enums: 'javascript', exportCore: true, format: false, input: '', @@ -128,7 +129,9 @@ describe('writeCore', () => { output: '', schemas: {}, services: {}, - types: {}, + types: { + enums: 'javascript', + }, useOptions: true, }); diff --git a/packages/openapi-ts/src/utils/write/__tests__/index.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/index.spec.ts index 8e6f39f9f..818213b8c 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/index.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/index.spec.ts @@ -15,7 +15,6 @@ describe('processIndex', () => { client: 'fetch', debug: false, dryRun: false, - enums: 'javascript', exportCore: true, format: false, input: '', @@ -23,15 +22,13 @@ describe('processIndex', () => { output: '', schemas: {}, services: {}, - types: {}, + types: { + enums: 'javascript', + }, useOptions: true, }); const files: Parameters[0]['files'] = { - enums: new TypeScriptFile({ - dir: '/', - name: 'enums.ts', - }), index: new TypeScriptFile({ dir: '/', name: 'index.ts', diff --git a/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts index 25f287e70..e0ca8d8aa 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts @@ -5,17 +5,16 @@ import { describe, expect, it, vi } from 'vitest'; import { TypeScriptFile } from '../../../compiler'; import { setConfig } from '../../config'; -import { processTypesAndEnums } from '../models'; +import { processTypes } from '../types'; vi.mock('node:fs'); -describe('processTypesAndEnums', () => { +describe('processTypes', () => { it('writes to filesystem', async () => { setConfig({ client: 'fetch', debug: false, dryRun: false, - enums: 'javascript', exportCore: true, format: false, input: '', @@ -24,11 +23,13 @@ describe('processTypesAndEnums', () => { output: '', schemas: {}, services: {}, - types: {}, + types: { + enums: 'javascript', + }, useOptions: true, }); - const client: Parameters[0]['client'] = { + const client: Parameters[0]['client'] = { enumNames: [], models: [ { @@ -56,22 +57,17 @@ describe('processTypesAndEnums', () => { }; const files = { - enums: new TypeScriptFile({ - dir: '/', - name: 'enums.ts', - }), types: new TypeScriptFile({ dir: '/', name: 'models.ts', }), }; - await processTypesAndEnums({ + await processTypes({ client, files, }); - files.enums.write(); files.types.write(); expect(writeFileSync).toHaveBeenCalledWith( diff --git a/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts index c4d5e3125..47bb5c403 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts @@ -16,7 +16,6 @@ describe('processSchemas', () => { client: 'fetch', debug: false, dryRun: false, - enums: 'javascript', exportCore: true, format: false, input: '', @@ -25,7 +24,9 @@ describe('processSchemas', () => { output: '', schemas: {}, services: {}, - types: {}, + types: { + enums: 'javascript', + }, useOptions: true, }); diff --git a/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts index 6d940648e..0426e4c26 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts @@ -15,7 +15,6 @@ describe('processServices', () => { client: 'fetch', debug: false, dryRun: false, - enums: false, exportCore: true, format: false, input: '', diff --git a/packages/openapi-ts/src/utils/write/client.ts b/packages/openapi-ts/src/utils/write/client.ts index eb5528502..72190716f 100644 --- a/packages/openapi-ts/src/utils/write/client.ts +++ b/packages/openapi-ts/src/utils/write/client.ts @@ -9,9 +9,9 @@ import type { Templates } from '../handlebars'; import { writeClientClass } from './class'; import { writeCore } from './core'; import { processIndex } from './index'; -import { processTypesAndEnums } from './models'; import { processSchemas } from './schemas'; import { processServices } from './services'; +import { processTypes } from './types'; /** * Write our OpenAPI client, using the given templates at the given output @@ -50,12 +50,6 @@ export const writeClient = async ( name: 'index.ts', }), }; - if (config.enums) { - files.enums = new TypeScriptFile({ - dir: config.output, - name: 'enums.ts', - }); - } if (config.schemas.export) { files.schemas = new TypeScriptFile({ dir: config.output, @@ -76,7 +70,7 @@ export const writeClient = async ( } await processSchemas({ file: files.schemas, openApi }); - await processTypesAndEnums({ client, files }); + await processTypes({ client, files }); await processServices({ client, files }); // deprecated files @@ -85,7 +79,6 @@ export const writeClient = async ( await processIndex({ files }); - files.enums?.write('\n\n'); files.schemas?.write('\n\n'); files.services?.write('\n\n'); files.types?.write('\n\n'); diff --git a/packages/openapi-ts/src/utils/write/index.ts b/packages/openapi-ts/src/utils/write/index.ts index 39198145c..69f61ec02 100644 --- a/packages/openapi-ts/src/utils/write/index.ts +++ b/packages/openapi-ts/src/utils/write/index.ts @@ -43,9 +43,6 @@ export const processIndex = async ({ ); } - if (files.enums && !files.enums.isEmpty()) { - files.index.add(compiler.export.all(`./${files.enums.getName(false)}`)); - } if (files.schemas && !files.schemas.isEmpty()) { files.index.add(compiler.export.all(`./${files.schemas.getName(false)}`)); } diff --git a/packages/openapi-ts/src/utils/write/models.ts b/packages/openapi-ts/src/utils/write/types.ts similarity index 92% rename from packages/openapi-ts/src/utils/write/models.ts rename to packages/openapi-ts/src/utils/write/types.ts index 87b569117..df2bb21b7 100644 --- a/packages/openapi-ts/src/utils/write/models.ts +++ b/packages/openapi-ts/src/utils/write/types.ts @@ -16,7 +16,7 @@ import { transformTypeName } from '../transform'; import { serviceExportedNamespace } from './services'; import { toType } from './type'; -type OnNode = (node: Node, type?: 'enum') => void; +type OnNode = (node: Node) => void; const emptyModel: Model = { $refs: [], @@ -42,12 +42,7 @@ const processComposition = (client: Client, model: Model, onNode: OnNode) => { model.enums.forEach((enumerator) => processEnum(client, enumerator, onNode)); }; -const processEnum = ( - client: Client, - model: Model, - onNode: OnNode, - exportType = false, -) => { +const processEnum = (client: Client, model: Model, onNode: OnNode) => { const config = getConfig(); const properties: Record = {}; @@ -73,7 +68,7 @@ const processEnum = ( model.deprecated && '@deprecated', ]; - if (exportType) { + if (config.types.enums !== 'typescript') { const node = compiler.typedef.alias( ensureValidTypeScriptJavaScriptIdentifier(model.name), enumUnionType(model.enum), @@ -82,17 +77,17 @@ const processEnum = ( onNode(node); } - if (config.enums === 'typescript') { + if (config.types.enums === 'typescript') { const node = compiler.types.enum({ comments, leadingComment: comment, name, obj: properties, }); - onNode(node, 'enum'); + onNode(node); } - if (config.enums === 'javascript') { + if (config.types.enums === 'javascript') { const expression = compiler.types.object({ comments, multiLine: true, @@ -101,7 +96,7 @@ const processEnum = ( }); const node = compiler.export.asConst(name, expression); addLeadingJSDocComment(node, comment); - onNode(node, 'enum'); + onNode(node); } }; @@ -126,7 +121,7 @@ const processModel = (client: Client, model: Model, onNode: OnNode) => { case 'interface': return processComposition(client, model, onNode); case 'enum': - return processEnum(client, model, onNode, true); + return processEnum(client, model, onNode); default: return processType(client, model, onNode); } @@ -254,7 +249,7 @@ const processServiceTypes = (services: Service[], onNode: OnNode) => { onNode(node); }; -export const processTypesAndEnums = async ({ +export const processTypes = async ({ client, files, }: { @@ -262,12 +257,8 @@ export const processTypesAndEnums = async ({ files: Record; }): Promise => { for (const model of client.models) { - processModel(client, model, (node, type) => { - if (type === 'enum') { - files.enums?.add(node); - } else { - files.types?.add(node); - } + processModel(client, model, (node) => { + files.types?.add(node); }); } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/OpenAPI.ts.snap index f9eab42e2..7286660a4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/OpenAPI.ts.snap @@ -1,4 +1,3 @@ - import type { ApiRequestOptions } from './ApiRequestOptions'; type Headers = Record; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/enums.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/enums.gen.ts.snap deleted file mode 100644 index 1846b946a..000000000 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/enums.gen.ts.snap +++ /dev/null @@ -1,74 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -/** - * This is a simple enum with strings - */ -export const EnumWithStringsEnum = { - SUCCESS: 'Success', - WARNING: 'Warning', - ERROR: 'Error', - _SINGLE_QUOTE_: "'Single Quote'", - _DOUBLE_QUOTES_: '"Double Quotes"', - 'NON_ASCII__ØÆÅÔÖ_ØÆÅÔÖ字符串': 'Non-ascii: øæåôöØÆÅÔÖ字符串' -} as const; - -/** - * This is a simple enum with numbers - */ -export const EnumWithNumbersEnum = { - '_1': 1, - '_2': 2, - '_3': 3, - '_1.1': 1.1, - '_1.2': 1.2, - '_1.3': 1.3, - '_100': 100, - '_200': 200, - '_300': 300, - '_-100': -100, - '_-200': -200, - '_-300': -300, - '_-1.1': -1.1, - '_-1.2': -1.2, - '_-1.3': -1.3 -} as const; - -/** - * This is a simple enum with numbers - */ -export const EnumWithExtensionsEnum = { - /** - * Used when the status of something is successful - */ - CUSTOM_SUCCESS: 200, - /** - * Used when the status of something has a warning - */ - CUSTOM_WARNING: 400, - /** - * Used when the status of something has an error - */ - CUSTOM_ERROR: 500 -} as const; - -/** - * This is a simple enum with strings - */ -export const TestEnum = { - SUCCESS: 'Success', - WARNING: 'Warning', - ERROR: 'Error', - 'ØÆÅ字符串': 'ØÆÅ字符串' -} as const; - -/** - * These are the HTTP error code enums - */ -export const StatusCodeEnum = { - _100: '100', - _200_FOO: '200 FOO', - _300_FOO_BAR: '300 FOO_BAR', - _400_FOO_BAR: '400 foo-bar', - _500_FOO_BAR: '500 foo.bar', - _600_FOO_BAR: '600 foo&bar' -} as const; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/index.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/index.ts.snap index 6eb4b0c3a..205031a4e 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/index.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/index.ts.snap @@ -2,7 +2,6 @@ export { ApiError } from './core/ApiError'; export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; -export * from './enums.gen'; export * from './schemas.gen'; export * from './services.gen'; export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/types.gen.ts.snap index f69b10429..a0b35f501 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/types.gen.ts.snap @@ -243,6 +243,16 @@ export type ModelWithEnum = { bool?: boolean; }; +/** + * This is a simple enum with strings + */ +export type test = 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + +/** + * These are the HTTP error code enums + */ +export type statusCode = '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** * This is a model with one enum */ diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/OpenAPI.ts.snap index f9eab42e2..7286660a4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/OpenAPI.ts.snap @@ -1,4 +1,3 @@ - import type { ApiRequestOptions } from './ApiRequestOptions'; type Headers = Record; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/enums.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/enums.gen.ts.snap deleted file mode 100644 index 641bb2c83..000000000 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/enums.gen.ts.snap +++ /dev/null @@ -1,124 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -/** - * This is a simple enum with strings - */ -export const EnumWithStringsEnum = { - SUCCESS: 'Success', - WARNING: 'Warning', - ERROR: 'Error', - _SINGLE_QUOTE_: "'Single Quote'", - _DOUBLE_QUOTES_: '"Double Quotes"', - 'NON_ASCII__ØÆÅÔÖ_ØÆÅÔÖ字符串': 'Non-ascii: øæåôöØÆÅÔÖ字符串' -} as const; - -export const EnumWithReplacedCharactersEnum = { - _SINGLE_QUOTE_: "'Single Quote'", - _DOUBLE_QUOTES_: '"Double Quotes"', - 'ØÆÅÔÖ_ØÆÅÔÖ字符串': 'øæåôöØÆÅÔÖ字符串', - '_3.1': 3.1, - EMPTY_STRING: '' -} as const; - -/** - * This is a simple enum with numbers - */ -export const EnumWithNumbersEnum = { - '_1': 1, - '_2': 2, - '_3': 3, - '_1.1': 1.1, - '_1.2': 1.2, - '_1.3': 1.3, - '_100': 100, - '_200': 200, - '_300': 300, - '_-100': -100, - '_-200': -200, - '_-300': -300, - '_-1.1': -1.1, - '_-1.2': -1.2, - '_-1.3': -1.3 -} as const; - -/** - * This is a simple enum with numbers - */ -export const EnumWithExtensionsEnum = { - /** - * Used when the status of something is successful - */ - CUSTOM_SUCCESS: 200, - /** - * Used when the status of something has a warning - */ - CUSTOM_WARNING: 400, - /** - * Used when the status of something has an error - */ - CUSTOM_ERROR: 500 -} as const; - -export const EnumWithXEnumNamesEnum = { - zero: 0, - one: 1, - two: 2 -} as const; - -/** - * This is a simple enum with strings - */ -export const FooBarEnumEnum = { - SUCCESS: 'Success', - WARNING: 'Warning', - ERROR: 'Error', - 'ØÆÅ字符串': 'ØÆÅ字符串' -} as const; - -/** - * These are the HTTP error code enums - */ -export const StatusCodeEnum = { - _100: '100', - _200_FOO: '200 FOO', - _300_FOO_BAR: '300 FOO_BAR', - _400_FOO_BAR: '400 foo-bar', - _500_FOO_BAR: '500 foo.bar', - _600_FOO_BAR: '600 foo&bar' -} as const; - -export const FooBarBazQuxEnum = { - _3_0: '3.0' -} as const; - -export const Enum1Enum = { - BIRD: 'Bird', - DOG: 'Dog' -} as const; - -export const FooEnum = { - BAR: 'Bar' -} as const; - -export const ModelWithNestedArrayEnumsDataFooEnum = { - FOO: 'foo', - BAR: 'bar' -} as const; - -export const ModelWithNestedArrayEnumsDataBarEnum = { - BAZ: 'baz', - QUX: 'qux' -} as const; - -/** - * Период - */ -export const ValueEnum = { - '_-10': -10, - '_-1': -1, - '_0': 0, - '_1': 1, - '_3': 3, - '_6': 6, - '_12': 12 -} as const; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/index.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/index.ts.snap index 6eb4b0c3a..205031a4e 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/index.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/index.ts.snap @@ -2,7 +2,6 @@ export { ApiError } from './core/ApiError'; export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; -export * from './enums.gen'; export * from './schemas.gen'; export * from './services.gen'; export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/types.gen.ts.snap index c3494aaf5..7f0722ad6 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/types.gen.ts.snap @@ -278,6 +278,11 @@ export type ModelWithNullableString = { 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; }; +/** + * This is a simple enum with strings + */ +export type foo_bar_enum_ = 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** * This is a model with one enum */ @@ -296,6 +301,11 @@ export type ModelWithEnum = { bool?: boolean; }; +/** + * These are the HTTP error code enums + */ +export type statusCode = '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** * This is a model with one enum with escaped name */ @@ -303,6 +313,8 @@ export type ModelWithEnumWithHyphen = { 'foo-bar-baz-qux'?: '3.0'; }; +export type foo_bar_baz_qux_ = '3.0'; + /** * This is a model with one enum */ @@ -715,6 +727,8 @@ export type ModelWithOneOfEnum = { foo: 'Corge'; }; +export type foo = 'Bar'; + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; @@ -773,6 +787,11 @@ export type ModelWithNumericEnumUnion = { value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; }; +/** + * Период + */ +export type value = -10 | -1 | 0 | 1 | 3 | 6 | 12; + /** * Some description with `back ticks` */ diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap index c3494aaf5..7f0722ad6 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap @@ -278,6 +278,11 @@ export type ModelWithNullableString = { 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; }; +/** + * This is a simple enum with strings + */ +export type foo_bar_enum_ = 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** * This is a model with one enum */ @@ -296,6 +301,11 @@ export type ModelWithEnum = { bool?: boolean; }; +/** + * These are the HTTP error code enums + */ +export type statusCode = '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** * This is a model with one enum with escaped name */ @@ -303,6 +313,8 @@ export type ModelWithEnumWithHyphen = { 'foo-bar-baz-qux'?: '3.0'; }; +export type foo_bar_baz_qux_ = '3.0'; + /** * This is a model with one enum */ @@ -715,6 +727,8 @@ export type ModelWithOneOfEnum = { foo: 'Corge'; }; +export type foo = 'Bar'; + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; @@ -773,6 +787,11 @@ export type ModelWithNumericEnumUnion = { value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; }; +/** + * Период + */ +export type value = -10 | -1 | 0 | 1 | 3 | 6 | 12; + /** * Some description with `back ticks` */ diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/OpenAPI.ts.snap index f9eab42e2..7286660a4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/OpenAPI.ts.snap @@ -1,4 +1,3 @@ - import type { ApiRequestOptions } from './ApiRequestOptions'; type Headers = Record; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/enums.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/enums.gen.ts.snap deleted file mode 100644 index 641bb2c83..000000000 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/enums.gen.ts.snap +++ /dev/null @@ -1,124 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -/** - * This is a simple enum with strings - */ -export const EnumWithStringsEnum = { - SUCCESS: 'Success', - WARNING: 'Warning', - ERROR: 'Error', - _SINGLE_QUOTE_: "'Single Quote'", - _DOUBLE_QUOTES_: '"Double Quotes"', - 'NON_ASCII__ØÆÅÔÖ_ØÆÅÔÖ字符串': 'Non-ascii: øæåôöØÆÅÔÖ字符串' -} as const; - -export const EnumWithReplacedCharactersEnum = { - _SINGLE_QUOTE_: "'Single Quote'", - _DOUBLE_QUOTES_: '"Double Quotes"', - 'ØÆÅÔÖ_ØÆÅÔÖ字符串': 'øæåôöØÆÅÔÖ字符串', - '_3.1': 3.1, - EMPTY_STRING: '' -} as const; - -/** - * This is a simple enum with numbers - */ -export const EnumWithNumbersEnum = { - '_1': 1, - '_2': 2, - '_3': 3, - '_1.1': 1.1, - '_1.2': 1.2, - '_1.3': 1.3, - '_100': 100, - '_200': 200, - '_300': 300, - '_-100': -100, - '_-200': -200, - '_-300': -300, - '_-1.1': -1.1, - '_-1.2': -1.2, - '_-1.3': -1.3 -} as const; - -/** - * This is a simple enum with numbers - */ -export const EnumWithExtensionsEnum = { - /** - * Used when the status of something is successful - */ - CUSTOM_SUCCESS: 200, - /** - * Used when the status of something has a warning - */ - CUSTOM_WARNING: 400, - /** - * Used when the status of something has an error - */ - CUSTOM_ERROR: 500 -} as const; - -export const EnumWithXEnumNamesEnum = { - zero: 0, - one: 1, - two: 2 -} as const; - -/** - * This is a simple enum with strings - */ -export const FooBarEnumEnum = { - SUCCESS: 'Success', - WARNING: 'Warning', - ERROR: 'Error', - 'ØÆÅ字符串': 'ØÆÅ字符串' -} as const; - -/** - * These are the HTTP error code enums - */ -export const StatusCodeEnum = { - _100: '100', - _200_FOO: '200 FOO', - _300_FOO_BAR: '300 FOO_BAR', - _400_FOO_BAR: '400 foo-bar', - _500_FOO_BAR: '500 foo.bar', - _600_FOO_BAR: '600 foo&bar' -} as const; - -export const FooBarBazQuxEnum = { - _3_0: '3.0' -} as const; - -export const Enum1Enum = { - BIRD: 'Bird', - DOG: 'Dog' -} as const; - -export const FooEnum = { - BAR: 'Bar' -} as const; - -export const ModelWithNestedArrayEnumsDataFooEnum = { - FOO: 'foo', - BAR: 'bar' -} as const; - -export const ModelWithNestedArrayEnumsDataBarEnum = { - BAZ: 'baz', - QUX: 'qux' -} as const; - -/** - * Период - */ -export const ValueEnum = { - '_-10': -10, - '_-1': -1, - '_0': 0, - '_1': 1, - '_3': 3, - '_6': 6, - '_12': 12 -} as const; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/index.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/index.ts.snap index c3cdcd1d4..0fd1fa408 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/index.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/index.ts.snap @@ -4,6 +4,5 @@ export { ApiError } from './core/ApiError'; export { BaseHttpRequest } from './core/BaseHttpRequest'; export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; -export * from './enums.gen'; export * from './services.gen'; export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap index b5ee34f31..a0ab02bb4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap @@ -278,6 +278,11 @@ export type ModelWithNullableString = { 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; }; +/** + * This is a simple enum with strings + */ +export type foo_bar_enum_ = 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** * This is a model with one enum */ @@ -296,6 +301,11 @@ export type ModelWithEnum = { bool?: boolean; }; +/** + * These are the HTTP error code enums + */ +export type statusCode = '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** * This is a model with one enum with escaped name */ @@ -303,6 +313,8 @@ export type ModelWithEnumWithHyphen = { 'foo-bar-baz-qux'?: '3.0'; }; +export type foo_bar_baz_qux_ = '3.0'; + /** * This is a model with one enum */ @@ -715,6 +727,8 @@ export type ModelWithOneOfEnum = { foo: 'Corge'; }; +export type foo = 'Bar'; + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; @@ -773,6 +787,11 @@ export type ModelWithNumericEnumUnion = { value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; }; +/** + * Период + */ +export type value = -10 | -1 | 0 | 1 | 3 | 6 | 12; + /** * Some description with `back ticks` */ diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/OpenAPI.ts.snap index f9eab42e2..7286660a4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/OpenAPI.ts.snap @@ -1,4 +1,3 @@ - import type { ApiRequestOptions } from './ApiRequestOptions'; type Headers = Record; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/enums.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/enums.gen.ts.snap deleted file mode 100644 index 1e913b0a7..000000000 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/enums.gen.ts.snap +++ /dev/null @@ -1,124 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -/** - * This is a simple enum with strings - */ -export enum EnumWithStringsEnum { - SUCCESS = 'Success', - WARNING = 'Warning', - ERROR = 'Error', - _SINGLE_QUOTE_ = "'Single Quote'", - _DOUBLE_QUOTES_ = '"Double Quotes"', - NON_ASCII__ØÆÅÔÖ_ØÆÅÔÖ字符串 = 'Non-ascii: øæåôöØÆÅÔÖ字符串' -} - -export enum EnumWithReplacedCharactersEnum { - _SINGLE_QUOTE_ = "'Single Quote'", - _DOUBLE_QUOTES_ = '"Double Quotes"', - ØÆÅÔÖ_ØÆÅÔÖ字符串 = 'øæåôöØÆÅÔÖ字符串', - '_3.1' = 3.1, - EMPTY_STRING = '' -} - -/** - * This is a simple enum with numbers - */ -export enum EnumWithNumbersEnum { - '_1' = 1, - '_2' = 2, - '_3' = 3, - '_1.1' = 1.1, - '_1.2' = 1.2, - '_1.3' = 1.3, - '_100' = 100, - '_200' = 200, - '_300' = 300, - '_-100' = -100, - '_-200' = -200, - '_-300' = -300, - '_-1.1' = -1.1, - '_-1.2' = -1.2, - '_-1.3' = -1.3 -} - -/** - * This is a simple enum with numbers - */ -export enum EnumWithExtensionsEnum { - /** - * Used when the status of something is successful - */ - CUSTOM_SUCCESS = 200, - /** - * Used when the status of something has a warning - */ - CUSTOM_WARNING = 400, - /** - * Used when the status of something has an error - */ - CUSTOM_ERROR = 500 -} - -export enum EnumWithXEnumNamesEnum { - zero = 0, - one = 1, - two = 2 -} - -/** - * This is a simple enum with strings - */ -export enum FooBarEnumEnum { - SUCCESS = 'Success', - WARNING = 'Warning', - ERROR = 'Error', - ØÆÅ字符串 = 'ØÆÅ字符串' -} - -/** - * These are the HTTP error code enums - */ -export enum StatusCodeEnum { - _100 = '100', - _200_FOO = '200 FOO', - _300_FOO_BAR = '300 FOO_BAR', - _400_FOO_BAR = '400 foo-bar', - _500_FOO_BAR = '500 foo.bar', - _600_FOO_BAR = '600 foo&bar' -} - -export enum FooBarBazQuxEnum { - _3_0 = '3.0' -} - -export enum Enum1Enum { - BIRD = 'Bird', - DOG = 'Dog' -} - -export enum FooEnum { - BAR = 'Bar' -} - -export enum ModelWithNestedArrayEnumsDataFooEnum { - FOO = 'foo', - BAR = 'bar' -} - -export enum ModelWithNestedArrayEnumsDataBarEnum { - BAZ = 'baz', - QUX = 'qux' -} - -/** - * Период - */ -export enum ValueEnum { - '_-10' = -10, - '_-1' = -1, - '_0' = 0, - '_1' = 1, - '_3' = 3, - '_6' = 6, - '_12' = 12 -} \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/index.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/index.ts.snap index 48a15033a..3e1f0b35c 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/index.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/index.ts.snap @@ -2,6 +2,5 @@ export { ApiError } from './core/ApiError'; export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; -export * from './enums.gen'; export * from './services.gen'; export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap index c3494aaf5..7f0722ad6 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap @@ -278,6 +278,11 @@ export type ModelWithNullableString = { 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; }; +/** + * This is a simple enum with strings + */ +export type foo_bar_enum_ = 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** * This is a model with one enum */ @@ -296,6 +301,11 @@ export type ModelWithEnum = { bool?: boolean; }; +/** + * These are the HTTP error code enums + */ +export type statusCode = '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** * This is a model with one enum with escaped name */ @@ -303,6 +313,8 @@ export type ModelWithEnumWithHyphen = { 'foo-bar-baz-qux'?: '3.0'; }; +export type foo_bar_baz_qux_ = '3.0'; + /** * This is a model with one enum */ @@ -715,6 +727,8 @@ export type ModelWithOneOfEnum = { foo: 'Corge'; }; +export type foo = 'Bar'; + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; @@ -773,6 +787,11 @@ export type ModelWithNumericEnumUnion = { value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; }; +/** + * Период + */ +export type value = -10 | -1 | 0 | 1 | 3 | 6 | 12; + /** * Some description with `back ticks` */ diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/OpenAPI.ts.snap index f9eab42e2..7286660a4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/OpenAPI.ts.snap @@ -1,4 +1,3 @@ - import type { ApiRequestOptions } from './ApiRequestOptions'; type Headers = Record; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_models/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_models/types.gen.ts.snap index ef5049da7..b991f846e 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_models/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_models/types.gen.ts.snap @@ -278,6 +278,11 @@ export type ModelWithNullableString = { 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; }; +/** + * This is a simple enum with strings + */ +export type foo_bar_enum_ = 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** * This is a model with one enum */ @@ -296,6 +301,11 @@ export type ModelWithEnum = { bool?: boolean; }; +/** + * These are the HTTP error code enums + */ +export type statusCode = '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** * This is a model with one enum with escaped name */ @@ -303,6 +313,8 @@ export type ModelWithEnumWithHyphen = { 'foo-bar-baz-qux'?: '3.0'; }; +export type foo_bar_baz_qux_ = '3.0'; + /** * This is a model with one enum */ @@ -715,6 +727,8 @@ export type ModelWithOneOfEnum = { foo: 'Corge'; }; +export type foo = 'Bar'; + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; @@ -773,6 +787,11 @@ export type ModelWithNumericEnumUnion = { value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; }; +/** + * Период + */ +export type value = -10 | -1 | 0 | 1 | 3 | 6 | 12; + /** * Some description with `back ticks` */ diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/OpenAPI.ts.snap index f9eab42e2..7286660a4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/OpenAPI.ts.snap @@ -1,4 +1,3 @@ - import type { ApiRequestOptions } from './ApiRequestOptions'; type Headers = Record; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/OpenAPI.ts.snap index b6969225e..ec476fed8 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/OpenAPI.ts.snap @@ -1,4 +1,3 @@ - import type { ApiRequestOptions } from './ApiRequestOptions'; type Headers = Record;