diff --git a/.changeset/orange-keys-fry.md b/.changeset/orange-keys-fry.md new file mode 100644 index 000000000..3bf88cdb3 --- /dev/null +++ b/.changeset/orange-keys-fry.md @@ -0,0 +1,5 @@ +--- +"@hey-api/openapi-ts": minor +--- + +Add `index.ts` file to models, schemas, and services diff --git a/rollup.config.ts b/rollup.config.ts index 7f8c5ea2c..dad7e29f9 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -42,9 +42,6 @@ export function handlebarsPlugin(): Plugin { escapeDescription: true, escapeNewline: true, exactArray: true, - exportsModels: true, - exportsSchemas: true, - exportsServices: true, ifdef: true, ifOperationDataOptional: true, intersection: true, diff --git a/src/templates/index.hbs b/src/templates/index.hbs index ed27dc875..23a9d9797 100644 --- a/src/templates/index.hbs +++ b/src/templates/index.hbs @@ -12,8 +12,12 @@ export { OpenAPI } from './core/OpenAPI'; export type { OpenAPIConfig } from './core/OpenAPI'; {{/if}} -{{{exportsModels}}} - -{{{exportsSchemas}}} - -{{{exportsServices}}} +{{#if @root.$config.exportModels}} +export * from './models' +{{/if}} +{{#if @root.$config.exportSchemas}} +export * from './schemas' +{{/if}} +{{#if @root.$config.exportServices}} +export * from './services' +{{/if}} diff --git a/src/utils/handlebars.ts b/src/utils/handlebars.ts index 575b984e1..9fb880d24 100644 --- a/src/utils/handlebars.ts +++ b/src/utils/handlebars.ts @@ -99,53 +99,6 @@ const escapeComment = (value: string) => .replace(/\/\*/g, '*') .replace(/\r?\n(.*)/g, (_, w) => `${EOL} * ${w.trim()}`); -const exportsModels = (config: Config, client: Client) => { - if (!config.exportModels) { - return ''; - } - const path = './models/'; - const output = client.models.map(model => { - const importedModel = config.postfixModels - ? `${model.name} as ${model.name + config.postfixModels}` - : 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}';`]; - } - return result.join('\n'); - }); - return output.join('\n'); -}; - -const exportsSchemas = (config: Config, client: Client) => { - if (!config.exportSchemas) { - return ''; - } - const path = './schemas/'; - const output = client.models.map(model => { - const name = `$${model.name}`; - const result = [`export { ${name} } from '${path + name}';`]; - return result.join('\n'); - }); - return output.join('\n'); -}; - -const exportsServices = (config: Config, client: Client) => { - if (!config.exportServices) { - return ''; - } - const path = './services/'; - const output = client.services.map(service => { - const name = service.name + config.postfixServices; - const result = [`export { ${name} } from '${path + name}';`]; - return result.join('\n'); - }); - return output.join('\n'); -}; - const modelImports = (model: Model | Service, path: string) => { const output = model.imports.map(item => `import type { ${item} } from '${path + item}';`); return output.join('\n'); @@ -237,18 +190,6 @@ export const registerHandlebarHelpers = (config: Config, client: Client): void = return options.inverse(this); }); - Handlebars.registerHelper('exportsModels', function () { - return exportsModels(config, client); - }); - - Handlebars.registerHelper('exportsSchemas', function () { - return exportsSchemas(config, client); - }); - - Handlebars.registerHelper('exportsServices', function () { - return exportsServices(config, client); - }); - Handlebars.registerHelper('ifdef', function (this: unknown, ...args): string { const options = args.pop(); if (!args.every(value => !value)) { diff --git a/src/utils/write/__tests__/class.spec.ts b/src/utils/write/__tests__/class.spec.ts index fa5934758..2c05835f5 100644 --- a/src/utils/write/__tests__/class.spec.ts +++ b/src/utils/write/__tests__/class.spec.ts @@ -3,6 +3,7 @@ import { writeFileSync } from 'node:fs'; import { describe, expect, it, vi } from 'vitest'; import { writeClientClass } from '../class'; +import { mockTemplates } from './mocks'; vi.mock('node:fs'); @@ -15,28 +16,7 @@ describe('writeClientClass', () => { services: [], }; - const templates: Parameters[1] = { - client: () => 'client', - core: { - apiError: () => 'apiError', - apiRequestOptions: () => 'apiRequestOptions', - apiResult: () => 'apiResult', - baseHttpRequest: () => 'baseHttpRequest', - cancelablePromise: () => 'cancelablePromise', - httpRequest: () => 'httpRequest', - request: () => 'request', - settings: () => 'settings', - types: () => 'types', - }, - exports: { - model: () => 'model', - schema: () => 'schema', - service: () => 'service', - }, - index: () => 'index', - }; - - await writeClientClass(client, templates, './dist', { + await writeClientClass(client, mockTemplates, './dist', { client: 'fetch', enums: true, exportCore: true, diff --git a/src/utils/write/__tests__/client.spec.ts b/src/utils/write/__tests__/client.spec.ts index 96b2dd99e..7ae2664b2 100644 --- a/src/utils/write/__tests__/client.spec.ts +++ b/src/utils/write/__tests__/client.spec.ts @@ -3,6 +3,7 @@ import { mkdirSync, rmSync, writeFileSync } from 'node:fs'; import { describe, expect, it, vi } from 'vitest'; import { writeClient } from '../client'; +import { mockTemplates } from './mocks'; vi.mock('node:fs'); @@ -15,28 +16,7 @@ describe('writeClient', () => { services: [], }; - const templates: Parameters[1] = { - client: () => 'client', - core: { - apiError: () => 'apiError', - apiRequestOptions: () => 'apiRequestOptions', - apiResult: () => 'apiResult', - baseHttpRequest: () => 'baseHttpRequest', - cancelablePromise: () => 'cancelablePromise', - httpRequest: () => 'httpRequest', - request: () => 'request', - settings: () => 'settings', - types: () => 'types', - }, - exports: { - model: () => 'model', - schema: () => 'schema', - service: () => 'service', - }, - index: () => 'index', - }; - - await writeClient(client, templates, { + await writeClient(client, mockTemplates, { client: 'fetch', enums: true, exportCore: true, diff --git a/src/utils/write/__tests__/core.spec.ts b/src/utils/write/__tests__/core.spec.ts index cd250b8f9..3758ccd9c 100644 --- a/src/utils/write/__tests__/core.spec.ts +++ b/src/utils/write/__tests__/core.spec.ts @@ -4,33 +4,14 @@ import path from 'node:path'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { writeClientCore } from '../core'; +import { mockTemplates } from './mocks'; vi.mock('node:fs'); describe('writeClientCore', () => { let templates: Parameters[1]; beforeEach(() => { - const _templates: Parameters[1] = { - client: () => 'client', - core: { - apiError: () => 'apiError', - apiRequestOptions: () => 'apiRequestOptions', - apiResult: () => 'apiResult', - baseHttpRequest: () => 'baseHttpRequest', - cancelablePromise: () => 'cancelablePromise', - httpRequest: () => 'httpRequest', - request: () => 'request', - settings: vi.fn().mockReturnValue('settings'), - types: () => 'types', - }, - exports: { - model: () => 'model', - schema: () => 'schema', - service: () => 'service', - }, - index: () => 'index', - }; - templates = _templates; + templates = mockTemplates; }); it('should write to filesystem', async () => { diff --git a/src/utils/write/__tests__/index.spec.ts b/src/utils/write/__tests__/index.spec.ts index cf3eb94f3..68d24d4d4 100644 --- a/src/utils/write/__tests__/index.spec.ts +++ b/src/utils/write/__tests__/index.spec.ts @@ -4,6 +4,7 @@ import path from 'node:path'; import { describe, expect, it, vi } from 'vitest'; import { writeClientIndex } from '../index'; +import { mockTemplates } from './mocks'; vi.mock('node:fs'); @@ -16,28 +17,7 @@ describe('writeClientIndex', () => { services: [], }; - const templates: Parameters[1] = { - client: () => 'client', - core: { - apiError: () => 'apiError', - apiRequestOptions: () => 'apiRequestOptions', - apiResult: () => 'apiResult', - baseHttpRequest: () => 'baseHttpRequest', - cancelablePromise: () => 'cancelablePromise', - httpRequest: () => 'httpRequest', - request: () => 'request', - settings: () => 'settings', - types: () => 'types', - }, - exports: { - model: () => 'model', - schema: () => 'schema', - service: () => 'service', - }, - index: () => 'index', - }; - - await writeClientIndex(client, templates, '/', { + await writeClientIndex(client, mockTemplates, '/', { client: 'fetch', enums: true, exportCore: true, diff --git a/src/utils/write/__tests__/mocks.ts b/src/utils/write/__tests__/mocks.ts new file mode 100644 index 000000000..f99f44aa2 --- /dev/null +++ b/src/utils/write/__tests__/mocks.ts @@ -0,0 +1,24 @@ +import { vi } from 'vitest'; + +import type { Templates } from '../../handlebars'; + +export const mockTemplates: Templates = { + client: vi.fn().mockReturnValue('client'), + core: { + apiError: vi.fn().mockReturnValue('apiError'), + apiRequestOptions: vi.fn().mockReturnValue('apiRequestOptions'), + apiResult: vi.fn().mockReturnValue('apiResult'), + baseHttpRequest: vi.fn().mockReturnValue('baseHttpRequest'), + cancelablePromise: vi.fn().mockReturnValue('cancelablePromise'), + httpRequest: vi.fn().mockReturnValue('httpRequest'), + request: vi.fn().mockReturnValue('request'), + settings: vi.fn().mockReturnValue('settings'), + types: vi.fn().mockReturnValue('types'), + }, + exports: { + model: vi.fn().mockReturnValue('model'), + schema: vi.fn().mockReturnValue('schema'), + service: vi.fn().mockReturnValue('service'), + }, + index: vi.fn().mockReturnValue('index'), +}; diff --git a/src/utils/write/__tests__/models.spec.ts b/src/utils/write/__tests__/models.spec.ts index 512092943..79e01c5ff 100644 --- a/src/utils/write/__tests__/models.spec.ts +++ b/src/utils/write/__tests__/models.spec.ts @@ -4,6 +4,7 @@ import path from 'node:path'; import { describe, expect, it, vi } from 'vitest'; import { writeClientModels } from '../models'; +import { mockTemplates } from './mocks'; vi.mock('node:fs'); @@ -35,28 +36,7 @@ describe('writeClientModels', () => { services: [], }; - const templates: Parameters[1] = { - client: () => 'client', - core: { - apiError: () => 'apiError', - apiRequestOptions: () => 'apiRequestOptions', - apiResult: () => 'apiResult', - baseHttpRequest: () => 'baseHttpRequest', - cancelablePromise: () => 'cancelablePromise', - httpRequest: () => 'httpRequest', - request: () => 'request', - settings: () => 'settings', - types: () => 'types', - }, - exports: { - model: () => 'model', - schema: () => 'schema', - service: () => 'service', - }, - index: () => 'index', - }; - - await writeClientModels(client, templates, '/', { + await writeClientModels(client, mockTemplates, '/', { client: 'fetch', enums: true, exportCore: true, diff --git a/src/utils/write/__tests__/schemas.spec.ts b/src/utils/write/__tests__/schemas.spec.ts index 240209b04..f4deb9d0e 100644 --- a/src/utils/write/__tests__/schemas.spec.ts +++ b/src/utils/write/__tests__/schemas.spec.ts @@ -4,6 +4,7 @@ import path from 'node:path'; import { describe, expect, it, vi } from 'vitest'; import { writeClientSchemas } from '../schemas'; +import { mockTemplates } from './mocks'; vi.mock('node:fs'); @@ -35,28 +36,7 @@ describe('writeClientSchemas', () => { services: [], }; - const templates: Parameters[1] = { - client: () => 'client', - core: { - apiError: () => 'apiError', - apiRequestOptions: () => 'apiRequestOptions', - apiResult: () => 'apiResult', - baseHttpRequest: () => 'baseHttpRequest', - cancelablePromise: () => 'cancelablePromise', - httpRequest: () => 'httpRequest', - request: () => 'request', - settings: () => 'settings', - types: () => 'types', - }, - exports: { - model: () => 'model', - schema: () => 'schema', - service: () => 'service', - }, - index: () => 'index', - }; - - await writeClientSchemas(client, templates, '/', { + await writeClientSchemas(client, mockTemplates, '/', { client: 'fetch', enums: true, exportCore: true, diff --git a/src/utils/write/__tests__/services.spec.ts b/src/utils/write/__tests__/services.spec.ts index c921291b9..cc3aae1a0 100644 --- a/src/utils/write/__tests__/services.spec.ts +++ b/src/utils/write/__tests__/services.spec.ts @@ -4,6 +4,7 @@ import path from 'node:path'; import { describe, expect, it, vi } from 'vitest'; import { writeClientServices } from '../services'; +import { mockTemplates } from './mocks'; vi.mock('node:fs'); @@ -23,28 +24,7 @@ describe('writeClientServices', () => { ], }; - const templates: Parameters[1] = { - client: () => 'client', - core: { - apiError: () => 'apiError', - apiRequestOptions: () => 'apiRequestOptions', - apiResult: () => 'apiResult', - baseHttpRequest: () => 'baseHttpRequest', - cancelablePromise: () => 'cancelablePromise', - httpRequest: () => 'httpRequest', - request: () => 'request', - settings: () => 'settings', - types: () => 'types', - }, - exports: { - model: () => 'model', - schema: () => 'schema', - service: () => 'service', - }, - index: () => 'index', - }; - - await writeClientServices(client, templates, '/', { + await writeClientServices(client, mockTemplates, '/', { client: 'fetch', enums: false, exportCore: true, diff --git a/src/utils/write/models.ts b/src/utils/write/models.ts index d94dfcf1c..a64ad4935 100644 --- a/src/utils/write/models.ts +++ b/src/utils/write/models.ts @@ -3,6 +3,7 @@ import path from 'node:path'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; +import { enumName } from '../enum'; import type { Templates } from '../handlebars'; /** @@ -18,6 +19,7 @@ export const writeClientModels = async ( outputPath: string, config: Config ): Promise => { + // Generate a file for each model. for (const model of client.models) { const file = path.resolve(outputPath, `${model.name}.ts`); const templateResult = templates.exports.model({ @@ -26,4 +28,26 @@ export const writeClientModels = async ( }); await writeFileSync(file, templateResult); } + // Generate an index.ts file exporting all models from each file generated above. + const file = path.resolve(outputPath, 'index.ts'); + const content = exportsModels(config, client); + await writeFileSync(file, content); +}; + +const exportsModels = (config: Config, client: Client) => { + const path = './'; + const output = client.models.map(model => { + const importedModel = config.postfixModels + ? `${model.name} as ${model.name + config.postfixModels}` + : 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}';`]; + } + return result.join('\n'); + }); + return output.join('\n'); }; diff --git a/src/utils/write/schemas.ts b/src/utils/write/schemas.ts index 080dc9936..55a0944a8 100644 --- a/src/utils/write/schemas.ts +++ b/src/utils/write/schemas.ts @@ -4,6 +4,7 @@ import path from 'node:path'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import type { Templates } from '../handlebars'; +import { sortByName } from '../sort'; /** * Generate Schemas using the Handlebar template and write to disk. @@ -18,6 +19,7 @@ export const writeClientSchemas = async ( outputPath: string, config: Config ): Promise => { + // Generate file for each models schema. for (const model of client.models) { const file = path.resolve(outputPath, `$${model.name}.ts`); const templateResult = templates.exports.schema({ @@ -26,4 +28,8 @@ export const writeClientSchemas = async ( }); await writeFileSync(file, templateResult); } + // Generate index file exporting all generated schema files. + const file = path.resolve(outputPath, 'index.ts'); + const content = sortByName(client.models).map(model => `export { $${model.name} } from './$${model.name}';`); + await writeFileSync(file, content.join('\n')); }; diff --git a/src/utils/write/services.ts b/src/utils/write/services.ts index 4fbc62e74..54f4836e8 100644 --- a/src/utils/write/services.ts +++ b/src/utils/write/services.ts @@ -4,6 +4,7 @@ import path from 'node:path'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import type { Templates } from '../handlebars'; +import { sortByName } from '../sort'; /** * Generate Services using the Handlebar template and write to disk. @@ -18,6 +19,7 @@ export const writeClientServices = async ( outputPath: string, config: Config ): Promise => { + // Generate file for each service. for (const service of client.services) { const file = path.resolve(outputPath, `${service.name}${config.postfixServices}.ts`); const templateResult = templates.exports.service({ @@ -26,4 +28,11 @@ export const writeClientServices = async ( }); await writeFileSync(file, templateResult); } + // Generate index file exporting all generated service files. + const file = path.resolve(outputPath, 'index.ts'); + const content = sortByName(client.services).map( + service => + `export { ${service.name}${config.postfixServices} } from './${service.name}${config.postfixServices}'` + ); + await writeFileSync(file, content.join('\n')); }; diff --git a/test/__snapshots__/v2/test/generated/v2/index.ts.snap b/test/__snapshots__/v2/test/generated/v2/index.ts.snap index b205a7e46..2c5a14f44 100644 --- a/test/__snapshots__/v2/test/generated/v2/index.ts.snap +++ b/test/__snapshots__/v2/test/generated/v2/index.ts.snap @@ -3,124 +3,6 @@ export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI } from './core/OpenAPI'; export type { OpenAPIConfig } from './core/OpenAPI'; -export type { _default } from './models/_default'; -export type { ArrayWithArray } from './models/ArrayWithArray'; -export type { ArrayWithBooleans } from './models/ArrayWithBooleans'; -export type { ArrayWithNumbers } from './models/ArrayWithNumbers'; -export type { ArrayWithProperties } from './models/ArrayWithProperties'; -export type { ArrayWithReferences } from './models/ArrayWithReferences'; -export type { ArrayWithStrings } from './models/ArrayWithStrings'; -export type { CommentWithBackticks } from './models/CommentWithBackticks'; -export type { CommentWithBreaks } from './models/CommentWithBreaks'; -export type { CommentWithExpressionPlaceholders } from './models/CommentWithExpressionPlaceholders'; -export type { CommentWithQuotes } from './models/CommentWithQuotes'; -export type { CommentWithReservedCharacters } from './models/CommentWithReservedCharacters'; -export type { CommentWithSlashes } from './models/CommentWithSlashes'; -export type { Date } from './models/Date'; -export type { DictionaryWithArray } from './models/DictionaryWithArray'; -export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; -export type { DictionaryWithProperties } from './models/DictionaryWithProperties'; -export type { DictionaryWithReference } from './models/DictionaryWithReference'; -export type { DictionaryWithString } from './models/DictionaryWithString'; -export type { EnumFromDescription } from './models/EnumFromDescription'; -export type { EnumWithExtensions } from './models/EnumWithExtensions'; -export { EnumWithExtensionsEnum } from './models/EnumWithExtensions'; -export type { EnumWithNumbers } from './models/EnumWithNumbers'; -export { EnumWithNumbersEnum } from './models/EnumWithNumbers'; -export type { EnumWithStrings } from './models/EnumWithStrings'; -export { EnumWithStringsEnum } from './models/EnumWithStrings'; -export type { ModelThatExtends } from './models/ModelThatExtends'; -export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; -export type { ModelWithArray } from './models/ModelWithArray'; -export type { ModelWithBoolean } from './models/ModelWithBoolean'; -export type { ModelWithCircularReference } from './models/ModelWithCircularReference'; -export type { ModelWithDictionary } from './models/ModelWithDictionary'; -export type { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; -export type { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; -export type { ModelWithEnum } from './models/ModelWithEnum'; -export { TestEnum, StatusCodeEnum } from './models/ModelWithEnum'; -export type { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; -export type { ModelWithInteger } from './models/ModelWithInteger'; -export type { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; -export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; -export type { ModelWithNullableString } from './models/ModelWithNullableString'; -export type { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties'; -export type { ModelWithPattern } from './models/ModelWithPattern'; -export type { ModelWithProperties } from './models/ModelWithProperties'; -export type { ModelWithReference } from './models/ModelWithReference'; -export type { ModelWithString } from './models/ModelWithString'; -export type { NonAsciiStringæøåÆØÅöôêÊ字符串 } from './models/NonAsciiStringæøåÆØÅöôêÊ字符串'; -export type { SimpleBoolean } from './models/SimpleBoolean'; -export type { SimpleFile } from './models/SimpleFile'; -export type { SimpleInteger } from './models/SimpleInteger'; -export type { SimpleReference } from './models/SimpleReference'; -export type { SimpleString } from './models/SimpleString'; -export type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; - -export { $_default } from './schemas/$_default'; -export { $ArrayWithArray } from './schemas/$ArrayWithArray'; -export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans'; -export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers'; -export { $ArrayWithProperties } from './schemas/$ArrayWithProperties'; -export { $ArrayWithReferences } from './schemas/$ArrayWithReferences'; -export { $ArrayWithStrings } from './schemas/$ArrayWithStrings'; -export { $CommentWithBackticks } from './schemas/$CommentWithBackticks'; -export { $CommentWithBreaks } from './schemas/$CommentWithBreaks'; -export { $CommentWithExpressionPlaceholders } from './schemas/$CommentWithExpressionPlaceholders'; -export { $CommentWithQuotes } from './schemas/$CommentWithQuotes'; -export { $CommentWithReservedCharacters } from './schemas/$CommentWithReservedCharacters'; -export { $CommentWithSlashes } from './schemas/$CommentWithSlashes'; -export { $Date } from './schemas/$Date'; -export { $DictionaryWithArray } from './schemas/$DictionaryWithArray'; -export { $DictionaryWithDictionary } from './schemas/$DictionaryWithDictionary'; -export { $DictionaryWithProperties } from './schemas/$DictionaryWithProperties'; -export { $DictionaryWithReference } from './schemas/$DictionaryWithReference'; -export { $DictionaryWithString } from './schemas/$DictionaryWithString'; -export { $EnumFromDescription } from './schemas/$EnumFromDescription'; -export { $EnumWithExtensions } from './schemas/$EnumWithExtensions'; -export { $EnumWithNumbers } from './schemas/$EnumWithNumbers'; -export { $EnumWithStrings } from './schemas/$EnumWithStrings'; -export { $ModelThatExtends } from './schemas/$ModelThatExtends'; -export { $ModelThatExtendsExtends } from './schemas/$ModelThatExtendsExtends'; -export { $ModelWithArray } from './schemas/$ModelWithArray'; -export { $ModelWithBoolean } from './schemas/$ModelWithBoolean'; -export { $ModelWithCircularReference } from './schemas/$ModelWithCircularReference'; -export { $ModelWithDictionary } from './schemas/$ModelWithDictionary'; -export { $ModelWithDuplicateImports } from './schemas/$ModelWithDuplicateImports'; -export { $ModelWithDuplicateProperties } from './schemas/$ModelWithDuplicateProperties'; -export { $ModelWithEnum } from './schemas/$ModelWithEnum'; -export { $ModelWithEnumFromDescription } from './schemas/$ModelWithEnumFromDescription'; -export { $ModelWithInteger } from './schemas/$ModelWithInteger'; -export { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; -export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; -export { $ModelWithNullableString } from './schemas/$ModelWithNullableString'; -export { $ModelWithOrderedProperties } from './schemas/$ModelWithOrderedProperties'; -export { $ModelWithPattern } from './schemas/$ModelWithPattern'; -export { $ModelWithProperties } from './schemas/$ModelWithProperties'; -export { $ModelWithReference } from './schemas/$ModelWithReference'; -export { $ModelWithString } from './schemas/$ModelWithString'; -export { $NonAsciiStringæøåÆØÅöôêÊ字符串 } from './schemas/$NonAsciiStringæøåÆØÅöôêÊ字符串'; -export { $SimpleBoolean } from './schemas/$SimpleBoolean'; -export { $SimpleFile } from './schemas/$SimpleFile'; -export { $SimpleInteger } from './schemas/$SimpleInteger'; -export { $SimpleReference } from './schemas/$SimpleReference'; -export { $SimpleString } from './schemas/$SimpleString'; -export { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern'; - -export { CollectionFormatService } from './services/CollectionFormatService'; -export { ComplexService } from './services/ComplexService'; -export { DefaultService } from './services/DefaultService'; -export { DefaultsService } from './services/DefaultsService'; -export { DescriptionsService } from './services/DescriptionsService'; -export { DuplicateService } from './services/DuplicateService'; -export { ErrorService } from './services/ErrorService'; -export { HeaderService } from './services/HeaderService'; -export { MultipleTags1Service } from './services/MultipleTags1Service'; -export { MultipleTags2Service } from './services/MultipleTags2Service'; -export { MultipleTags3Service } from './services/MultipleTags3Service'; -export { NoContentService } from './services/NoContentService'; -export { NonAsciiÆøåÆøÅöôêÊService } from './services/NonAsciiÆøåÆøÅöôêÊService'; -export { ParametersService } from './services/ParametersService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; +export * from './models'; +export * from './schemas'; +export * from './services'; diff --git a/test/__snapshots__/v2/test/generated/v2/models/index.ts.snap b/test/__snapshots__/v2/test/generated/v2/models/index.ts.snap new file mode 100644 index 000000000..6077f0f60 --- /dev/null +++ b/test/__snapshots__/v2/test/generated/v2/models/index.ts.snap @@ -0,0 +1,53 @@ +export type { _default } from './_default'; +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 { Date } from './Date'; +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 type { EnumFromDescription } from './EnumFromDescription'; +export type { EnumWithExtensions } from './EnumWithExtensions'; +export { EnumWithExtensionsEnum } from './EnumWithExtensions'; +export type { EnumWithNumbers } from './EnumWithNumbers'; +export { EnumWithNumbersEnum } from './EnumWithNumbers'; +export type { EnumWithStrings } from './EnumWithStrings'; +export { EnumWithStringsEnum } from './EnumWithStrings'; +export type { ModelThatExtends } from './ModelThatExtends'; +export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends'; +export type { ModelWithArray } from './ModelWithArray'; +export type { ModelWithBoolean } from './ModelWithBoolean'; +export type { ModelWithCircularReference } from './ModelWithCircularReference'; +export type { ModelWithDictionary } from './ModelWithDictionary'; +export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports'; +export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties'; +export type { ModelWithEnum } from './ModelWithEnum'; +export { TestEnum, StatusCodeEnum } from './ModelWithEnum'; +export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; +export type { ModelWithInteger } from './ModelWithInteger'; +export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; +export type { ModelWithNestedProperties } from './ModelWithNestedProperties'; +export type { ModelWithNullableString } from './ModelWithNullableString'; +export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties'; +export type { ModelWithPattern } from './ModelWithPattern'; +export type { ModelWithProperties } from './ModelWithProperties'; +export type { ModelWithReference } from './ModelWithReference'; +export type { ModelWithString } from './ModelWithString'; +export type { NonAsciiStringæøåÆØÅöôêÊ字符串 } from './NonAsciiStringæøåÆØÅöôêÊ字符串'; +export type { SimpleBoolean } from './SimpleBoolean'; +export type { SimpleFile } from './SimpleFile'; +export type { SimpleInteger } from './SimpleInteger'; +export type { SimpleReference } from './SimpleReference'; +export type { SimpleString } from './SimpleString'; +export type { SimpleStringWithPattern } from './SimpleStringWithPattern'; diff --git a/test/__snapshots__/v2/test/generated/v2/schemas/index.ts.snap b/test/__snapshots__/v2/test/generated/v2/schemas/index.ts.snap new file mode 100644 index 000000000..7d23ee465 --- /dev/null +++ b/test/__snapshots__/v2/test/generated/v2/schemas/index.ts.snap @@ -0,0 +1,49 @@ +export { $_default } from './$_default'; +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 { $Date } from './$Date'; +export { $DictionaryWithArray } from './$DictionaryWithArray'; +export { $DictionaryWithDictionary } from './$DictionaryWithDictionary'; +export { $DictionaryWithProperties } from './$DictionaryWithProperties'; +export { $DictionaryWithReference } from './$DictionaryWithReference'; +export { $DictionaryWithString } from './$DictionaryWithString'; +export { $EnumFromDescription } from './$EnumFromDescription'; +export { $EnumWithExtensions } from './$EnumWithExtensions'; +export { $EnumWithNumbers } from './$EnumWithNumbers'; +export { $EnumWithStrings } from './$EnumWithStrings'; +export { $ModelThatExtends } from './$ModelThatExtends'; +export { $ModelThatExtendsExtends } from './$ModelThatExtendsExtends'; +export { $ModelWithArray } from './$ModelWithArray'; +export { $ModelWithBoolean } from './$ModelWithBoolean'; +export { $ModelWithCircularReference } from './$ModelWithCircularReference'; +export { $ModelWithDictionary } from './$ModelWithDictionary'; +export { $ModelWithDuplicateImports } from './$ModelWithDuplicateImports'; +export { $ModelWithDuplicateProperties } from './$ModelWithDuplicateProperties'; +export { $ModelWithEnum } from './$ModelWithEnum'; +export { $ModelWithEnumFromDescription } from './$ModelWithEnumFromDescription'; +export { $ModelWithInteger } from './$ModelWithInteger'; +export { $ModelWithNestedEnums } from './$ModelWithNestedEnums'; +export { $ModelWithNestedProperties } from './$ModelWithNestedProperties'; +export { $ModelWithNullableString } from './$ModelWithNullableString'; +export { $ModelWithOrderedProperties } from './$ModelWithOrderedProperties'; +export { $ModelWithPattern } from './$ModelWithPattern'; +export { $ModelWithProperties } from './$ModelWithProperties'; +export { $ModelWithReference } from './$ModelWithReference'; +export { $ModelWithString } from './$ModelWithString'; +export { $NonAsciiStringæøåÆØÅöôêÊ字符串 } from './$NonAsciiStringæøåÆØÅöôêÊ字符串'; +export { $SimpleBoolean } from './$SimpleBoolean'; +export { $SimpleFile } from './$SimpleFile'; +export { $SimpleInteger } from './$SimpleInteger'; +export { $SimpleReference } from './$SimpleReference'; +export { $SimpleString } from './$SimpleString'; +export { $SimpleStringWithPattern } from './$SimpleStringWithPattern'; diff --git a/test/__snapshots__/v2/test/generated/v2/services/index.ts.snap b/test/__snapshots__/v2/test/generated/v2/services/index.ts.snap new file mode 100644 index 000000000..f55f810d9 --- /dev/null +++ b/test/__snapshots__/v2/test/generated/v2/services/index.ts.snap @@ -0,0 +1,17 @@ +export { CollectionFormatService } from './CollectionFormatService'; +export { ComplexService } from './ComplexService'; +export { DefaultService } from './DefaultService'; +export { DefaultsService } from './DefaultsService'; +export { DescriptionsService } from './DescriptionsService'; +export { DuplicateService } from './DuplicateService'; +export { ErrorService } from './ErrorService'; +export { HeaderService } from './HeaderService'; +export { MultipleTags1Service } from './MultipleTags1Service'; +export { MultipleTags2Service } from './MultipleTags2Service'; +export { MultipleTags3Service } from './MultipleTags3Service'; +export { NoContentService } from './NoContentService'; +export { NonAsciiÆøåÆøÅöôêÊService } from './NonAsciiÆøåÆøÅöôêÊService'; +export { ParametersService } from './ParametersService'; +export { ResponseService } from './ResponseService'; +export { SimpleService } from './SimpleService'; +export { TypesService } from './TypesService'; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/ApiClient.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/ApiClient.ts.snap new file mode 100644 index 000000000..6987a9af1 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/ApiClient.ts.snap @@ -0,0 +1,95 @@ +import type { BaseHttpRequest } from './core/BaseHttpRequest'; +import type { OpenAPIConfig } from './core/OpenAPI'; +import { FetchHttpRequest } from './core/FetchHttpRequest'; + +import { CollectionFormatService } from './services/CollectionFormatService'; +import { ComplexService } from './services/ComplexService'; +import { DefaultService } from './services/DefaultService'; +import { DefaultsService } from './services/DefaultsService'; +import { DeprecatedService } from './services/DeprecatedService'; +import { DescriptionsService } from './services/DescriptionsService'; +import { DuplicateService } from './services/DuplicateService'; +import { ErrorService } from './services/ErrorService'; +import { FileResponseService } from './services/FileResponseService'; +import { FormDataService } from './services/FormDataService'; +import { HeaderService } from './services/HeaderService'; +import { MultipartService } from './services/MultipartService'; +import { MultipleTags1Service } from './services/MultipleTags1Service'; +import { MultipleTags2Service } from './services/MultipleTags2Service'; +import { MultipleTags3Service } from './services/MultipleTags3Service'; +import { NoContentService } from './services/NoContentService'; +import { NonAsciiÆøåÆøÅöôêÊService } from './services/NonAsciiÆøåÆøÅöôêÊService'; +import { ParametersService } from './services/ParametersService'; +import { RequestBodyService } from './services/RequestBodyService'; +import { ResponseService } from './services/ResponseService'; +import { SimpleService } from './services/SimpleService'; +import { TypesService } from './services/TypesService'; +import { UploadService } from './services/UploadService'; + +type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest; + +export class ApiClient { + public readonly collectionFormat: CollectionFormatService; + public readonly complex: ComplexService; + public readonly default: DefaultService; + public readonly defaults: DefaultsService; + public readonly deprecated: DeprecatedService; + public readonly descriptions: DescriptionsService; + public readonly duplicate: DuplicateService; + public readonly error: ErrorService; + public readonly fileResponse: FileResponseService; + public readonly formData: FormDataService; + public readonly header: HeaderService; + public readonly multipart: MultipartService; + public readonly multipleTags1: MultipleTags1Service; + public readonly multipleTags2: MultipleTags2Service; + public readonly multipleTags3: MultipleTags3Service; + public readonly noContent: NoContentService; + public readonly nonAsciiÆøåÆøÅöôêÊ: NonAsciiÆøåÆøÅöôêÊService; + public readonly parameters: ParametersService; + public readonly requestBody: RequestBodyService; + public readonly response: ResponseService; + public readonly simple: SimpleService; + public readonly types: TypesService; + public readonly upload: UploadService; + + public readonly request: BaseHttpRequest; + + constructor(config?: Partial, HttpRequest: HttpRequestConstructor = FetchHttpRequest) { + this.request = new HttpRequest({ + BASE: config?.BASE ?? 'http://localhost:3000/base', + VERSION: config?.VERSION ?? '1.0', + WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false, + CREDENTIALS: config?.CREDENTIALS ?? 'include', + TOKEN: config?.TOKEN, + USERNAME: config?.USERNAME, + PASSWORD: config?.PASSWORD, + HEADERS: config?.HEADERS, + ENCODE_PATH: config?.ENCODE_PATH, + }); + + this.collectionFormat = new CollectionFormatService(this.request); + this.complex = new ComplexService(this.request); + this.default = new DefaultService(this.request); + this.defaults = new DefaultsService(this.request); + this.deprecated = new DeprecatedService(this.request); + this.descriptions = new DescriptionsService(this.request); + this.duplicate = new DuplicateService(this.request); + this.error = new ErrorService(this.request); + this.fileResponse = new FileResponseService(this.request); + this.formData = new FormDataService(this.request); + this.header = new HeaderService(this.request); + this.multipart = new MultipartService(this.request); + this.multipleTags1 = new MultipleTags1Service(this.request); + this.multipleTags2 = new MultipleTags2Service(this.request); + this.multipleTags3 = new MultipleTags3Service(this.request); + this.noContent = new NoContentService(this.request); + this.nonAsciiÆøåÆøÅöôêÊ = new NonAsciiÆøåÆøÅöôêÊService(this.request); + this.parameters = new ParametersService(this.request); + this.requestBody = new RequestBodyService(this.request); + this.response = new ResponseService(this.request); + this.simple = new SimpleService(this.request); + this.types = new TypesService(this.request); + this.upload = new UploadService(this.request); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/core/ApiError.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/core/ApiError.ts.snap new file mode 100644 index 000000000..2c11b4136 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/core/ApiError.ts.snap @@ -0,0 +1,21 @@ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; + +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: unknown; + public readonly request: ApiRequestOptions; + + constructor(request: ApiRequestOptions, response: ApiResult, message: string) { + super(message); + + this.name = 'ApiError'; + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + this.request = request; + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/core/ApiRequestOptions.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/core/ApiRequestOptions.ts.snap new file mode 100644 index 000000000..e93003ee7 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/core/ApiRequestOptions.ts.snap @@ -0,0 +1,13 @@ +export type ApiRequestOptions = { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly url: string; + readonly path?: Record; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/core/ApiResult.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/core/ApiResult.ts.snap new file mode 100644 index 000000000..caa79c2ea --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/core/ApiResult.ts.snap @@ -0,0 +1,7 @@ +export type ApiResult = { + readonly body: TData; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly url: string; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/core/BaseHttpRequest.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/core/BaseHttpRequest.ts.snap new file mode 100644 index 000000000..934de716a --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/core/BaseHttpRequest.ts.snap @@ -0,0 +1,9 @@ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { CancelablePromise } from './CancelablePromise'; +import type { OpenAPIConfig } from './OpenAPI'; + +export abstract class BaseHttpRequest { + constructor(public readonly config: OpenAPIConfig) {} + + public abstract request(options: ApiRequestOptions): CancelablePromise; +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/core/CancelablePromise.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/core/CancelablePromise.ts.snap new file mode 100644 index 000000000..0e480dd1d --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/core/CancelablePromise.ts.snap @@ -0,0 +1,126 @@ +export class CancelError extends Error { + constructor(message: string) { + super(message); + this.name = 'CancelError'; + } + + public get isCancelled(): boolean { + return true; + } +} + +export interface OnCancel { + readonly isResolved: boolean; + readonly isRejected: boolean; + readonly isCancelled: boolean; + + (cancelHandler: () => void): void; +} + +export class CancelablePromise implements Promise { + #isResolved: boolean; + #isRejected: boolean; + #isCancelled: boolean; + readonly #cancelHandlers: (() => void)[]; + readonly #promise: Promise; + #resolve?: (value: T | PromiseLike) => void; + #reject?: (reason?: unknown) => void; + + constructor( + executor: ( + resolve: (value: T | PromiseLike) => void, + reject: (reason?: unknown) => void, + onCancel: OnCancel + ) => void + ) { + this.#isResolved = false; + this.#isRejected = false; + this.#isCancelled = false; + this.#cancelHandlers = []; + this.#promise = new Promise((resolve, reject) => { + this.#resolve = resolve; + this.#reject = reject; + + const onResolve = (value: T | PromiseLike): void => { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#isResolved = true; + if (this.#resolve) this.#resolve(value); + }; + + const onReject = (reason?: unknown): void => { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#isRejected = true; + if (this.#reject) this.#reject(reason); + }; + + const onCancel = (cancelHandler: () => void): void => { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#cancelHandlers.push(cancelHandler); + }; + + Object.defineProperty(onCancel, 'isResolved', { + get: (): boolean => this.#isResolved, + }); + + Object.defineProperty(onCancel, 'isRejected', { + get: (): boolean => this.#isRejected, + }); + + Object.defineProperty(onCancel, 'isCancelled', { + get: (): boolean => this.#isCancelled, + }); + + return executor(onResolve, onReject, onCancel as OnCancel); + }); + } + + get [Symbol.toStringTag]() { + return 'Cancellable Promise'; + } + + public then( + onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, + onRejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): Promise { + return this.#promise.then(onFulfilled, onRejected); + } + + public catch( + onRejected?: ((reason: unknown) => TResult | PromiseLike) | null + ): Promise { + return this.#promise.catch(onRejected); + } + + public finally(onFinally?: (() => void) | null): Promise { + return this.#promise.finally(onFinally); + } + + public cancel(): void { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#isCancelled = true; + if (this.#cancelHandlers.length) { + try { + for (const cancelHandler of this.#cancelHandlers) { + cancelHandler(); + } + } catch (error) { + console.warn('Cancellation threw an error', error); + return; + } + } + this.#cancelHandlers.length = 0; + if (this.#reject) this.#reject(new CancelError('Request aborted')); + } + + public get isCancelled(): boolean { + return this.#isCancelled; + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/core/FetchHttpRequest.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/core/FetchHttpRequest.ts.snap new file mode 100644 index 000000000..e58e58780 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/core/FetchHttpRequest.ts.snap @@ -0,0 +1,21 @@ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import { BaseHttpRequest } from './BaseHttpRequest'; +import type { CancelablePromise } from './CancelablePromise'; +import type { OpenAPIConfig } from './OpenAPI'; +import { request as __request } from './request'; + +export class FetchHttpRequest extends BaseHttpRequest { + constructor(config: OpenAPIConfig) { + super(config); + } + + /** + * Request method + * @param options The request options from the service + * @returns CancelablePromise + * @throws ApiError + */ + public override request(options: ApiRequestOptions): CancelablePromise { + return __request(this.config, options); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/core/OpenAPI.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/core/OpenAPI.ts.snap new file mode 100644 index 000000000..9308c908f --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/core/OpenAPI.ts.snap @@ -0,0 +1,45 @@ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { TConfig, TResult } from './types'; + +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; + +export type OpenAPIConfig = { + BASE: string; + CREDENTIALS: 'include' | 'omit' | 'same-origin'; + ENCODE_PATH?: ((path: string) => string) | undefined; + HEADERS?: Headers | Resolver | undefined; + PASSWORD?: string | Resolver | undefined; + RESULT?: TResult; + TOKEN?: string | Resolver | undefined; + USERNAME?: string | Resolver | undefined; + VERSION: string; + WITH_CREDENTIALS: boolean; +}; + +export const OpenAPI: OpenAPIConfig = { + BASE: 'http://localhost:3000/base', + CREDENTIALS: 'include', + ENCODE_PATH: undefined, + HEADERS: undefined, + PASSWORD: undefined, + RESULT: 'body', + TOKEN: undefined, + USERNAME: undefined, + VERSION: '1.0', + WITH_CREDENTIALS: false, +}; + +export const mergeOpenApiConfig = (config: OpenAPIConfig, overrides: TConfig) => { + const merged = { ...config }; + Object.entries(overrides) + .filter(([key]) => key.startsWith('_')) + .forEach(([key, value]) => { + const k = key.slice(1).toLocaleUpperCase() as keyof typeof merged; + if (merged.hasOwnProperty(k)) { + // @ts-ignore + merged[k] = value; + } + }); + return merged; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/core/request.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/core/request.ts.snap new file mode 100644 index 000000000..7bc4c87bc --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/core/request.ts.snap @@ -0,0 +1,314 @@ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import { CancelablePromise } from './CancelablePromise'; +import type { OnCancel } from './CancelablePromise'; +import type { OpenAPIConfig } from './OpenAPI'; + +export const isString = (value: unknown): value is string => { + return typeof value === 'string'; +}; + +export const isStringWithValue = (value: unknown): value is string => { + return isString(value) && value !== ''; +}; + +export const isBlob = (value: any): value is Blob => { + return ( + value !== null && + typeof value === 'object' && + typeof value.type === 'string' && + typeof value.stream === 'function' && + typeof value.arrayBuffer === 'function' && + typeof value.constructor === 'function' && + typeof value.constructor.name === 'string' && + /^(Blob|File)$/.test(value.constructor.name) && + // @ts-ignore + /^(Blob|File)$/.test(value[Symbol.toStringTag]) + ); +}; + +export const isFormData = (value: unknown): value is FormData => { + return value instanceof FormData; +}; + +export const base64 = (str: string): string => { + try { + return btoa(str); + } catch (err) { + // @ts-ignore + return Buffer.from(str).toString('base64'); + } +}; + +export const getQueryString = (params: Record): string => { + const qs: string[] = []; + + const append = (key: string, value: unknown) => { + qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); + }; + + const encodePair = (key: string, value: unknown) => { + if (value === undefined || value === null) { + return; + } + + if (Array.isArray(value)) { + value.forEach(v => encodePair(key, v)); + } else if (typeof value === 'object') { + Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v)); + } else { + append(key, value); + } + }; + + Object.entries(params).forEach(([key, value]) => encodePair(key, value)); + + return qs.length ? `?${qs.join('&')}` : ''; +}; + +const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { + const encoder = config.ENCODE_PATH || encodeURI; + + const path = options.url + .replace('{api-version}', config.VERSION) + .replace(/{(.*?)}/g, (substring: string, group: string) => { + if (options.path?.hasOwnProperty(group)) { + return encoder(String(options.path[group])); + } + return substring; + }); + + const url = config.BASE + path; + return options.query ? url + getQueryString(options.query) : url; +}; + +export const getFormData = (options: ApiRequestOptions): FormData | undefined => { + if (options.formData) { + const formData = new FormData(); + + const process = (key: string, value: any) => { + if (isString(value) || isBlob(value)) { + formData.append(key, value); + } else { + formData.append(key, JSON.stringify(value)); + } + }; + + Object.entries(options.formData) + .filter(([_, value]) => value !== undefined && value !== null) + .forEach(([key, value]) => { + if (Array.isArray(value)) { + value.forEach(v => process(key, v)); + } else { + process(key, value); + } + }); + + return formData; + } + return undefined; +}; + +type Resolver = (options: ApiRequestOptions) => Promise; + +export const resolve = async (options: ApiRequestOptions, resolver?: T | Resolver): Promise => { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +}; + +export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise => { + const [token, username, password, additionalHeaders] = await Promise.all([ + resolve(options, config.TOKEN), + resolve(options, config.USERNAME), + resolve(options, config.PASSWORD), + resolve(options, config.HEADERS), + ]); + + const headers = Object.entries({ + Accept: 'application/json', + ...additionalHeaders, + ...options.headers, + }) + .filter(([_, value]) => value !== undefined && value !== null) + .reduce( + (headers, [key, value]) => ({ + ...headers, + [key]: String(value), + }), + {} as Record + ); + + if (isStringWithValue(token)) { + headers['Authorization'] = `Bearer ${token}`; + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = base64(`${username}:${password}`); + headers['Authorization'] = `Basic ${credentials}`; + } + + if (options.body !== undefined) { + if (options.mediaType) { + headers['Content-Type'] = options.mediaType; + } else if (isBlob(options.body)) { + headers['Content-Type'] = options.body.type || 'application/octet-stream'; + } else if (isString(options.body)) { + headers['Content-Type'] = 'text/plain'; + } else if (!isFormData(options.body)) { + headers['Content-Type'] = 'application/json'; + } + } + + return new Headers(headers); +}; + +export const getRequestBody = (options: ApiRequestOptions): unknown => { + if (options.body !== undefined) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body); + } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +}; + +export const sendRequest = async ( + config: OpenAPIConfig, + options: ApiRequestOptions, + url: string, + body: any, + formData: FormData | undefined, + headers: Headers, + onCancel: OnCancel +): Promise => { + const controller = new AbortController(); + + const request: RequestInit = { + headers, + body: body ?? formData, + method: options.method, + signal: controller.signal, + }; + + if (config.WITH_CREDENTIALS) { + request.credentials = config.CREDENTIALS; + } + + onCancel(() => controller.abort()); + + return await fetch(url, request); +}; + +export const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return undefined; +}; + +export const getResponseBody = async (response: Response): Promise => { + if (response.status !== 204) { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const jsonTypes = ['application/json', 'application/problem+json']; + const binaryTypes = ['audio/', 'image/', 'video/']; + const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type)); + const isBinary = binaryTypes.some(type => contentType.toLowerCase().startsWith(type)); + if (isJSON) { + return await response.json(); + } else if (isBinary) { + return await response.blob(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + } + return undefined; +}; + +export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => { + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + }; + + const error = errors[result.status]; + if (error) { + throw new ApiError(options, result, error); + } + + if (!result.ok) { + const errorStatus = result.status ?? 'unknown'; + const errorStatusText = result.statusText ?? 'unknown'; + const errorBody = (() => { + try { + return JSON.stringify(result.body, null, 2); + } catch (e) { + return undefined; + } + })(); + + throw new ApiError( + options, + result, + `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}` + ); + } +}; + +/** + * Request method + * @param config The OpenAPI configuration object + * @param options The request options from the service + * @returns CancelablePromise + * @throws ApiError + */ +export const request = (config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise => { + return new CancelablePromise(async (resolve, reject, onCancel) => { + try { + const url = getUrl(config, options); + const formData = getFormData(options); + const body = getRequestBody(options); + const headers = await getHeaders(config, options); + + if (!onCancel.isCancelled) { + const response = await sendRequest(config, options, url, body, formData, headers, onCancel); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader ?? responseBody, + }; + + catchErrorCodes(options, result); + + resolve(result.body); + } + } catch (error) { + reject(error); + } + }); +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/core/types.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/core/types.ts.snap new file mode 100644 index 000000000..e33a5d996 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/core/types.ts.snap @@ -0,0 +1,10 @@ +import type { ApiResult } from './ApiResult'; + +export type TResult = 'body' | 'raw'; + +export type TApiResponse = + Exclude extends never ? ApiResult : ApiResult['body']; + +export type TConfig = { + _result?: T; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/index.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/index.ts.snap new file mode 100644 index 000000000..68267b95e --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/index.ts.snap @@ -0,0 +1,10 @@ +export { ApiClient } from './ApiClient'; + +export { ApiError } from './core/ApiError'; +export { BaseHttpRequest } from './core/BaseHttpRequest'; +export { CancelablePromise, CancelError } from './core/CancelablePromise'; +export { OpenAPI } from './core/OpenAPI'; +export type { OpenAPIConfig } from './core/OpenAPI'; + +export * from './models'; +export * from './services'; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/AnyOfAnyAndNull.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/AnyOfAnyAndNull.ts.snap new file mode 100644 index 000000000..6ae8825f1 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/AnyOfAnyAndNull.ts.snap @@ -0,0 +1,3 @@ +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/AnyOfArrays.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/AnyOfArrays.ts.snap new file mode 100644 index 000000000..19603e432 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/AnyOfArrays.ts.snap @@ -0,0 +1,13 @@ +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array< + | { + foo?: string; + } + | { + bar?: string; + } + >; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithAnyOfProperties.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithAnyOfProperties.ts.snap new file mode 100644 index 000000000..f1035ac52 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithAnyOfProperties.ts.snap @@ -0,0 +1,11 @@ +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array< + | { + foo?: string; + } + | { + bar?: string; + } +>; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithArray.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithArray.ts.snap new file mode 100644 index 000000000..e22d6a4be --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithArray.ts.snap @@ -0,0 +1,6 @@ +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithBooleans.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithBooleans.ts.snap new file mode 100644 index 000000000..47c9c25ad --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithBooleans.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithNumbers.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithNumbers.ts.snap new file mode 100644 index 000000000..e19d5c773 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithNumbers.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithProperties.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithProperties.ts.snap new file mode 100644 index 000000000..2cb636892 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithProperties.ts.snap @@ -0,0 +1,7 @@ +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + foo?: string; + bar?: string; +}>; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithReferences.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithReferences.ts.snap new file mode 100644 index 000000000..cce8ccacb --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithReferences.ts.snap @@ -0,0 +1,6 @@ +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithStrings.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithStrings.ts.snap new file mode 100644 index 000000000..df2b24751 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ArrayWithStrings.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithBackticks.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithBackticks.ts.snap new file mode 100644 index 000000000..8821bb20e --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithBackticks.ts.snap @@ -0,0 +1,4 @@ +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithBreaks.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithBreaks.ts.snap new file mode 100644 index 000000000..1901bb6c3 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithBreaks.ts.snap @@ -0,0 +1,7 @@ +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithExpressionPlaceholders.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithExpressionPlaceholders.ts.snap new file mode 100644 index 000000000..5fc8b7e03 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithExpressionPlaceholders.ts.snap @@ -0,0 +1,4 @@ +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithQuotes.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithQuotes.ts.snap new file mode 100644 index 000000000..f5abb3c73 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithQuotes.ts.snap @@ -0,0 +1,4 @@ +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithReservedCharacters.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithReservedCharacters.ts.snap new file mode 100644 index 000000000..0a8ee6de3 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithReservedCharacters.ts.snap @@ -0,0 +1,4 @@ +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithSlashes.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithSlashes.ts.snap new file mode 100644 index 000000000..ec9d9f26d --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CommentWithSlashes.ts.snap @@ -0,0 +1,4 @@ +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionBaseModel.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionBaseModel.ts.snap new file mode 100644 index 000000000..4a6997e24 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionBaseModel.ts.snap @@ -0,0 +1,7 @@ +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionExtendedModel.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionExtendedModel.ts.snap new file mode 100644 index 000000000..5d5598c88 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionExtendedModel.ts.snap @@ -0,0 +1,10 @@ +import type { CompositionBaseModel } from './CompositionBaseModel'; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + firstName: string; + lastname: string; + age: number; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAllOfAndNullable.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAllOfAndNullable.ts.snap new file mode 100644 index 000000000..5c22a114c --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAllOfAndNullable.ts.snap @@ -0,0 +1,16 @@ +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: + | ({ + boolean?: boolean; + } & ModelWithEnum & + ModelWithArray & + ModelWithDictionary) + | null; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAnyOf.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAnyOf.ts.snap new file mode 100644 index 000000000..b4f77afd8 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAnyOf.ts.snap @@ -0,0 +1,11 @@ +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAnyOfAndNullable.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAnyOfAndNullable.ts.snap new file mode 100644 index 000000000..e03daa1fa --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAnyOfAndNullable.ts.snap @@ -0,0 +1,17 @@ +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: + | { + boolean?: boolean; + } + | ModelWithEnum + | ModelWithArray + | ModelWithDictionary + | null; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAnyOfAnonymous.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAnyOfAnonymous.ts.snap new file mode 100644 index 000000000..b5abf3bc7 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithAnyOfAnonymous.ts.snap @@ -0,0 +1,11 @@ +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: + | { + propA?: string; + } + | string + | number; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithNestedAnyAndTypeNull.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithNestedAnyAndTypeNull.ts.snap new file mode 100644 index 000000000..198a0920f --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithNestedAnyAndTypeNull.ts.snap @@ -0,0 +1,9 @@ +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithNestedAnyOfAndNull.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithNestedAnyOfAndNull.ts.snap new file mode 100644 index 000000000..f598fed05 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithNestedAnyOfAndNull.ts.snap @@ -0,0 +1,9 @@ +import type { ConstValue } from './ConstValue'; +import type { Enum1 } from './Enum1'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + propA?: Array | null; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOf.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOf.ts.snap new file mode 100644 index 000000000..6faf1d73a --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOf.ts.snap @@ -0,0 +1,11 @@ +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndComplexArrayDictionary.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndComplexArrayDictionary.ts.snap new file mode 100644 index 000000000..f98100a06 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndComplexArrayDictionary.ts.snap @@ -0,0 +1,6 @@ +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | Record>; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndNullable.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndNullable.ts.snap new file mode 100644 index 000000000..c71253b8e --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndNullable.ts.snap @@ -0,0 +1,17 @@ +import type { ModelWithArray } from './ModelWithArray'; +import type { ModelWithDictionary } from './ModelWithDictionary'; +import type { ModelWithEnum } from './ModelWithEnum'; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: + | { + boolean?: boolean; + } + | ModelWithEnum + | ModelWithArray + | ModelWithDictionary + | null; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndProperties.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndProperties.ts.snap new file mode 100644 index 000000000..b62f3159d --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndProperties.ts.snap @@ -0,0 +1,14 @@ +import type { NonAsciiStringæøåÆØÅöôêÊ字符串 } from './NonAsciiStringæøåÆØÅöôêÊ字符串'; +import type { SimpleParameter } from './SimpleParameter'; + +export type CompositionWithOneOfAndProperties = + | { + foo: SimpleParameter; + baz: number | null; + qux: number; + } + | { + bar: NonAsciiStringæøåÆØÅöôêÊ字符串; + baz: number | null; + qux: number; + }; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndSimpleArrayDictionary.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndSimpleArrayDictionary.ts.snap new file mode 100644 index 000000000..7d89d086e --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndSimpleArrayDictionary.ts.snap @@ -0,0 +1,6 @@ +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | Record>; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndSimpleDictionary.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndSimpleDictionary.ts.snap new file mode 100644 index 000000000..df2b73b59 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAndSimpleDictionary.ts.snap @@ -0,0 +1,6 @@ +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | Record; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAnonymous.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAnonymous.ts.snap new file mode 100644 index 000000000..befe9779a --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfAnonymous.ts.snap @@ -0,0 +1,11 @@ +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: + | { + propA?: string; + } + | string + | number; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfDiscriminator.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfDiscriminator.ts.snap new file mode 100644 index 000000000..a2f9acd00 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/CompositionWithOneOfDiscriminator.ts.snap @@ -0,0 +1,7 @@ +import type { ModelCircle } from './ModelCircle'; +import type { ModelSquare } from './ModelSquare'; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ConstValue.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ConstValue.ts.snap new file mode 100644 index 000000000..2ae94c345 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ConstValue.ts.snap @@ -0,0 +1 @@ +export type ConstValue = 'ConstValue'; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/DeprecatedModel.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/DeprecatedModel.ts.snap new file mode 100644 index 000000000..d42fc4724 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/DeprecatedModel.ts.snap @@ -0,0 +1,11 @@ +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithArray.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithArray.ts.snap new file mode 100644 index 000000000..1f607589c --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithArray.ts.snap @@ -0,0 +1,6 @@ +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = Record>; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithDictionary.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithDictionary.ts.snap new file mode 100644 index 000000000..8de230522 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithDictionary.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = Record>; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithProperties.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithProperties.ts.snap new file mode 100644 index 000000000..4997b3540 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithProperties.ts.snap @@ -0,0 +1,10 @@ +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = Record< + string, + { + foo?: string; + bar?: string; + } +>; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithReference.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithReference.ts.snap new file mode 100644 index 000000000..9c6984d91 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithReference.ts.snap @@ -0,0 +1,6 @@ +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a string reference + */ +export type DictionaryWithReference = Record; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithString.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithString.ts.snap new file mode 100644 index 000000000..8cdba767c --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/DictionaryWithString.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a string dictionary + */ +export type DictionaryWithString = Record; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/Enum1.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/Enum1.ts.snap new file mode 100644 index 000000000..0421d9cc6 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/Enum1.ts.snap @@ -0,0 +1,6 @@ +export type Enum1 = 'Bird' | 'Dog'; + +export const Enum1Enum = { + BIRD: 'Bird', + DOG: 'Dog', +} as const; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumFromDescription.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumFromDescription.ts.snap new file mode 100644 index 000000000..c399deac4 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumFromDescription.ts.snap @@ -0,0 +1,4 @@ +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithExtensions.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithExtensions.ts.snap new file mode 100644 index 000000000..d5ca1e898 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithExtensions.ts.snap @@ -0,0 +1,19 @@ +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +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; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithNumbers.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithNumbers.ts.snap new file mode 100644 index 000000000..b2f85dc12 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithNumbers.ts.snap @@ -0,0 +1,22 @@ +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +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; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithReplacedCharacters.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithReplacedCharacters.ts.snap new file mode 100644 index 000000000..9813f93c4 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithReplacedCharacters.ts.snap @@ -0,0 +1,9 @@ +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +export const EnumWithReplacedCharactersEnum = { + _SINGLE_QUOTE_: "'Single Quote'", + _DOUBLE_QUOTES_: '"Double Quotes"', + ØÆÅÔÖ_ØÆÅÔÖ字符串: 'øæåôöØÆÅÔÖ字符串', + '_3.1': 3.1, + EMPTY_STRING: '', +} as const; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithStrings.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithStrings.ts.snap new file mode 100644 index 000000000..126afe0c1 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/EnumWithStrings.ts.snap @@ -0,0 +1,19 @@ +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = + | 'Success' + | 'Warning' + | 'Error' + | "'Single Quote'" + | '"Double Quotes"' + | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export const EnumWithStringsEnum = { + SUCCESS: 'Success', + WARNING: 'Warning', + ERROR: 'Error', + _SINGLE_QUOTE_: "'Single Quote'", + _DOUBLE_QUOTES_: '"Double Quotes"', + NON_ASCII__ØÆÅÔÖ_ØÆÅÔÖ字符串: 'Non-ascii: øæåôöØÆÅÔÖ字符串', +} as const; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/File.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/File.ts.snap new file mode 100644 index 000000000..0ef950a79 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/File.ts.snap @@ -0,0 +1,7 @@ +export type File = { + readonly id?: string; + readonly updated_at?: Date; + readonly created_at?: Date; + mime: string; + readonly file?: string; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/FreeFormObjectWithAdditionalPropertiesEqEmptyObject.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/FreeFormObjectWithAdditionalPropertiesEqEmptyObject.ts.snap new file mode 100644 index 000000000..0fb4a7517 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/FreeFormObjectWithAdditionalPropertiesEqEmptyObject.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = Record; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/FreeFormObjectWithAdditionalPropertiesEqTrue.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/FreeFormObjectWithAdditionalPropertiesEqTrue.ts.snap new file mode 100644 index 000000000..16961a031 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/FreeFormObjectWithAdditionalPropertiesEqTrue.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = Record; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/FreeFormObjectWithoutAdditionalProperties.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/FreeFormObjectWithoutAdditionalProperties.ts.snap new file mode 100644 index 000000000..9ab1d8d24 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/FreeFormObjectWithoutAdditionalProperties.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = Record; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelCircle.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelCircle.ts.snap new file mode 100644 index 000000000..ad93f2e41 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelCircle.ts.snap @@ -0,0 +1,7 @@ +/** + * Circle + */ +export type ModelCircle = { + kind: 'circle'; + radius?: number; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelSquare.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelSquare.ts.snap new file mode 100644 index 000000000..f1911fe03 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelSquare.ts.snap @@ -0,0 +1,7 @@ +/** + * Square + */ +export type ModelSquare = { + kind: 'square'; + sideLength?: number; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelThatExtends.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelThatExtends.ts.snap new file mode 100644 index 000000000..4ae9a1b85 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelThatExtends.ts.snap @@ -0,0 +1,9 @@ +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelThatExtendsExtends.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelThatExtendsExtends.ts.snap new file mode 100644 index 000000000..8207bd040 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelThatExtendsExtends.ts.snap @@ -0,0 +1,11 @@ +import type { ModelThatExtends } from './ModelThatExtends'; +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & + ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; + }; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithAdditionalPropertiesEqTrue.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithAdditionalPropertiesEqTrue.ts.snap new file mode 100644 index 000000000..4d5a422ec --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithAdditionalPropertiesEqTrue.ts.snap @@ -0,0 +1,10 @@ +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithArray.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithArray.ts.snap new file mode 100644 index 000000000..b3caea287 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithArray.ts.snap @@ -0,0 +1,10 @@ +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithArrayReadOnlyAndWriteOnly.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithArrayReadOnlyAndWriteOnly.ts.snap new file mode 100644 index 000000000..a0679628f --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithArrayReadOnlyAndWriteOnly.ts.snap @@ -0,0 +1,10 @@ +import type { ModelWithReadOnlyAndWriteOnly } from './ModelWithReadOnlyAndWriteOnly'; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithBoolean.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithBoolean.ts.snap new file mode 100644 index 000000000..3fb0b51c4 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithBoolean.ts.snap @@ -0,0 +1,9 @@ +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithCircularReference.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithCircularReference.ts.snap new file mode 100644 index 000000000..02560acd2 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithCircularReference.ts.snap @@ -0,0 +1,6 @@ +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithConst.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithConst.ts.snap new file mode 100644 index 000000000..174ff6348 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithConst.ts.snap @@ -0,0 +1,6 @@ +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithDictionary.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithDictionary.ts.snap new file mode 100644 index 000000000..34e8b2904 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithDictionary.ts.snap @@ -0,0 +1,6 @@ +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: Record; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithDuplicateImports.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithDuplicateImports.ts.snap new file mode 100644 index 000000000..55a879e42 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithDuplicateImports.ts.snap @@ -0,0 +1,10 @@ +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithDuplicateProperties.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithDuplicateProperties.ts.snap new file mode 100644 index 000000000..865db789c --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithDuplicateProperties.ts.snap @@ -0,0 +1,8 @@ +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithEnum.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithEnum.ts.snap new file mode 100644 index 000000000..848b2f336 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithEnum.ts.snap @@ -0,0 +1,33 @@ +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + test?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: boolean; +}; + +export const TestEnum = { + SUCCESS: 'Success', + WARNING: 'Warning', + ERROR: 'Error', + ØÆÅ字符串: 'ØÆÅ字符串', +} as const; + +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; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithEnumFromDescription.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithEnumFromDescription.ts.snap new file mode 100644 index 000000000..d34988f55 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithEnumFromDescription.ts.snap @@ -0,0 +1,9 @@ +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithEnumWithHyphen.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithEnumWithHyphen.ts.snap new file mode 100644 index 000000000..1f1b43b9f --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithEnumWithHyphen.ts.snap @@ -0,0 +1,10 @@ +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + 'foo-bar-baz-qux'?: '3.0'; +}; + +export const FooBarBazQuxEnum = { + _3_0: '3.0', +} as const; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithInteger.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithInteger.ts.snap new file mode 100644 index 000000000..fcf3ed1d6 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithInteger.ts.snap @@ -0,0 +1,9 @@ +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnums.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnums.ts.snap new file mode 100644 index 000000000..3abc00ee6 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnums.ts.snap @@ -0,0 +1,6 @@ +import type { ModelWithNestedArrayEnumsData } from './ModelWithNestedArrayEnumsData'; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnumsData.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnumsData.ts.snap new file mode 100644 index 000000000..b675991c0 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnumsData.ts.snap @@ -0,0 +1,7 @@ +import type { ModelWithNestedArrayEnumsDataBar } from './ModelWithNestedArrayEnumsDataBar'; +import type { ModelWithNestedArrayEnumsDataFoo } from './ModelWithNestedArrayEnumsDataFoo'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnumsDataBar.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnumsDataBar.ts.snap new file mode 100644 index 000000000..fd53127ed --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnumsDataBar.ts.snap @@ -0,0 +1,6 @@ +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export const ModelWithNestedArrayEnumsDataBarEnum = { + BAZ: 'baz', + QUX: 'qux', +} as const; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnumsDataFoo.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnumsDataFoo.ts.snap new file mode 100644 index 000000000..9ea608074 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedArrayEnumsDataFoo.ts.snap @@ -0,0 +1,6 @@ +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export const ModelWithNestedArrayEnumsDataFooEnum = { + FOO: 'foo', + BAR: 'bar', +} as const; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedCompositionEnums.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedCompositionEnums.ts.snap new file mode 100644 index 000000000..ae1ec5fd5 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedCompositionEnums.ts.snap @@ -0,0 +1,5 @@ +import type { ModelWithNestedArrayEnumsDataFoo } from './ModelWithNestedArrayEnumsDataFoo'; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedEnums.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedEnums.ts.snap new file mode 100644 index 000000000..8e1ed1cd8 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedEnums.ts.snap @@ -0,0 +1,9 @@ +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: Record; + dictionaryWithEnumFromDescription?: Record; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedProperties.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedProperties.ts.snap new file mode 100644 index 000000000..1c9d61d63 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNestedProperties.ts.snap @@ -0,0 +1,10 @@ +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNullableObject.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNullableObject.ts.snap new file mode 100644 index 000000000..14a3288e3 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNullableObject.ts.snap @@ -0,0 +1,5 @@ +import type { NullableObject } from './NullableObject'; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNullableString.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNullableString.ts.snap new file mode 100644 index 000000000..da7b07f72 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithNullableString.ts.snap @@ -0,0 +1,21 @@ +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithOneOfEnum.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithOneOfEnum.ts.snap new file mode 100644 index 000000000..8a7d97180 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithOneOfEnum.ts.snap @@ -0,0 +1,22 @@ +export type ModelWithOneOfEnum = + | { + foo: 'Bar'; + } + | { + foo: 'Baz'; + } + | { + foo: 'Qux'; + } + | { + content: Date; + foo: 'Quux'; + } + | { + content: [Date, string]; + foo: 'Corge'; + }; + +export const FooEnum = { + BAR: 'Bar', +} as const; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithOrderedProperties.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithOrderedProperties.ts.snap new file mode 100644 index 000000000..d9e532738 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithOrderedProperties.ts.snap @@ -0,0 +1,8 @@ +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithPattern.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithPattern.ts.snap new file mode 100644 index 000000000..50059d14c --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithPattern.ts.snap @@ -0,0 +1,14 @@ +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: Date; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithProperties.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithProperties.ts.snap new file mode 100644 index 000000000..34d1f8bf8 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithProperties.ts.snap @@ -0,0 +1,19 @@ +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithReadOnlyAndWriteOnly.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithReadOnlyAndWriteOnly.ts.snap new file mode 100644 index 000000000..558101f98 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithReadOnlyAndWriteOnly.ts.snap @@ -0,0 +1,5 @@ +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; + baz: string; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithReference.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithReference.ts.snap new file mode 100644 index 000000000..80dbd078b --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithReference.ts.snap @@ -0,0 +1,8 @@ +import type { ModelWithProperties } from './ModelWithProperties'; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithString.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithString.ts.snap new file mode 100644 index 000000000..7e0e7b336 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/ModelWithString.ts.snap @@ -0,0 +1,9 @@ +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/NestedAnyOfArraysNullable.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/NestedAnyOfArraysNullable.ts.snap new file mode 100644 index 000000000..241963542 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/NestedAnyOfArraysNullable.ts.snap @@ -0,0 +1,3 @@ +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; diff --git "a/test/__snapshots__/v3-client/test/generated/v3_client/models/NonAsciiString\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212\345\255\227\347\254\246\344\270\262.ts.snap" "b/test/__snapshots__/v3-client/test/generated/v3_client/models/NonAsciiString\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212\345\255\227\347\254\246\344\270\262.ts.snap" new file mode 100644 index 000000000..72359bbde --- /dev/null +++ "b/test/__snapshots__/v3-client/test/generated/v3_client/models/NonAsciiString\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212\345\255\227\347\254\246\344\270\262.ts.snap" @@ -0,0 +1,4 @@ +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆØÅöôêÊ字符串 = string; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/NullableObject.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/NullableObject.ts.snap new file mode 100644 index 000000000..c2f64ece7 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/NullableObject.ts.snap @@ -0,0 +1,6 @@ +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/Pageable.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/Pageable.ts.snap new file mode 100644 index 000000000..659cc4bc2 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/Pageable.ts.snap @@ -0,0 +1,5 @@ +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleBoolean.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleBoolean.ts.snap new file mode 100644 index 000000000..99b020679 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleBoolean.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleFile.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleFile.ts.snap new file mode 100644 index 000000000..b206fcf96 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleFile.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a simple file + */ +export type SimpleFile = Blob; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleInteger.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleInteger.ts.snap new file mode 100644 index 000000000..7a547a495 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleInteger.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a simple number + */ +export type SimpleInteger = number; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleParameter.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleParameter.ts.snap new file mode 100644 index 000000000..8d9bcc2be --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleParameter.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleReference.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleReference.ts.snap new file mode 100644 index 000000000..d4ddda16f --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleReference.ts.snap @@ -0,0 +1,6 @@ +import type { ModelWithString } from './ModelWithString'; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleString.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleString.ts.snap new file mode 100644 index 000000000..ce4410ecf --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleString.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a simple string + */ +export type SimpleString = string; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleStringWithPattern.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleStringWithPattern.ts.snap new file mode 100644 index 000000000..4765083c8 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/SimpleStringWithPattern.ts.snap @@ -0,0 +1,4 @@ +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/_default.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/_default.ts.snap new file mode 100644 index 000000000..0867799ba --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/_default.ts.snap @@ -0,0 +1,3 @@ +export type _default = { + name?: string; +}; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/models/index.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/models/index.ts.snap new file mode 100644 index 000000000..ddb62d6e1 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/models/index.ts.snap @@ -0,0 +1,103 @@ +export type { CommentWithBreaks } from './CommentWithBreaks'; +export type { CommentWithBackticks } from './CommentWithBackticks'; +export type { CommentWithSlashes } from './CommentWithSlashes'; +export type { CommentWithExpressionPlaceholders } from './CommentWithExpressionPlaceholders'; +export type { CommentWithQuotes } from './CommentWithQuotes'; +export type { CommentWithReservedCharacters } from './CommentWithReservedCharacters'; +export type { SimpleInteger } from './SimpleInteger'; +export type { SimpleBoolean } from './SimpleBoolean'; +export type { SimpleString } from './SimpleString'; +export type { NonAsciiStringæøåÆØÅöôêÊ字符串 } from './NonAsciiStringæøåÆØÅöôêÊ字符串'; +export type { SimpleFile } from './SimpleFile'; +export type { SimpleReference } from './SimpleReference'; +export type { SimpleStringWithPattern } from './SimpleStringWithPattern'; +export type { EnumWithStrings } from './EnumWithStrings'; +export { EnumWithStringsEnum } from './EnumWithStrings'; +export type { EnumWithReplacedCharacters } from './EnumWithReplacedCharacters'; +export { EnumWithReplacedCharactersEnum } from './EnumWithReplacedCharacters'; +export type { EnumWithNumbers } from './EnumWithNumbers'; +export { EnumWithNumbersEnum } from './EnumWithNumbers'; +export type { EnumFromDescription } from './EnumFromDescription'; +export type { EnumWithExtensions } from './EnumWithExtensions'; +export { EnumWithExtensionsEnum } from './EnumWithExtensions'; +export type { ArrayWithNumbers } from './ArrayWithNumbers'; +export type { ArrayWithBooleans } from './ArrayWithBooleans'; +export type { ArrayWithStrings } from './ArrayWithStrings'; +export type { ArrayWithReferences } from './ArrayWithReferences'; +export type { ArrayWithArray } from './ArrayWithArray'; +export type { ArrayWithProperties } from './ArrayWithProperties'; +export type { ArrayWithAnyOfProperties } from './ArrayWithAnyOfProperties'; +export type { AnyOfAnyAndNull } from './AnyOfAnyAndNull'; +export type { AnyOfArrays } from './AnyOfArrays'; +export type { DictionaryWithString } from './DictionaryWithString'; +export type { DictionaryWithReference } from './DictionaryWithReference'; +export type { DictionaryWithArray } from './DictionaryWithArray'; +export type { DictionaryWithDictionary } from './DictionaryWithDictionary'; +export type { DictionaryWithProperties } from './DictionaryWithProperties'; +export type { ModelWithInteger } from './ModelWithInteger'; +export type { ModelWithBoolean } from './ModelWithBoolean'; +export type { ModelWithString } from './ModelWithString'; +export type { ModelWithNullableString } from './ModelWithNullableString'; +export type { ModelWithEnum } from './ModelWithEnum'; +export { TestEnum, StatusCodeEnum } from './ModelWithEnum'; +export type { ModelWithEnumWithHyphen } from './ModelWithEnumWithHyphen'; +export { FooBarBazQuxEnum } from './ModelWithEnumWithHyphen'; +export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; +export type { ModelWithNestedEnums } from './ModelWithNestedEnums'; +export type { ModelWithReference } from './ModelWithReference'; +export type { ModelWithArrayReadOnlyAndWriteOnly } from './ModelWithArrayReadOnlyAndWriteOnly'; +export type { ModelWithArray } from './ModelWithArray'; +export type { ModelWithDictionary } from './ModelWithDictionary'; +export type { DeprecatedModel } from './DeprecatedModel'; +export type { ModelWithCircularReference } from './ModelWithCircularReference'; +export type { CompositionWithOneOf } from './CompositionWithOneOf'; +export type { CompositionWithOneOfAnonymous } from './CompositionWithOneOfAnonymous'; +export type { ModelCircle } from './ModelCircle'; +export type { ModelSquare } from './ModelSquare'; +export type { CompositionWithOneOfDiscriminator } from './CompositionWithOneOfDiscriminator'; +export type { CompositionWithAnyOf } from './CompositionWithAnyOf'; +export type { CompositionWithAnyOfAnonymous } from './CompositionWithAnyOfAnonymous'; +export type { CompositionWithNestedAnyAndTypeNull } from './CompositionWithNestedAnyAndTypeNull'; +export type { Enum1 } from './Enum1'; +export { Enum1Enum } from './Enum1'; +export type { ConstValue } from './ConstValue'; +export type { CompositionWithNestedAnyOfAndNull } from './CompositionWithNestedAnyOfAndNull'; +export type { CompositionWithOneOfAndNullable } from './CompositionWithOneOfAndNullable'; +export type { CompositionWithOneOfAndSimpleDictionary } from './CompositionWithOneOfAndSimpleDictionary'; +export type { CompositionWithOneOfAndSimpleArrayDictionary } from './CompositionWithOneOfAndSimpleArrayDictionary'; +export type { CompositionWithOneOfAndComplexArrayDictionary } from './CompositionWithOneOfAndComplexArrayDictionary'; +export type { CompositionWithAllOfAndNullable } from './CompositionWithAllOfAndNullable'; +export type { CompositionWithAnyOfAndNullable } from './CompositionWithAnyOfAndNullable'; +export type { CompositionBaseModel } from './CompositionBaseModel'; +export type { CompositionExtendedModel } from './CompositionExtendedModel'; +export type { ModelWithProperties } from './ModelWithProperties'; +export type { ModelWithNestedProperties } from './ModelWithNestedProperties'; +export type { ModelWithDuplicateProperties } from './ModelWithDuplicateProperties'; +export type { ModelWithOrderedProperties } from './ModelWithOrderedProperties'; +export type { ModelWithDuplicateImports } from './ModelWithDuplicateImports'; +export type { ModelThatExtends } from './ModelThatExtends'; +export type { ModelThatExtendsExtends } from './ModelThatExtendsExtends'; +export type { ModelWithPattern } from './ModelWithPattern'; +export type { File } from './File'; +export type { _default } from './_default'; +export type { Pageable } from './Pageable'; +export type { FreeFormObjectWithoutAdditionalProperties } from './FreeFormObjectWithoutAdditionalProperties'; +export type { FreeFormObjectWithAdditionalPropertiesEqTrue } from './FreeFormObjectWithAdditionalPropertiesEqTrue'; +export type { FreeFormObjectWithAdditionalPropertiesEqEmptyObject } from './FreeFormObjectWithAdditionalPropertiesEqEmptyObject'; +export type { ModelWithConst } from './ModelWithConst'; +export type { ModelWithAdditionalPropertiesEqTrue } from './ModelWithAdditionalPropertiesEqTrue'; +export type { NestedAnyOfArraysNullable } from './NestedAnyOfArraysNullable'; +export type { CompositionWithOneOfAndProperties } from './CompositionWithOneOfAndProperties'; +export type { NullableObject } from './NullableObject'; +export type { ModelWithNullableObject } from './ModelWithNullableObject'; +export type { ModelWithOneOfEnum } from './ModelWithOneOfEnum'; +export { FooEnum } from './ModelWithOneOfEnum'; +export type { ModelWithNestedArrayEnumsDataFoo } from './ModelWithNestedArrayEnumsDataFoo'; +export { ModelWithNestedArrayEnumsDataFooEnum } from './ModelWithNestedArrayEnumsDataFoo'; +export type { ModelWithNestedArrayEnumsDataBar } from './ModelWithNestedArrayEnumsDataBar'; +export { ModelWithNestedArrayEnumsDataBarEnum } from './ModelWithNestedArrayEnumsDataBar'; +export type { ModelWithNestedArrayEnumsData } from './ModelWithNestedArrayEnumsData'; +export type { ModelWithNestedArrayEnums } from './ModelWithNestedArrayEnums'; +export type { ModelWithNestedCompositionEnums } from './ModelWithNestedCompositionEnums'; +export type { ModelWithReadOnlyAndWriteOnly } from './ModelWithReadOnlyAndWriteOnly'; +export type { SimpleParameter } from './SimpleParameter'; diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/CollectionFormatService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/CollectionFormatService.ts.snap new file mode 100644 index 000000000..6f4c0e91c --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/CollectionFormatService.ts.snap @@ -0,0 +1,48 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataCollectionFormat = { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; +}; + +export class CollectionFormatService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @throws ApiError + */ + public collectionFormat(data: TDataCollectionFormat): CancelablePromise { + const { parameterArrayCsv, parameterArrayMulti, parameterArrayPipes, parameterArraySsv, parameterArrayTsv } = + data; + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/collectionFormat', + query: { + parameterArrayCSV: parameterArrayCsv, + parameterArraySSV: parameterArraySsv, + parameterArrayTSV: parameterArrayTsv, + parameterArrayPipes, + parameterArrayMulti, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/ComplexService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/ComplexService.ts.snap new file mode 100644 index 000000000..1e6f35075 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/ComplexService.ts.snap @@ -0,0 +1,80 @@ +import type { ModelWithArray } from '../models/ModelWithArray'; +import type { ModelWithDictionary } from '../models/ModelWithDictionary'; +import type { ModelWithEnum } from '../models/ModelWithEnum'; +import type { ModelWithString } from '../models/ModelWithString'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataComplexTypes = { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; +}; +export type TDataComplexParams = { + id: number; + requestBody?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + readonly type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; +}; + +export class ComplexService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns ModelWithString Successful response + * @throws ApiError + */ + public complexTypes(data: TDataComplexTypes): CancelablePromise> { + const { parameterObject, parameterReference } = data; + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/complex', + query: { + parameterObject, + parameterReference, + }, + errors: { + 400: `400 server error`, + 500: `500 server error`, + }, + }); + } + + /** + * @returns ModelWithString Success + * @throws ApiError + */ + public complexParams(data: TDataComplexParams): CancelablePromise { + const { id, requestBody } = data; + return this.httpRequest.request({ + method: 'PUT', + url: '/api/v{api-version}/complex/{id}', + path: { + id, + }, + body: requestBody, + mediaType: 'application/json-patch+json', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/DefaultService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/DefaultService.ts.snap new file mode 100644 index 000000000..29748faee --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/DefaultService.ts.snap @@ -0,0 +1,38 @@ +import type { ModelWithArrayReadOnlyAndWriteOnly } from '../models/ModelWithArrayReadOnlyAndWriteOnly'; +import type { ModelWithReadOnlyAndWriteOnly } from '../models/ModelWithReadOnlyAndWriteOnly'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataPostServiceWithEmptyTag = { + requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; +}; + +export class DefaultService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @throws ApiError + */ + public serviceWithEmptyTag(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/no-tag', + }); + } + + /** + * @returns ModelWithReadOnlyAndWriteOnly + * @throws ApiError + */ + public postServiceWithEmptyTag( + data: TDataPostServiceWithEmptyTag + ): CancelablePromise { + const { requestBody } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/no-tag', + body: requestBody, + mediaType: 'application/json', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/DefaultsService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/DefaultsService.ts.snap new file mode 100644 index 000000000..855d36149 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/DefaultsService.ts.snap @@ -0,0 +1,170 @@ +import type { ModelWithString } from '../models/ModelWithString'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataCallWithDefaultParameters = { + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple string with default value + */ + parameterString?: string | null; +}; +export type TDataCallWithDefaultOptionalParameters = { + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; +}; +export type TDataCallToTestOrderOfParams = { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string with default + */ + parameterStringWithDefault?: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault?: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; +}; + +export class DefaultsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @throws ApiError + */ + public callWithDefaultParameters(data: TDataCallWithDefaultParameters = {}): CancelablePromise { + const { + parameterBoolean = true, + parameterEnum = 'Success', + parameterModel = { + prop: 'Hello World!', + }, + parameterNumber = 123, + parameterString = 'Hello World!', + } = data; + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/defaults', + query: { + parameterString, + parameterNumber, + parameterBoolean, + parameterEnum, + parameterModel, + }, + }); + } + + /** + * @throws ApiError + */ + public callWithDefaultOptionalParameters( + data: TDataCallWithDefaultOptionalParameters = {} + ): CancelablePromise { + const { + parameterBoolean = true, + parameterEnum = 'Success', + parameterModel = { + prop: 'Hello World!', + }, + parameterNumber = 123, + parameterString = 'Hello World!', + } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/defaults', + query: { + parameterString, + parameterNumber, + parameterBoolean, + parameterEnum, + parameterModel, + }, + }); + } + + /** + * @throws ApiError + */ + public callToTestOrderOfParams(data: TDataCallToTestOrderOfParams): CancelablePromise { + const { + parameterOptionalStringWithDefault = 'Hello World!', + parameterOptionalStringWithEmptyDefault = '', + parameterOptionalStringWithNoDefault, + parameterStringNullableWithDefault = null, + parameterStringNullableWithNoDefault, + parameterStringWithDefault = 'Hello World!', + parameterStringWithEmptyDefault = '', + parameterStringWithNoDefault, + } = data; + return this.httpRequest.request({ + method: 'PUT', + url: '/api/v{api-version}/defaults', + query: { + parameterOptionalStringWithDefault, + parameterOptionalStringWithEmptyDefault, + parameterOptionalStringWithNoDefault, + parameterStringWithDefault, + parameterStringWithEmptyDefault, + parameterStringWithNoDefault, + parameterStringNullableWithNoDefault, + parameterStringNullableWithDefault, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/DeprecatedService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/DeprecatedService.ts.snap new file mode 100644 index 000000000..cd54834c1 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/DeprecatedService.ts.snap @@ -0,0 +1,29 @@ +import type { DeprecatedModel } from '../models/DeprecatedModel'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataDeprecatedCall = { + /** + * This parameter is deprecated + */ + parameter: DeprecatedModel | null; +}; + +export class DeprecatedService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @deprecated + * @throws ApiError + */ + public deprecatedCall(data: TDataDeprecatedCall): CancelablePromise { + const { parameter } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/parameters/deprecated', + headers: { + parameter, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/DescriptionsService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/DescriptionsService.ts.snap new file mode 100644 index 000000000..fcb6127a6 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/DescriptionsService.ts.snap @@ -0,0 +1,62 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataCallWithDescriptions = { + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: unknown; + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: unknown; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: unknown; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: unknown; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: unknown; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: unknown; +}; + +export class DescriptionsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @throws ApiError + */ + public callWithDescriptions(data: TDataCallWithDescriptions = {}): CancelablePromise { + const { + parameterWithBackticks, + parameterWithBreaks, + parameterWithExpressionPlaceholders, + parameterWithQuotes, + parameterWithReservedCharacters, + parameterWithSlashes, + } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/descriptions/', + query: { + parameterWithBreaks, + parameterWithBackticks, + parameterWithSlashes, + parameterWithExpressionPlaceholders, + parameterWithQuotes, + parameterWithReservedCharacters, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/DuplicateService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/DuplicateService.ts.snap new file mode 100644 index 000000000..bc973818a --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/DuplicateService.ts.snap @@ -0,0 +1,46 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class DuplicateService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @throws ApiError + */ + public duplicateName(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/duplicate', + }); + } + + /** + * @throws ApiError + */ + public duplicateName1(): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/duplicate', + }); + } + + /** + * @throws ApiError + */ + public duplicateName2(): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/api/v{api-version}/duplicate', + }); + } + + /** + * @throws ApiError + */ + public duplicateName3(): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/api/v{api-version}/duplicate', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/ErrorService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/ErrorService.ts.snap new file mode 100644 index 000000000..f08e48eab --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/ErrorService.ts.snap @@ -0,0 +1,34 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataTestErrorCode = { + /** + * Status code to return + */ + status: number; +}; + +export class ErrorService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns any Custom message: Successful response + * @throws ApiError + */ + public testErrorCode(data: TDataTestErrorCode): CancelablePromise { + const { status } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/error', + query: { + status, + }, + errors: { + 500: `Custom message: Internal Server Error`, + 501: `Custom message: Not Implemented`, + 502: `Custom message: Bad Gateway`, + 503: `Custom message: Service Unavailable`, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/FileResponseService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/FileResponseService.ts.snap new file mode 100644 index 000000000..1ae60f65e --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/FileResponseService.ts.snap @@ -0,0 +1,25 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataFileResponse = { + id: string; +}; + +export class FileResponseService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns binary Success + * @throws ApiError + */ + public fileResponse(data: TDataFileResponse): CancelablePromise { + const { id } = data; + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/file/{id}', + path: { + id, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/FormDataService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/FormDataService.ts.snap new file mode 100644 index 000000000..91e244fd7 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/FormDataService.ts.snap @@ -0,0 +1,34 @@ +import type { ModelWithString } from '../models/ModelWithString'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataPostApiFormData = { + /** + * A reusable request body + */ + formData?: ModelWithString; + /** + * This is a reusable parameter + */ + parameter?: string; +}; + +export class FormDataService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @throws ApiError + */ + public postApiFormData(data: TDataPostApiFormData = {}): CancelablePromise { + const { formData, parameter } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/formData/', + query: { + parameter, + }, + formData: formData, + mediaType: 'multipart/form-data', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/HeaderService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/HeaderService.ts.snap new file mode 100644 index 000000000..e8777c312 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/HeaderService.ts.snap @@ -0,0 +1,22 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class HeaderService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns string Successful response + * @throws ApiError + */ + public callWithResultFromHeader(): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/header', + responseHeader: 'operation-location', + errors: { + 400: `400 server error`, + 500: `500 server error`, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipartService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipartService.ts.snap new file mode 100644 index 000000000..c948254c8 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipartService.ts.snap @@ -0,0 +1,44 @@ +import type { ModelWithString } from '../models/ModelWithString'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataMultipartRequest = { + formData?: { + content?: Blob; + data?: ModelWithString | null; + }; +}; + +export class MultipartService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @throws ApiError + */ + public multipartRequest(data: TDataMultipartRequest = {}): CancelablePromise { + const { formData } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/multipart', + formData: formData, + mediaType: 'multipart/form-data', + }); + } + + /** + * @returns any OK + * @throws ApiError + */ + public multipartResponse(): CancelablePromise<{ + file?: Blob; + metadata?: { + foo?: string; + bar?: string; + }; + }> { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/multipart', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipleTags1Service.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipleTags1Service.ts.snap new file mode 100644 index 000000000..b9f5cf1b3 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipleTags1Service.ts.snap @@ -0,0 +1,28 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class MultipleTags1Service { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns void Success + * @throws ApiError + */ + public dummyA(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + }); + } + + /** + * @returns void Success + * @throws ApiError + */ + public dummyB(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipleTags2Service.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipleTags2Service.ts.snap new file mode 100644 index 000000000..dc50ec906 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipleTags2Service.ts.snap @@ -0,0 +1,28 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class MultipleTags2Service { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns void Success + * @throws ApiError + */ + public dummyA(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + }); + } + + /** + * @returns void Success + * @throws ApiError + */ + public dummyB(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipleTags3Service.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipleTags3Service.ts.snap new file mode 100644 index 000000000..fee47245a --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/MultipleTags3Service.ts.snap @@ -0,0 +1,17 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class MultipleTags3Service { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns void Success + * @throws ApiError + */ + public dummyB(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/NoContentService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/NoContentService.ts.snap new file mode 100644 index 000000000..0d76f25b2 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/NoContentService.ts.snap @@ -0,0 +1,29 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class NoContentService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns void Success + * @throws ApiError + */ + public callWithNoContentResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/no-content', + }); + } + + /** + * @returns number Response is a simple number + * @returns void Success + * @throws ApiError + */ + public callWithResponseAndNoContentResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + }); + } +} diff --git "a/test/__snapshots__/v3-client/test/generated/v3_client/services/NonAscii\303\206\303\270\303\245\303\206\303\270\303\205\303\266\303\264\303\252\303\212Service.ts.snap" "b/test/__snapshots__/v3-client/test/generated/v3_client/services/NonAscii\303\206\303\270\303\245\303\206\303\270\303\205\303\266\303\264\303\252\303\212Service.ts.snap" new file mode 100644 index 000000000..43a213286 --- /dev/null +++ "b/test/__snapshots__/v3-client/test/generated/v3_client/services/NonAscii\303\206\303\270\303\245\303\206\303\270\303\205\303\266\303\264\303\252\303\212Service.ts.snap" @@ -0,0 +1,31 @@ +import type { NonAsciiStringæøåÆØÅöôêÊ字符串 } from '../models/NonAsciiStringæøåÆØÅöôêÊ字符串'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataNonAsciiæøåÆøÅöôêÊ字符串 = { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; +}; + +export class NonAsciiÆøåÆøÅöôêÊService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns NonAsciiStringæøåÆØÅöôêÊ字符串 Successful response + * @throws ApiError + */ + public nonAsciiæøåÆøÅöôêÊ字符串( + data: TDataNonAsciiæøåÆøÅöôêÊ字符串 + ): CancelablePromise> { + const { nonAsciiParamæøåÆøÅöôêÊ } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + query: { + nonAsciiParamæøåÆØÅöôêÊ: nonAsciiParamæøåÆøÅöôêÊ, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/ParametersService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/ParametersService.ts.snap new file mode 100644 index 000000000..7f917cd9c --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/ParametersService.ts.snap @@ -0,0 +1,234 @@ +import type { ModelWithNestedArrayEnumsDataFoo } from '../models/ModelWithNestedArrayEnumsDataFoo'; +import type { ModelWithOneOfEnum } from '../models/ModelWithOneOfEnum'; +import type { ModelWithString } from '../models/ModelWithString'; +import type { Pageable } from '../models/Pageable'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataDeleteFoo = { + /** + * bar in method + */ + bar: string; + /** + * foo in method + */ + foo: string; +}; +export type TDataCallWithParameters = { + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the cookie + */ + parameterCookie: string | null; + /** + * This is the parameter that goes into the form data + */ + parameterForm: string | null; + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * This is the parameter that goes into the query params + */ + parameterQuery: string | null; + /** + * This is the parameter that goes into the body + */ + requestBody: ModelWithString | null; +}; +export type TDataCallWithWeirdParameterNames = { + /** + * This is the parameter with a reserved keyword + */ + _default?: string; + /** + * This is the parameter that goes into the cookie + */ + parameterCookie: string | null; + /** + * This is the parameter that goes into the request form data + */ + parameterForm: string | null; + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + /** + * This is the parameter that goes into the body + */ + requestBody: ModelWithString | null; +}; +export type TDataGetCallWithOptionalParam = { + /** + * This is an optional parameter + */ + parameter?: string; + /** + * This is a required parameter + */ + requestBody: ModelWithOneOfEnum; +}; +export type TDataPostCallWithOptionalParam = { + /** + * This is a required parameter + */ + parameter: Pageable; + /** + * This is an optional parameter + */ + requestBody?: ModelWithString; +}; + +export class ParametersService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @throws ApiError + */ + public deleteFoo(data: TDataDeleteFoo): CancelablePromise { + const { bar, foo } = data; + return this.httpRequest.request({ + method: 'DELETE', + url: '/api/v{api-version}/foo/{foo}/bar/{bar}', + path: { + foo, + bar, + }, + }); + } + + /** + * @throws ApiError + */ + public callWithParameters(data: TDataCallWithParameters): CancelablePromise { + const { + fooAllOfEnum, + fooRefEnum, + parameterCookie, + parameterForm, + parameterHeader, + parameterPath, + parameterQuery, + requestBody, + } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/parameters/{parameterPath}', + path: { + parameterPath, + }, + cookies: { + parameterCookie, + }, + headers: { + parameterHeader, + }, + query: { + foo_ref_enum: fooRefEnum, + foo_all_of_enum: fooAllOfEnum, + parameterQuery, + }, + formData: { + parameterForm, + }, + body: requestBody, + mediaType: 'application/json', + }); + } + + /** + * @throws ApiError + */ + public callWithWeirdParameterNames(data: TDataCallWithWeirdParameterNames): CancelablePromise { + const { + _default, + parameterCookie, + parameterForm, + parameterHeader, + parameterPath1, + parameterPath2, + parameterPath3, + parameterQuery, + requestBody, + } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + path: { + 'parameter.path.1': parameterPath1, + 'parameter-path-2': parameterPath2, + 'PARAMETER-PATH-3': parameterPath3, + }, + cookies: { + 'PARAMETER-COOKIE': parameterCookie, + }, + headers: { + 'parameter.header': parameterHeader, + }, + query: { + default: _default, + 'parameter-query': parameterQuery, + }, + formData: { + parameter_form: parameterForm, + }, + body: requestBody, + mediaType: 'application/json', + }); + } + + /** + * @throws ApiError + */ + public getCallWithOptionalParam(data: TDataGetCallWithOptionalParam): CancelablePromise { + const { parameter, requestBody } = data; + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/parameters/', + query: { + parameter, + }, + body: requestBody, + mediaType: 'application/json', + }); + } + + /** + * @throws ApiError + */ + public postCallWithOptionalParam(data: TDataPostCallWithOptionalParam): CancelablePromise { + const { parameter, requestBody } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/parameters/', + query: { + parameter, + }, + body: requestBody, + mediaType: 'application/json', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/RequestBodyService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/RequestBodyService.ts.snap new file mode 100644 index 000000000..08aa2f001 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/RequestBodyService.ts.snap @@ -0,0 +1,34 @@ +import type { ModelWithString } from '../models/ModelWithString'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataPostApiRequestBody = { + /** + * A reusable request body + */ + foo?: ModelWithString; + /** + * This is a reusable parameter + */ + parameter?: string; +}; + +export class RequestBodyService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @throws ApiError + */ + public postApiRequestBody(data: TDataPostApiRequestBody = {}): CancelablePromise { + const { foo, parameter } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/requestBody/', + query: { + parameter, + }, + body: foo, + mediaType: 'application/json', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/ResponseService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/ResponseService.ts.snap new file mode 100644 index 000000000..8b23c0982 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/ResponseService.ts.snap @@ -0,0 +1,76 @@ +import type { ModelThatExtends } from '../models/ModelThatExtends'; +import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; +import type { ModelWithString } from '../models/ModelWithString'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class ResponseService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns number Response is a simple number + * @returns void Success + * @throws ApiError + */ + public callWithResponseAndNoContentResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + }); + } + + /** + * @returns ModelWithString + * @throws ApiError + */ + public callWithResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/response', + }); + } + + /** + * @returns ModelWithString Message for default response + * @throws ApiError + */ + public callWithDuplicateResponses(): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/response', + errors: { + 500: `Message for 500 error`, + 501: `Message for 501 error`, + 502: `Message for 502 error`, + }, + }); + } + + /** + * @returns any Message for 200 response + * @returns ModelWithString Message for default response + * @returns ModelThatExtends Message for 201 response + * @returns ModelThatExtendsExtends Message for 202 response + * @throws ApiError + */ + public callWithResponses(): CancelablePromise< + | { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + } + | ModelWithString + | ModelThatExtends + | ModelThatExtendsExtends + > { + return this.httpRequest.request({ + method: 'PUT', + url: '/api/v{api-version}/response', + errors: { + 500: `Message for 500 error`, + 501: `Message for 501 error`, + 502: `Message for 502 error`, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/SimpleService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/SimpleService.ts.snap new file mode 100644 index 000000000..85bee6b61 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/SimpleService.ts.snap @@ -0,0 +1,76 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class SimpleService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @throws ApiError + */ + public getCallWithoutParametersAndResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/simple', + }); + } + + /** + * @throws ApiError + */ + public putCallWithoutParametersAndResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/api/v{api-version}/simple', + }); + } + + /** + * @throws ApiError + */ + public postCallWithoutParametersAndResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/simple', + }); + } + + /** + * @throws ApiError + */ + public deleteCallWithoutParametersAndResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/api/v{api-version}/simple', + }); + } + + /** + * @throws ApiError + */ + public optionsCallWithoutParametersAndResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'OPTIONS', + url: '/api/v{api-version}/simple', + }); + } + + /** + * @throws ApiError + */ + public headCallWithoutParametersAndResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'HEAD', + url: '/api/v{api-version}/simple', + }); + } + + /** + * @throws ApiError + */ + public patchCallWithoutParametersAndResponse(): CancelablePromise { + return this.httpRequest.request({ + method: 'PATCH', + url: '/api/v{api-version}/simple', + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/TypesService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/TypesService.ts.snap new file mode 100644 index 000000000..cbbee1f64 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/TypesService.ts.snap @@ -0,0 +1,77 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataTypes = { + /** + * This is a number parameter + */ + id?: number; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a boolean parameter + */ + parameterBoolean?: boolean | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: Record | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + /** + * This is a number parameter + */ + parameterNumber?: number; + /** + * This is an object parameter + */ + parameterObject?: Record | null; + /** + * This is a string parameter + */ + parameterString?: string | null; +}; + +export class TypesService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns number Response is a simple number + * @returns string Response is a simple string + * @returns boolean Response is a simple boolean + * @returns unknown Response is a simple object + * @throws ApiError + */ + public types(data: TDataTypes): CancelablePromise> { + const { + id, + parameterArray, + parameterBoolean = true, + parameterDictionary, + parameterEnum, + parameterNumber = 123, + parameterObject = null, + parameterString = 'default', + } = data; + return this.httpRequest.request({ + method: 'GET', + url: '/api/v{api-version}/types', + path: { + id, + }, + query: { + parameterNumber, + parameterString, + parameterBoolean, + parameterObject, + parameterArray, + parameterDictionary, + parameterEnum, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/UploadService.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/UploadService.ts.snap new file mode 100644 index 000000000..3d49884ab --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/UploadService.ts.snap @@ -0,0 +1,28 @@ +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export type TDataUploadFile = { + /** + * Supply a file reference for upload + */ + file: Blob; +}; + +export class UploadService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * @returns boolean + * @throws ApiError + */ + public uploadFile(data: TDataUploadFile): CancelablePromise { + const { file } = data; + return this.httpRequest.request({ + method: 'POST', + url: '/api/v{api-version}/upload', + formData: { + file, + }, + }); + } +} diff --git a/test/__snapshots__/v3-client/test/generated/v3_client/services/index.ts.snap b/test/__snapshots__/v3-client/test/generated/v3_client/services/index.ts.snap new file mode 100644 index 000000000..3243a2fb1 --- /dev/null +++ b/test/__snapshots__/v3-client/test/generated/v3_client/services/index.ts.snap @@ -0,0 +1,23 @@ +export { CollectionFormatService } from './CollectionFormatService'; +export { ComplexService } from './ComplexService'; +export { DefaultService } from './DefaultService'; +export { DefaultsService } from './DefaultsService'; +export { DeprecatedService } from './DeprecatedService'; +export { DescriptionsService } from './DescriptionsService'; +export { DuplicateService } from './DuplicateService'; +export { ErrorService } from './ErrorService'; +export { FileResponseService } from './FileResponseService'; +export { FormDataService } from './FormDataService'; +export { HeaderService } from './HeaderService'; +export { MultipartService } from './MultipartService'; +export { MultipleTags1Service } from './MultipleTags1Service'; +export { MultipleTags2Service } from './MultipleTags2Service'; +export { MultipleTags3Service } from './MultipleTags3Service'; +export { NoContentService } from './NoContentService'; +export { NonAsciiÆøåÆøÅöôêÊService } from './NonAsciiÆøåÆøÅöôêÊService'; +export { ParametersService } from './ParametersService'; +export { RequestBodyService } from './RequestBodyService'; +export { ResponseService } from './ResponseService'; +export { SimpleService } from './SimpleService'; +export { TypesService } from './TypesService'; +export { UploadService } from './UploadService'; diff --git a/test/__snapshots__/v3-date/test/generated/v3_date/index.ts.snap b/test/__snapshots__/v3-date/test/generated/v3_date/index.ts.snap index 347c02309..9545f7d9c 100644 --- a/test/__snapshots__/v3-date/test/generated/v3_date/index.ts.snap +++ b/test/__snapshots__/v3-date/test/generated/v3_date/index.ts.snap @@ -1,3 +1,2 @@ -export type { ModelWithPattern } from './models/ModelWithPattern'; - -export { $ModelWithPattern } from './schemas/$ModelWithPattern'; +export * from './models'; +export * from './schemas'; diff --git a/test/__snapshots__/v3-date/test/generated/v3_date/models/index.ts.snap b/test/__snapshots__/v3-date/test/generated/v3_date/models/index.ts.snap new file mode 100644 index 000000000..6d4078ffe --- /dev/null +++ b/test/__snapshots__/v3-date/test/generated/v3_date/models/index.ts.snap @@ -0,0 +1 @@ +export type { ModelWithPattern } from './ModelWithPattern'; diff --git a/test/__snapshots__/v3-date/test/generated/v3_date/schemas/index.ts.snap b/test/__snapshots__/v3-date/test/generated/v3_date/schemas/index.ts.snap new file mode 100644 index 000000000..11e8b2ecf --- /dev/null +++ b/test/__snapshots__/v3-date/test/generated/v3_date/schemas/index.ts.snap @@ -0,0 +1 @@ +export { $ModelWithPattern } from './$ModelWithPattern'; diff --git a/test/__snapshots__/v3-options/test/generated/v3_options/index.ts.snap b/test/__snapshots__/v3-options/test/generated/v3_options/index.ts.snap index 37c5eab68..adb5e2405 100644 --- a/test/__snapshots__/v3-options/test/generated/v3_options/index.ts.snap +++ b/test/__snapshots__/v3-options/test/generated/v3_options/index.ts.snap @@ -3,6 +3,5 @@ export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI } from './core/OpenAPI'; export type { OpenAPIConfig } from './core/OpenAPI'; -export type { ModelWithString } from './models/ModelWithString'; - -export { DefaultsService } from './services/DefaultsService'; +export * from './models'; +export * from './services'; diff --git a/test/__snapshots__/v3-options/test/generated/v3_options/models/index.ts.snap b/test/__snapshots__/v3-options/test/generated/v3_options/models/index.ts.snap new file mode 100644 index 000000000..6e2cfa4d4 --- /dev/null +++ b/test/__snapshots__/v3-options/test/generated/v3_options/models/index.ts.snap @@ -0,0 +1 @@ +export type { ModelWithString } from './ModelWithString'; diff --git a/test/__snapshots__/v3-options/test/generated/v3_options/services/index.ts.snap b/test/__snapshots__/v3-options/test/generated/v3_options/services/index.ts.snap new file mode 100644 index 000000000..94bf72bbd --- /dev/null +++ b/test/__snapshots__/v3-options/test/generated/v3_options/services/index.ts.snap @@ -0,0 +1 @@ +export { DefaultsService } from './DefaultsService'; diff --git a/test/__snapshots__/v3/test/generated/v3/index.ts.snap b/test/__snapshots__/v3/test/generated/v3/index.ts.snap index 7bcc38a4b..2c5a14f44 100644 --- a/test/__snapshots__/v3/test/generated/v3/index.ts.snap +++ b/test/__snapshots__/v3/test/generated/v3/index.ts.snap @@ -3,224 +3,6 @@ export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI } from './core/OpenAPI'; export type { OpenAPIConfig } from './core/OpenAPI'; -export type { _default } from './models/_default'; -export type { AnyOfAnyAndNull } from './models/AnyOfAnyAndNull'; -export type { AnyOfArrays } from './models/AnyOfArrays'; -export type { ArrayWithAnyOfProperties } from './models/ArrayWithAnyOfProperties'; -export type { ArrayWithArray } from './models/ArrayWithArray'; -export type { ArrayWithBooleans } from './models/ArrayWithBooleans'; -export type { ArrayWithNumbers } from './models/ArrayWithNumbers'; -export type { ArrayWithProperties } from './models/ArrayWithProperties'; -export type { ArrayWithReferences } from './models/ArrayWithReferences'; -export type { ArrayWithStrings } from './models/ArrayWithStrings'; -export type { CommentWithBackticks } from './models/CommentWithBackticks'; -export type { CommentWithBreaks } from './models/CommentWithBreaks'; -export type { CommentWithExpressionPlaceholders } from './models/CommentWithExpressionPlaceholders'; -export type { CommentWithQuotes } from './models/CommentWithQuotes'; -export type { CommentWithReservedCharacters } from './models/CommentWithReservedCharacters'; -export type { CommentWithSlashes } from './models/CommentWithSlashes'; -export type { CompositionBaseModel } from './models/CompositionBaseModel'; -export type { CompositionExtendedModel } from './models/CompositionExtendedModel'; -export type { CompositionWithAllOfAndNullable } from './models/CompositionWithAllOfAndNullable'; -export type { CompositionWithAnyOf } from './models/CompositionWithAnyOf'; -export type { CompositionWithAnyOfAndNullable } from './models/CompositionWithAnyOfAndNullable'; -export type { CompositionWithAnyOfAnonymous } from './models/CompositionWithAnyOfAnonymous'; -export type { CompositionWithNestedAnyAndTypeNull } from './models/CompositionWithNestedAnyAndTypeNull'; -export type { CompositionWithNestedAnyOfAndNull } from './models/CompositionWithNestedAnyOfAndNull'; -export type { CompositionWithOneOf } from './models/CompositionWithOneOf'; -export type { CompositionWithOneOfAndComplexArrayDictionary } from './models/CompositionWithOneOfAndComplexArrayDictionary'; -export type { CompositionWithOneOfAndNullable } from './models/CompositionWithOneOfAndNullable'; -export type { CompositionWithOneOfAndProperties } from './models/CompositionWithOneOfAndProperties'; -export type { CompositionWithOneOfAndSimpleArrayDictionary } from './models/CompositionWithOneOfAndSimpleArrayDictionary'; -export type { CompositionWithOneOfAndSimpleDictionary } from './models/CompositionWithOneOfAndSimpleDictionary'; -export type { CompositionWithOneOfAnonymous } from './models/CompositionWithOneOfAnonymous'; -export type { CompositionWithOneOfDiscriminator } from './models/CompositionWithOneOfDiscriminator'; -export type { ConstValue } from './models/ConstValue'; -export type { DeprecatedModel } from './models/DeprecatedModel'; -export type { DictionaryWithArray } from './models/DictionaryWithArray'; -export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; -export type { DictionaryWithProperties } from './models/DictionaryWithProperties'; -export type { DictionaryWithReference } from './models/DictionaryWithReference'; -export type { DictionaryWithString } from './models/DictionaryWithString'; -export type { Enum1 } from './models/Enum1'; -export { Enum1Enum } from './models/Enum1'; -export type { EnumFromDescription } from './models/EnumFromDescription'; -export type { EnumWithExtensions } from './models/EnumWithExtensions'; -export { EnumWithExtensionsEnum } from './models/EnumWithExtensions'; -export type { EnumWithNumbers } from './models/EnumWithNumbers'; -export { EnumWithNumbersEnum } from './models/EnumWithNumbers'; -export type { EnumWithReplacedCharacters } from './models/EnumWithReplacedCharacters'; -export { EnumWithReplacedCharactersEnum } from './models/EnumWithReplacedCharacters'; -export type { EnumWithStrings } from './models/EnumWithStrings'; -export { EnumWithStringsEnum } from './models/EnumWithStrings'; -export type { File } from './models/File'; -export type { FreeFormObjectWithAdditionalPropertiesEqEmptyObject } from './models/FreeFormObjectWithAdditionalPropertiesEqEmptyObject'; -export type { FreeFormObjectWithAdditionalPropertiesEqTrue } from './models/FreeFormObjectWithAdditionalPropertiesEqTrue'; -export type { FreeFormObjectWithoutAdditionalProperties } from './models/FreeFormObjectWithoutAdditionalProperties'; -export type { ModelCircle } from './models/ModelCircle'; -export type { ModelSquare } from './models/ModelSquare'; -export type { ModelThatExtends } from './models/ModelThatExtends'; -export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; -export type { ModelWithAdditionalPropertiesEqTrue } from './models/ModelWithAdditionalPropertiesEqTrue'; -export type { ModelWithArray } from './models/ModelWithArray'; -export type { ModelWithArrayReadOnlyAndWriteOnly } from './models/ModelWithArrayReadOnlyAndWriteOnly'; -export type { ModelWithBoolean } from './models/ModelWithBoolean'; -export type { ModelWithCircularReference } from './models/ModelWithCircularReference'; -export type { ModelWithConst } from './models/ModelWithConst'; -export type { ModelWithDictionary } from './models/ModelWithDictionary'; -export type { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; -export type { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; -export type { ModelWithEnum } from './models/ModelWithEnum'; -export { TestEnum, StatusCodeEnum } from './models/ModelWithEnum'; -export type { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; -export type { ModelWithEnumWithHyphen } from './models/ModelWithEnumWithHyphen'; -export { FooBarBazQuxEnum } from './models/ModelWithEnumWithHyphen'; -export type { ModelWithInteger } from './models/ModelWithInteger'; -export type { ModelWithNestedArrayEnums } from './models/ModelWithNestedArrayEnums'; -export type { ModelWithNestedArrayEnumsData } from './models/ModelWithNestedArrayEnumsData'; -export type { ModelWithNestedArrayEnumsDataBar } from './models/ModelWithNestedArrayEnumsDataBar'; -export { ModelWithNestedArrayEnumsDataBarEnum } from './models/ModelWithNestedArrayEnumsDataBar'; -export type { ModelWithNestedArrayEnumsDataFoo } from './models/ModelWithNestedArrayEnumsDataFoo'; -export { ModelWithNestedArrayEnumsDataFooEnum } from './models/ModelWithNestedArrayEnumsDataFoo'; -export type { ModelWithNestedCompositionEnums } from './models/ModelWithNestedCompositionEnums'; -export type { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; -export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; -export type { ModelWithNullableObject } from './models/ModelWithNullableObject'; -export type { ModelWithNullableString } from './models/ModelWithNullableString'; -export type { ModelWithOneOfEnum } from './models/ModelWithOneOfEnum'; -export { FooEnum } from './models/ModelWithOneOfEnum'; -export type { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties'; -export type { ModelWithPattern } from './models/ModelWithPattern'; -export type { ModelWithProperties } from './models/ModelWithProperties'; -export type { ModelWithReadOnlyAndWriteOnly } from './models/ModelWithReadOnlyAndWriteOnly'; -export type { ModelWithReference } from './models/ModelWithReference'; -export type { ModelWithString } from './models/ModelWithString'; -export type { NestedAnyOfArraysNullable } from './models/NestedAnyOfArraysNullable'; -export type { NonAsciiStringæøåÆØÅöôêÊ字符串 } from './models/NonAsciiStringæøåÆØÅöôêÊ字符串'; -export type { NullableObject } from './models/NullableObject'; -export type { Pageable } from './models/Pageable'; -export type { SimpleBoolean } from './models/SimpleBoolean'; -export type { SimpleFile } from './models/SimpleFile'; -export type { SimpleInteger } from './models/SimpleInteger'; -export type { SimpleParameter } from './models/SimpleParameter'; -export type { SimpleReference } from './models/SimpleReference'; -export type { SimpleString } from './models/SimpleString'; -export type { SimpleStringWithPattern } from './models/SimpleStringWithPattern'; - -export { $_default } from './schemas/$_default'; -export { $AnyOfAnyAndNull } from './schemas/$AnyOfAnyAndNull'; -export { $AnyOfArrays } from './schemas/$AnyOfArrays'; -export { $ArrayWithAnyOfProperties } from './schemas/$ArrayWithAnyOfProperties'; -export { $ArrayWithArray } from './schemas/$ArrayWithArray'; -export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans'; -export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers'; -export { $ArrayWithProperties } from './schemas/$ArrayWithProperties'; -export { $ArrayWithReferences } from './schemas/$ArrayWithReferences'; -export { $ArrayWithStrings } from './schemas/$ArrayWithStrings'; -export { $CommentWithBackticks } from './schemas/$CommentWithBackticks'; -export { $CommentWithBreaks } from './schemas/$CommentWithBreaks'; -export { $CommentWithExpressionPlaceholders } from './schemas/$CommentWithExpressionPlaceholders'; -export { $CommentWithQuotes } from './schemas/$CommentWithQuotes'; -export { $CommentWithReservedCharacters } from './schemas/$CommentWithReservedCharacters'; -export { $CommentWithSlashes } from './schemas/$CommentWithSlashes'; -export { $CompositionBaseModel } from './schemas/$CompositionBaseModel'; -export { $CompositionExtendedModel } from './schemas/$CompositionExtendedModel'; -export { $CompositionWithAllOfAndNullable } from './schemas/$CompositionWithAllOfAndNullable'; -export { $CompositionWithAnyOf } from './schemas/$CompositionWithAnyOf'; -export { $CompositionWithAnyOfAndNullable } from './schemas/$CompositionWithAnyOfAndNullable'; -export { $CompositionWithAnyOfAnonymous } from './schemas/$CompositionWithAnyOfAnonymous'; -export { $CompositionWithNestedAnyAndTypeNull } from './schemas/$CompositionWithNestedAnyAndTypeNull'; -export { $CompositionWithNestedAnyOfAndNull } from './schemas/$CompositionWithNestedAnyOfAndNull'; -export { $CompositionWithOneOf } from './schemas/$CompositionWithOneOf'; -export { $CompositionWithOneOfAndComplexArrayDictionary } from './schemas/$CompositionWithOneOfAndComplexArrayDictionary'; -export { $CompositionWithOneOfAndNullable } from './schemas/$CompositionWithOneOfAndNullable'; -export { $CompositionWithOneOfAndProperties } from './schemas/$CompositionWithOneOfAndProperties'; -export { $CompositionWithOneOfAndSimpleArrayDictionary } from './schemas/$CompositionWithOneOfAndSimpleArrayDictionary'; -export { $CompositionWithOneOfAndSimpleDictionary } from './schemas/$CompositionWithOneOfAndSimpleDictionary'; -export { $CompositionWithOneOfAnonymous } from './schemas/$CompositionWithOneOfAnonymous'; -export { $CompositionWithOneOfDiscriminator } from './schemas/$CompositionWithOneOfDiscriminator'; -export { $ConstValue } from './schemas/$ConstValue'; -export { $DeprecatedModel } from './schemas/$DeprecatedModel'; -export { $DictionaryWithArray } from './schemas/$DictionaryWithArray'; -export { $DictionaryWithDictionary } from './schemas/$DictionaryWithDictionary'; -export { $DictionaryWithProperties } from './schemas/$DictionaryWithProperties'; -export { $DictionaryWithReference } from './schemas/$DictionaryWithReference'; -export { $DictionaryWithString } from './schemas/$DictionaryWithString'; -export { $Enum1 } from './schemas/$Enum1'; -export { $EnumFromDescription } from './schemas/$EnumFromDescription'; -export { $EnumWithExtensions } from './schemas/$EnumWithExtensions'; -export { $EnumWithNumbers } from './schemas/$EnumWithNumbers'; -export { $EnumWithReplacedCharacters } from './schemas/$EnumWithReplacedCharacters'; -export { $EnumWithStrings } from './schemas/$EnumWithStrings'; -export { $File } from './schemas/$File'; -export { $FreeFormObjectWithAdditionalPropertiesEqEmptyObject } from './schemas/$FreeFormObjectWithAdditionalPropertiesEqEmptyObject'; -export { $FreeFormObjectWithAdditionalPropertiesEqTrue } from './schemas/$FreeFormObjectWithAdditionalPropertiesEqTrue'; -export { $FreeFormObjectWithoutAdditionalProperties } from './schemas/$FreeFormObjectWithoutAdditionalProperties'; -export { $ModelCircle } from './schemas/$ModelCircle'; -export { $ModelSquare } from './schemas/$ModelSquare'; -export { $ModelThatExtends } from './schemas/$ModelThatExtends'; -export { $ModelThatExtendsExtends } from './schemas/$ModelThatExtendsExtends'; -export { $ModelWithAdditionalPropertiesEqTrue } from './schemas/$ModelWithAdditionalPropertiesEqTrue'; -export { $ModelWithArray } from './schemas/$ModelWithArray'; -export { $ModelWithArrayReadOnlyAndWriteOnly } from './schemas/$ModelWithArrayReadOnlyAndWriteOnly'; -export { $ModelWithBoolean } from './schemas/$ModelWithBoolean'; -export { $ModelWithCircularReference } from './schemas/$ModelWithCircularReference'; -export { $ModelWithConst } from './schemas/$ModelWithConst'; -export { $ModelWithDictionary } from './schemas/$ModelWithDictionary'; -export { $ModelWithDuplicateImports } from './schemas/$ModelWithDuplicateImports'; -export { $ModelWithDuplicateProperties } from './schemas/$ModelWithDuplicateProperties'; -export { $ModelWithEnum } from './schemas/$ModelWithEnum'; -export { $ModelWithEnumFromDescription } from './schemas/$ModelWithEnumFromDescription'; -export { $ModelWithEnumWithHyphen } from './schemas/$ModelWithEnumWithHyphen'; -export { $ModelWithInteger } from './schemas/$ModelWithInteger'; -export { $ModelWithNestedArrayEnums } from './schemas/$ModelWithNestedArrayEnums'; -export { $ModelWithNestedArrayEnumsData } from './schemas/$ModelWithNestedArrayEnumsData'; -export { $ModelWithNestedArrayEnumsDataBar } from './schemas/$ModelWithNestedArrayEnumsDataBar'; -export { $ModelWithNestedArrayEnumsDataFoo } from './schemas/$ModelWithNestedArrayEnumsDataFoo'; -export { $ModelWithNestedCompositionEnums } from './schemas/$ModelWithNestedCompositionEnums'; -export { $ModelWithNestedEnums } from './schemas/$ModelWithNestedEnums'; -export { $ModelWithNestedProperties } from './schemas/$ModelWithNestedProperties'; -export { $ModelWithNullableObject } from './schemas/$ModelWithNullableObject'; -export { $ModelWithNullableString } from './schemas/$ModelWithNullableString'; -export { $ModelWithOneOfEnum } from './schemas/$ModelWithOneOfEnum'; -export { $ModelWithOrderedProperties } from './schemas/$ModelWithOrderedProperties'; -export { $ModelWithPattern } from './schemas/$ModelWithPattern'; -export { $ModelWithProperties } from './schemas/$ModelWithProperties'; -export { $ModelWithReadOnlyAndWriteOnly } from './schemas/$ModelWithReadOnlyAndWriteOnly'; -export { $ModelWithReference } from './schemas/$ModelWithReference'; -export { $ModelWithString } from './schemas/$ModelWithString'; -export { $NestedAnyOfArraysNullable } from './schemas/$NestedAnyOfArraysNullable'; -export { $NonAsciiStringæøåÆØÅöôêÊ字符串 } from './schemas/$NonAsciiStringæøåÆØÅöôêÊ字符串'; -export { $NullableObject } from './schemas/$NullableObject'; -export { $Pageable } from './schemas/$Pageable'; -export { $SimpleBoolean } from './schemas/$SimpleBoolean'; -export { $SimpleFile } from './schemas/$SimpleFile'; -export { $SimpleInteger } from './schemas/$SimpleInteger'; -export { $SimpleParameter } from './schemas/$SimpleParameter'; -export { $SimpleReference } from './schemas/$SimpleReference'; -export { $SimpleString } from './schemas/$SimpleString'; -export { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern'; - -export { CollectionFormatService } from './services/CollectionFormatService'; -export { ComplexService } from './services/ComplexService'; -export { DefaultService } from './services/DefaultService'; -export { DefaultsService } from './services/DefaultsService'; -export { DeprecatedService } from './services/DeprecatedService'; -export { DescriptionsService } from './services/DescriptionsService'; -export { DuplicateService } from './services/DuplicateService'; -export { ErrorService } from './services/ErrorService'; -export { FileResponseService } from './services/FileResponseService'; -export { FormDataService } from './services/FormDataService'; -export { HeaderService } from './services/HeaderService'; -export { MultipartService } from './services/MultipartService'; -export { MultipleTags1Service } from './services/MultipleTags1Service'; -export { MultipleTags2Service } from './services/MultipleTags2Service'; -export { MultipleTags3Service } from './services/MultipleTags3Service'; -export { NoContentService } from './services/NoContentService'; -export { NonAsciiÆøåÆøÅöôêÊService } from './services/NonAsciiÆøåÆøÅöôêÊService'; -export { ParametersService } from './services/ParametersService'; -export { RequestBodyService } from './services/RequestBodyService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; -export { UploadService } from './services/UploadService'; +export * from './models'; +export * from './schemas'; +export * from './services'; diff --git a/test/__snapshots__/v3/test/generated/v3/models/index.ts.snap b/test/__snapshots__/v3/test/generated/v3/models/index.ts.snap new file mode 100644 index 000000000..b07b74bc1 --- /dev/null +++ b/test/__snapshots__/v3/test/generated/v3/models/index.ts.snap @@ -0,0 +1,103 @@ +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 type { Enum1 } from './Enum1'; +export { Enum1Enum } from './Enum1'; +export type { EnumFromDescription } from './EnumFromDescription'; +export type { EnumWithExtensions } from './EnumWithExtensions'; +export { EnumWithExtensionsEnum } from './EnumWithExtensions'; +export type { EnumWithNumbers } from './EnumWithNumbers'; +export { EnumWithNumbersEnum } from './EnumWithNumbers'; +export type { EnumWithReplacedCharacters } from './EnumWithReplacedCharacters'; +export { EnumWithReplacedCharactersEnum } from './EnumWithReplacedCharacters'; +export type { EnumWithStrings } from './EnumWithStrings'; +export { EnumWithStringsEnum } from './EnumWithStrings'; +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 { TestEnum, StatusCodeEnum } from './ModelWithEnum'; +export type { ModelWithEnumFromDescription } from './ModelWithEnumFromDescription'; +export type { ModelWithEnumWithHyphen } from './ModelWithEnumWithHyphen'; +export { FooBarBazQuxEnum } from './ModelWithEnumWithHyphen'; +export type { ModelWithInteger } from './ModelWithInteger'; +export type { ModelWithNestedArrayEnums } from './ModelWithNestedArrayEnums'; +export type { ModelWithNestedArrayEnumsData } from './ModelWithNestedArrayEnumsData'; +export type { ModelWithNestedArrayEnumsDataBar } from './ModelWithNestedArrayEnumsDataBar'; +export { ModelWithNestedArrayEnumsDataBarEnum } from './ModelWithNestedArrayEnumsDataBar'; +export type { ModelWithNestedArrayEnumsDataFoo } from './ModelWithNestedArrayEnumsDataFoo'; +export { ModelWithNestedArrayEnumsDataFooEnum } from './ModelWithNestedArrayEnumsDataFoo'; +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 { FooEnum } 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'; diff --git a/test/__snapshots__/v3/test/generated/v3/schemas/index.ts.snap b/test/__snapshots__/v3/test/generated/v3/schemas/index.ts.snap new file mode 100644 index 000000000..0b903c2d7 --- /dev/null +++ b/test/__snapshots__/v3/test/generated/v3/schemas/index.ts.snap @@ -0,0 +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 { $Enum1 } from './$Enum1'; +export { $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 { $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'; diff --git a/test/__snapshots__/v3/test/generated/v3/services/index.ts.snap b/test/__snapshots__/v3/test/generated/v3/services/index.ts.snap new file mode 100644 index 000000000..3243a2fb1 --- /dev/null +++ b/test/__snapshots__/v3/test/generated/v3/services/index.ts.snap @@ -0,0 +1,23 @@ +export { CollectionFormatService } from './CollectionFormatService'; +export { ComplexService } from './ComplexService'; +export { DefaultService } from './DefaultService'; +export { DefaultsService } from './DefaultsService'; +export { DeprecatedService } from './DeprecatedService'; +export { DescriptionsService } from './DescriptionsService'; +export { DuplicateService } from './DuplicateService'; +export { ErrorService } from './ErrorService'; +export { FileResponseService } from './FileResponseService'; +export { FormDataService } from './FormDataService'; +export { HeaderService } from './HeaderService'; +export { MultipartService } from './MultipartService'; +export { MultipleTags1Service } from './MultipleTags1Service'; +export { MultipleTags2Service } from './MultipleTags2Service'; +export { MultipleTags3Service } from './MultipleTags3Service'; +export { NoContentService } from './NoContentService'; +export { NonAsciiÆøåÆøÅöôêÊService } from './NonAsciiÆøåÆøÅöôêÊService'; +export { ParametersService } from './ParametersService'; +export { RequestBodyService } from './RequestBodyService'; +export { ResponseService } from './ResponseService'; +export { SimpleService } from './SimpleService'; +export { TypesService } from './TypesService'; +export { UploadService } from './UploadService'; diff --git a/test/index.spec.ts b/test/index.spec.ts index 8e1c045d2..371f68d1e 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -85,4 +85,25 @@ describe('v3', () => { expect(content).toMatchFileSnapshot(`./__snapshots__/v3-options/${file}.snap`); }); }); + + it('should generate a client', async () => { + await createClient({ + client: 'fetch', + enums: true, + exportCore: true, + exportModels: true, + exportSchemas: false, + exportServices: true, + input: './test/spec/v3.json', + output: './test/generated/v3_client/', + useDateType: true, + useOptions: true, + name: 'ApiClient', + }); + + sync('./test/generated/v3_client/**/*.ts').forEach(file => { + const content = readFileSync(file, 'utf8').toString(); + expect(content).toMatchFileSnapshot(`./__snapshots__/v3-client/${file}.snap`); + }); + }); });