From 412ed5ebcc78830202b8ccb346d408989342079f Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Mon, 1 Jun 2026 15:17:26 +0200 Subject: [PATCH 01/11] feat(mock): add arrayItems faker option for reusable array item mocks Expose exported getMock factories for object-like array item schemas in operation responses so consumers can reuse item-level fakers outside of full response mocks. Closes #3513. Co-authored-by: Cursor --- docs/content/docs/guides/faker.mdx | 37 ++++ packages/core/src/types.ts | 4 + .../faker/getters/array-item-factory.test.ts | 160 ++++++++++++++++++ .../src/faker/getters/array-item-factory.ts | 160 ++++++++++++++++++ packages/mock/src/faker/getters/object.ts | 1 + packages/mock/src/faker/getters/scalar.ts | 18 +- packages/mock/src/types.ts | 1 + .../mock/faker-array-items/endpoints.ts | 76 +++++++++ .../faker-array-items/model/getTenants200.ts | 12 ++ .../model/getTenants200ValueItem.ts | 11 ++ .../mock/faker-array-items/model/index.ts | 11 ++ .../model/tenantListResponse.ts | 12 ++ .../model/tenantResponseModelDto.ts | 11 ++ tests/configs/mock.config.ts | 15 ++ tests/specifications/faker-array-items.yaml | 73 ++++++++ 15 files changed, 601 insertions(+), 1 deletion(-) create mode 100644 packages/mock/src/faker/getters/array-item-factory.test.ts create mode 100644 packages/mock/src/faker/getters/array-item-factory.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/endpoints.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getTenants200.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getTenants200ValueItem.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/index.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/tenantListResponse.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/tenantResponseModelDto.ts create mode 100644 tests/specifications/faker-array-items.yaml diff --git a/docs/content/docs/guides/faker.mdx b/docs/content/docs/guides/faker.mdx index 96efe54c61..20e6d39bef 100644 --- a/docs/content/docs/guides/faker.mdx +++ b/docs/content/docs/guides/faker.mdx @@ -106,6 +106,42 @@ If an operation- or tag-level `override.mock` rule targets a property of a refer Requires `output.schemas` to be configured (the consolidated file is written into that directory). +### Array Item Factories + +Set `arrayItems: true` to emit reusable mock factories for **object-like array item schemas** found in operation responses. This covers array elements that are inlined in the response body (not just entries under `components/schemas`): + +```ts title="orval.config.ts" +mock: { + generators: [ + { + type: 'faker', + arrayItems: true, + }, + ], +} +``` + +For a paginated list response like `{ value: TenantResponseModelDto[], count: number }`, Orval emits both the operation factory and a reusable item factory: + +```ts +export const getTenantResponseModelDtoMock = ( + overrideResponse: Partial = {}, +): TenantResponseModelDto => ({ /* ... */, ...overrideResponse }); + +export const getGetTenantsByRefResponseMock = ( + overrideResponse: Partial = {}, +): TenantListResponse => ({ + value: Array.from(/* ... */).map(() => ({ ...getTenantResponseModelDtoMock() })), + count: faker.number.int(), + ...overrideResponse, +}); +``` + +- **`$ref` array items** → `getMock` (shared across operations referencing the same schema). +- **Inline object array items** → `getResponseItemMock` typed as `Item` (matching Orval's generated item type aliases). + +When `schemas: true` is also enabled, `$ref` items delegate to the consolidated schema factory instead (same as today). `arrayItems` is useful when item types only appear inside response wrappers or when you want item factories without emitting every `components/schemas` entry. + ## Options Set faker-specific options on the generator entry: @@ -132,6 +168,7 @@ mock: { | `preferredContentType` | `string` | — | When an operation has multiple response content types, mock the one matching this MIME type. | | `schemas` | `boolean` | `false` | Emit a consolidated `getMock` factory per `components/schemas` entry into `/index.faker.ts`. See [Schema Factories](#schema-factories). | | `operationResponses` | `boolean` | `true` | Emit per-operation `getResponseMock` factories. Set to `false` (typically with `schemas: true`) to skip operation-level factories. | +| `arrayItems` | `boolean` | `false` | Emit reusable mock factories for object-like array item schemas in operation responses. See [Array Item Factories](#array-item-factories). | ## Customizing Mock Values diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 4ea422e625..2dc8f18ef0 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -479,6 +479,10 @@ export interface FakerMockOptions extends CommonMockOptions { // Defaults to `true`. Set to `false` together with `schemas: true` to get // only the consolidated schema factories. operationResponses?: boolean; + // Emit reusable mock factories for object-like array item schemas found in + // operation responses (e.g. `getTenantResponseModelDtoMock` for + // `value: TenantResponseModelDto[]`). Defaults to `false`. + arrayItems?: boolean; } export type GlobalMockOptions = MswMockOptions | FakerMockOptions; diff --git a/packages/mock/src/faker/getters/array-item-factory.test.ts b/packages/mock/src/faker/getters/array-item-factory.test.ts new file mode 100644 index 0000000000..6499bfb24a --- /dev/null +++ b/packages/mock/src/faker/getters/array-item-factory.test.ts @@ -0,0 +1,160 @@ +import type { ContextSpec } from '@orval/core'; +import { describe, expect, it } from 'vitest'; + +import { + extractArrayItemMock, + shouldExtractArrayItemFactories, +} from './array-item-factory'; + +const contextWithArrayItems = { + output: { + mock: { + generators: [{ type: 'faker', arrayItems: true }], + }, + override: { + components: { schemas: { suffix: '', itemSuffix: 'Item' } }, + }, + }, +} as unknown as ContextSpec; + +const contextWithoutArrayItems = { + output: { + mock: { + generators: [{ type: 'faker' }], + }, + override: { + components: { schemas: { suffix: '', itemSuffix: 'Item' } }, + }, + }, +} as unknown as ContextSpec; + +describe('shouldExtractArrayItemFactories', () => { + it('returns true when arrayItems is enabled', () => { + expect(shouldExtractArrayItemFactories(contextWithArrayItems)).toBe(true); + }); + + it('returns false when arrayItems is not enabled', () => { + expect(shouldExtractArrayItemFactories(contextWithoutArrayItems)).toBe( + false, + ); + }); +}); + +describe('extractArrayItemMock', () => { + it('extracts a reusable factory for $ref array items', () => { + const splitMockImplementations: string[] = []; + const imports: Parameters[0]['imports'] = []; + + const call = extractArrayItemMock({ + items: { $ref: '#/components/schemas/TenantResponseModelDto' }, + propertyName: 'value', + operationId: 'getTenantsByRef', + mapValue: + '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}', + context: contextWithArrayItems, + splitMockImplementations, + imports, + }); + + expect(call).toBe('{...getTenantResponseModelDtoMock()}'); + expect(splitMockImplementations).toHaveLength(1); + expect(splitMockImplementations[0]).toContain( + 'export const getTenantResponseModelDtoMock', + ); + expect(splitMockImplementations[0]).toContain( + 'Partial', + ); + expect(imports).toEqual([{ name: 'TenantResponseModelDto' }]); + }); + + it('extracts a reusable factory for inline object array items', () => { + const splitMockImplementations: string[] = []; + + const call = extractArrayItemMock({ + items: { + type: 'object', + properties: { + id: { type: 'string' }, + name: { type: 'string' }, + }, + }, + propertyName: 'value', + parentName: 'GetTenants200', + operationId: 'getTenants', + mapValue: + '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}', + context: contextWithArrayItems, + splitMockImplementations, + imports: [], + }); + + expect(call).toBe('{...getGetTenantsResponseValueItemMock()}'); + expect(splitMockImplementations[0]).toContain( + 'export const getGetTenantsResponseValueItemMock', + ); + expect(splitMockImplementations[0]).toContain( + 'Partial', + ); + }); + + it('deduplicates factories with the same name', () => { + const splitMockImplementations: string[] = []; + const mapValue = + '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}'; + + extractArrayItemMock({ + items: { $ref: '#/components/schemas/TenantResponseModelDto' }, + propertyName: 'value', + operationId: 'getTenantsByRef', + mapValue, + context: contextWithArrayItems, + splitMockImplementations, + imports: [], + }); + extractArrayItemMock({ + items: { $ref: '#/components/schemas/TenantResponseModelDto' }, + propertyName: 'items', + operationId: 'getTenantsByRef', + mapValue, + context: contextWithArrayItems, + splitMockImplementations, + imports: [], + }); + + expect(splitMockImplementations).toHaveLength(1); + }); + + it('skips primitive array items', () => { + const splitMockImplementations: string[] = []; + + const call = extractArrayItemMock({ + items: { type: 'string' }, + propertyName: 'tags', + operationId: 'getTenants', + mapValue: 'faker.string.alpha({length: {min: 10, max: 20}})', + context: contextWithArrayItems, + splitMockImplementations, + imports: [], + }); + + expect(call).toBeUndefined(); + expect(splitMockImplementations).toHaveLength(0); + }); + + it('skips when the value already delegates to a factory', () => { + const splitMockImplementations: string[] = []; + + const call = extractArrayItemMock({ + items: { $ref: '#/components/schemas/TenantResponseModelDto' }, + propertyName: 'value', + operationId: 'getTenantsByRef', + mapValue: '{...getTenantResponseModelDtoMock()}', + context: contextWithArrayItems, + splitMockImplementations, + imports: [], + }); + + expect(call).toBeUndefined(); + expect(splitMockImplementations).toHaveLength(0); + }); +}); diff --git a/packages/mock/src/faker/getters/array-item-factory.ts b/packages/mock/src/faker/getters/array-item-factory.ts new file mode 100644 index 0000000000..0f293b0a86 --- /dev/null +++ b/packages/mock/src/faker/getters/array-item-factory.ts @@ -0,0 +1,160 @@ +import { + type ContextSpec, + type GeneratorImport, + getRefInfo, + isFunction, + isReference, + type OpenApiSchemaObject, + OutputMockType, + pascal, +} from '@orval/core'; + +import type { MockSchema } from '../../types'; +import { overrideVarName } from './object'; +import { extractItemsRef } from './scalar'; + +/** + * True when the active faker generator entry opts into reusable array-item + * mock factories for object-like array item schemas in operation responses. + */ +export function shouldExtractArrayItemFactories(context: ContextSpec): boolean { + const generators = context.output.mock?.generators; + if (!generators) { + return false; + } + + const fakerEntry = generators.find( + (g) => + !isFunction(g) && + g.type === OutputMockType.FAKER && + g.arrayItems === true, + ); + return !!fakerEntry; +} + +function isObjectLikeArrayItem(items: MockSchema): boolean { + if (isReference(items)) { + return true; + } + + const schema = items as OpenApiSchemaObject; + if (schema.type === 'object' || schema.properties) { + return true; + } + + if (schema.allOf || schema.oneOf || schema.anyOf) { + return true; + } + + return false; +} + +function isAlreadyFactoryCall(mapValue: string): boolean { + return /\bget\w+Mock\(\)/.test(mapValue); +} + +interface ArrayItemFactoryNames { + factoryName: string; + typeName: string; +} + +function getArrayItemFactoryNames({ + items, + propertyName, + parentName, + operationId, + context, +}: { + items: MockSchema; + propertyName: string; + parentName?: string; + operationId: string; + context: ContextSpec; +}): ArrayItemFactoryNames | undefined { + const itemsRef = extractItemsRef(items); + if (itemsRef) { + const { name } = getRefInfo(itemsRef, context); + const typeName = pascal(name); + return { + factoryName: `get${typeName}Mock`, + typeName, + }; + } + + if (!isObjectLikeArrayItem(items)) { + return undefined; + } + + const itemSuffix = context.output.override.components.schemas.itemSuffix; + const typeName = parentName + ? `${pascal(parentName)}${pascal(propertyName)}${itemSuffix}` + : `${pascal(operationId)}${pascal(propertyName)}${itemSuffix}`; + return { + factoryName: `get${pascal(operationId)}Response${pascal(propertyName)}ItemMock`, + typeName, + }; +} + +interface ExtractArrayItemMockOptions { + items: MockSchema; + propertyName: string; + parentName?: string; + operationId: string; + mapValue: string; + context: ContextSpec; + splitMockImplementations: string[]; + imports: GeneratorImport[]; +} + +/** + * When `arrayItems: true`, lift an object-like array item mock body into a + * reusable exported factory and return the call site expression for `.map()`. + */ +export function extractArrayItemMock({ + items, + propertyName, + parentName, + operationId, + mapValue, + context, + splitMockImplementations, + imports, +}: ExtractArrayItemMockOptions): string | undefined { + if (!shouldExtractArrayItemFactories(context)) { + return undefined; + } + + if (!mapValue || mapValue === '[]' || isAlreadyFactoryCall(mapValue)) { + return undefined; + } + + const names = getArrayItemFactoryNames({ + items, + propertyName, + parentName, + operationId, + context, + }); + if (!names) { + return undefined; + } + + const { factoryName, typeName } = names; + + if ( + !splitMockImplementations.some((f) => + f.includes(`export const ${factoryName}`), + ) + ) { + const args = `${overrideVarName}: Partial<${typeName}> = {}`; + const spreadPrefix = mapValue.startsWith('...') ? '' : '...'; + const func = + `export const ${factoryName} = (${args}): ${typeName} => ` + + `({${spreadPrefix}${mapValue}, ...${overrideVarName}});`; + splitMockImplementations.push(func); + } + + imports.push({ name: typeName }); + + return `{...${factoryName}()}`; +} diff --git a/packages/mock/src/faker/getters/object.ts b/packages/mock/src/faker/getters/object.ts index cc0e43238b..487cd5ad02 100644 --- a/packages/mock/src/faker/getters/object.ts +++ b/packages/mock/src/faker/getters/object.ts @@ -181,6 +181,7 @@ export function getMockObject({ schema: { ...(prop as Record), name: key, + parentName: schemaItem.name, path: schemaItem.path ? `${schemaItem.path}.${key}` : `#.${key}`, }, mockOptions, diff --git a/packages/mock/src/faker/getters/scalar.ts b/packages/mock/src/faker/getters/scalar.ts index a9d053b8c4..0d238156c6 100644 --- a/packages/mock/src/faker/getters/scalar.ts +++ b/packages/mock/src/faker/getters/scalar.ts @@ -26,6 +26,7 @@ import { resolveMockValue, } from '../resolvers'; import { getMockObject } from './object'; +import { extractArrayItemMock } from './array-item-factory'; interface GetMockScalarOptions { item: MockSchemaObject; @@ -314,6 +315,7 @@ export function getMockScalar({ schema: { ...resolvedItems, name: item.name, + parentName: item.parentName, path: item.path ? `${item.path}.[]` : '#.[]', }, combine, @@ -336,6 +338,20 @@ export function getMockScalar({ let mapValue = value; + const extractedItemCall = extractArrayItemMock({ + items: resolvedItems, + propertyName: item.name, + parentName: item.parentName, + operationId, + mapValue, + context, + splitMockImplementations, + imports: resolvedImports, + }); + if (extractedItemCall) { + mapValue = extractedItemCall; + } + if ( combine && !value.startsWith('faker') && @@ -513,7 +529,7 @@ export function getMockScalar({ // Returns the $ref string from array `items` — either direct ($ref on items // itself) or wrapped in a single-element allOf/oneOf/anyOf composition. // Multi-element compositions return undefined to preserve combine semantics. -function extractItemsRef(items: MockSchema): string | undefined { +export function extractItemsRef(items: MockSchema): string | undefined { if (isReference(items)) { return items.$ref; } diff --git a/packages/mock/src/types.ts b/packages/mock/src/types.ts index 070569169d..34f7312e68 100644 --- a/packages/mock/src/types.ts +++ b/packages/mock/src/types.ts @@ -24,6 +24,7 @@ export type MockSchemaRef = OpenApiReferenceObject; export type MockSchemaObject = Omit & { name: string; path?: string; + parentName?: string; isRef?: boolean; enum?: string[]; }; diff --git a/tests/__snapshots__/mock/faker-array-items/endpoints.ts b/tests/__snapshots__/mock/faker-array-items/endpoints.ts new file mode 100644 index 0000000000..c16baf2f84 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/endpoints.ts @@ -0,0 +1,76 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ +import axios from 'axios'; +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; + +import type { GetTenants200, TenantListResponse } from './model'; + +import { faker } from '@faker-js/faker'; + +import type { GetTenants200ValueItem, TenantResponseModelDto } from './model'; + +export const getFakerArrayItemFactories = ( + axiosInstance: AxiosInstance = axios, +) => { + const getTenants = ( + options?: AxiosRequestConfig, + ): Promise> => { + return axiosInstance.get(`/tenants`, options); + }; + + const getTenantsByRef = ( + options?: AxiosRequestConfig, + ): Promise> => { + return axiosInstance.get(`/tenants-by-ref`, options); + }; + + return { getTenants, getTenantsByRef }; +}; +export type GetTenantsResult = AxiosResponse; +export type GetTenantsByRefResult = AxiosResponse; + +export const getGetTenantsResponseValueItemMock = ( + overrideResponse: Partial = {}, +): GetTenants200ValueItem => ({ + ...{ + id: faker.string.uuid(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}); + +export const getGetTenantsResponseMock = ( + overrideResponse: Partial> = {}, +): GetTenants200 => ({ + value: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ ...getGetTenantsResponseValueItemMock() })), + count: faker.number.int(), + ...overrideResponse, +}); + +export const getTenantResponseModelDtoMock = ( + overrideResponse: Partial = {}, +): TenantResponseModelDto => ({ + ...{ + id: faker.string.uuid(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}); + +export const getGetTenantsByRefResponseMock = ( + overrideResponse: Partial> = {}, +): TenantListResponse => ({ + value: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ ...getTenantResponseModelDtoMock() })), + count: faker.number.int(), + ...overrideResponse, +}); diff --git a/tests/__snapshots__/mock/faker-array-items/model/getTenants200.ts b/tests/__snapshots__/mock/faker-array-items/model/getTenants200.ts new file mode 100644 index 0000000000..d2b4454d60 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getTenants200.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ +import type { GetTenants200ValueItem } from './getTenants200ValueItem'; + +export type GetTenants200 = { + value: GetTenants200ValueItem[]; + count: number; +}; diff --git a/tests/__snapshots__/mock/faker-array-items/model/getTenants200ValueItem.ts b/tests/__snapshots__/mock/faker-array-items/model/getTenants200ValueItem.ts new file mode 100644 index 0000000000..b4eaa9bb19 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getTenants200ValueItem.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ + +export type GetTenants200ValueItem = { + id: string; + name: string; +}; diff --git a/tests/__snapshots__/mock/faker-array-items/model/index.ts b/tests/__snapshots__/mock/faker-array-items/model/index.ts new file mode 100644 index 0000000000..a8a61bbc06 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/index.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ + +export * from './getTenants200'; +export * from './getTenants200ValueItem'; +export * from './tenantListResponse'; +export * from './tenantResponseModelDto'; diff --git a/tests/__snapshots__/mock/faker-array-items/model/tenantListResponse.ts b/tests/__snapshots__/mock/faker-array-items/model/tenantListResponse.ts new file mode 100644 index 0000000000..0e6f17d078 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/tenantListResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ +import type { TenantResponseModelDto } from './tenantResponseModelDto'; + +export interface TenantListResponse { + value: TenantResponseModelDto[]; + count: number; +} diff --git a/tests/__snapshots__/mock/faker-array-items/model/tenantResponseModelDto.ts b/tests/__snapshots__/mock/faker-array-items/model/tenantResponseModelDto.ts new file mode 100644 index 0000000000..e5f903add5 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/tenantResponseModelDto.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ + +export interface TenantResponseModelDto { + id: string; + name: string; +} diff --git a/tests/configs/mock.config.ts b/tests/configs/mock.config.ts index bf07024b85..e26e1a6c20 100644 --- a/tests/configs/mock.config.ts +++ b/tests/configs/mock.config.ts @@ -516,4 +516,19 @@ export default defineConfig({ target: '../specifications/issue-3484.yaml', }, }, + fakerArrayItems: { + output: { + target: '../generated/mock/faker-array-items/endpoints.ts', + schemas: '../generated/mock/faker-array-items/model', + client: 'axios', + mock: { + generators: [{ type: 'faker', arrayItems: true }], + }, + clean: true, + formatter: 'prettier', + }, + input: { + target: '../specifications/faker-array-items.yaml', + }, + }, }); diff --git a/tests/specifications/faker-array-items.yaml b/tests/specifications/faker-array-items.yaml new file mode 100644 index 0000000000..78a4c0d8e5 --- /dev/null +++ b/tests/specifications/faker-array-items.yaml @@ -0,0 +1,73 @@ +openapi: 3.0.3 +info: + title: Faker array item factories + version: 1.0.0 +paths: + /tenants: + get: + operationId: getTenants + tags: + - tenants + responses: + '200': + description: List tenants + content: + application/json: + schema: + type: object + required: + - value + - count + properties: + value: + type: array + items: + type: object + required: + - id + - name + properties: + id: + type: string + format: uuid + name: + type: string + count: + type: integer + /tenants-by-ref: + get: + operationId: getTenantsByRef + tags: + - tenants + responses: + '200': + description: List tenants by ref + content: + application/json: + schema: + $ref: '#/components/schemas/TenantListResponse' +components: + schemas: + TenantResponseModelDto: + type: object + required: + - id + - name + properties: + id: + type: string + format: uuid + name: + type: string + TenantListResponse: + type: object + required: + - value + - count + properties: + value: + type: array + items: + $ref: '#/components/schemas/TenantResponseModelDto' + count: + type: integer From ad803fd09d91361b2b782a5083532f72d1c2ff0a Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Mon, 1 Jun 2026 15:29:59 +0200 Subject: [PATCH 02/11] fix(mock): address PR review and lint failures for arrayItems Fix eslint issues, tighten factory-call detection, skip extraction when schemas: true already emits consolidated factories, and add regression tests. Co-authored-by: Cursor --- docs/content/docs/guides/faker.mdx | 2 +- .../faker/getters/array-item-factory.test.ts | 54 ++++++++++++++++ .../src/faker/getters/array-item-factory.ts | 61 ++++++++++++++++--- packages/mock/src/faker/getters/scalar.ts | 2 +- 4 files changed, 109 insertions(+), 10 deletions(-) diff --git a/docs/content/docs/guides/faker.mdx b/docs/content/docs/guides/faker.mdx index 20e6d39bef..76a83bf368 100644 --- a/docs/content/docs/guides/faker.mdx +++ b/docs/content/docs/guides/faker.mdx @@ -140,7 +140,7 @@ export const getGetTenantsByRefResponseMock = ( - **`$ref` array items** → `getMock` (shared across operations referencing the same schema). - **Inline object array items** → `getResponseItemMock` typed as `Item` (matching Orval's generated item type aliases). -When `schemas: true` is also enabled, `$ref` items delegate to the consolidated schema factory instead (same as today). `arrayItems` is useful when item types only appear inside response wrappers or when you want item factories without emitting every `components/schemas` entry. +When `schemas: true` is also enabled, `$ref` items delegate to the consolidated schema factory instead (same as today). `arrayItems` is useful when item types only appear inside response wrappers or when you want item factories without emitting every `components/schemas` entry. With both options enabled, `$ref` items are not re-exported from the operation mock file — import `getMock` from `/index.faker.ts` instead. ## Options diff --git a/packages/mock/src/faker/getters/array-item-factory.test.ts b/packages/mock/src/faker/getters/array-item-factory.test.ts index 6499bfb24a..18f0273a35 100644 --- a/packages/mock/src/faker/getters/array-item-factory.test.ts +++ b/packages/mock/src/faker/getters/array-item-factory.test.ts @@ -157,4 +157,58 @@ describe('extractArrayItemMock', () => { expect(call).toBeUndefined(); expect(splitMockImplementations).toHaveLength(0); }); + + it('does not treat nested factory calls as already delegating', () => { + const splitMockImplementations: string[] = []; + + const call = extractArrayItemMock({ + items: { + type: 'object', + properties: { + id: { type: 'string' }, + pet: { $ref: '#/components/schemas/Pet' }, + }, + }, + propertyName: 'value', + parentName: 'GetTenants200', + operationId: 'getTenants', + mapValue: + '{id: faker.string.uuid(), pet: {...getPetMock()}, name: faker.string.alpha({length: {min: 10, max: 20}})}', + context: contextWithArrayItems, + splitMockImplementations, + imports: [], + }); + + expect(call).toBe('{...getGetTenantsResponseValueItemMock()}'); + expect(splitMockImplementations).toHaveLength(1); + }); + + it('skips $ref components/schemas items when schemas: true emits consolidated factories', () => { + const splitMockImplementations: string[] = []; + const contextWithSchemas = { + output: { + schemas: './model', + mock: { + generators: [{ type: 'faker', arrayItems: true, schemas: true }], + }, + override: { + components: { schemas: { suffix: '', itemSuffix: 'Item' } }, + }, + }, + } as unknown as ContextSpec; + + const call = extractArrayItemMock({ + items: { $ref: '#/components/schemas/TenantResponseModelDto' }, + propertyName: 'value', + operationId: 'getTenantsByRef', + mapValue: + '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}', + context: contextWithSchemas, + splitMockImplementations, + imports: [], + }); + + expect(call).toBeUndefined(); + expect(splitMockImplementations).toHaveLength(0); + }); }); diff --git a/packages/mock/src/faker/getters/array-item-factory.ts b/packages/mock/src/faker/getters/array-item-factory.ts index 0f293b0a86..133f4cd5c4 100644 --- a/packages/mock/src/faker/getters/array-item-factory.ts +++ b/packages/mock/src/faker/getters/array-item-factory.ts @@ -18,12 +18,7 @@ import { extractItemsRef } from './scalar'; * mock factories for object-like array item schemas in operation responses. */ export function shouldExtractArrayItemFactories(context: ContextSpec): boolean { - const generators = context.output.mock?.generators; - if (!generators) { - return false; - } - - const fakerEntry = generators.find( + const fakerEntry = context.output.mock.generators.find( (g) => !isFunction(g) && g.type === OutputMockType.FAKER && @@ -32,6 +27,43 @@ export function shouldExtractArrayItemFactories(context: ContextSpec): boolean { return !!fakerEntry; } +/** + * True when `schemas: true` already emits a consolidated factory for this + * `$ref` item under `components/schemas`, so we must not re-export it from + * the operation mock file. + */ +function hasConsolidatedSchemaFactory( + items: MockSchema, + context: ContextSpec, +): boolean { + if (!context.output.schemas) { + return false; + } + + const itemsRef = extractItemsRef(items); + if (!itemsRef) { + return false; + } + + const { refPaths } = getRefInfo(itemsRef, context); + const isComponentsSchema = + Array.isArray(refPaths) && + refPaths[0] === 'components' && + refPaths[1] === 'schemas'; + + if (!isComponentsSchema) { + return false; + } + + return context.output.mock.generators.some( + (g) => + !isFunction(g) && g.type === OutputMockType.FAKER && g.schemas === true, + ); +} + +/** + * True when array `items` resolve to an object-like schema worth extracting. + */ function isObjectLikeArrayItem(items: MockSchema): boolean { if (isReference(items)) { return true; @@ -49,8 +81,13 @@ function isObjectLikeArrayItem(items: MockSchema): boolean { return false; } +/** + * True when `mapValue` is already a bare factory call or a single spread of one. + */ function isAlreadyFactoryCall(mapValue: string): boolean { - return /\bget\w+Mock\(\)/.test(mapValue); + return /^(?:\{\s*\.\.\.\s*get\w+Mock\(\)\s*\}|get\w+Mock\(\))$/.test( + mapValue.trim(), + ); } interface ArrayItemFactoryNames { @@ -58,6 +95,9 @@ interface ArrayItemFactoryNames { typeName: string; } +/** + * Derive the exported factory and TypeScript type names for an array item. + */ function getArrayItemFactoryNames({ items, propertyName, @@ -124,7 +164,12 @@ export function extractArrayItemMock({ return undefined; } - if (!mapValue || mapValue === '[]' || isAlreadyFactoryCall(mapValue)) { + if ( + !mapValue || + mapValue === '[]' || + isAlreadyFactoryCall(mapValue) || + hasConsolidatedSchemaFactory(items, context) + ) { return undefined; } diff --git a/packages/mock/src/faker/getters/scalar.ts b/packages/mock/src/faker/getters/scalar.ts index 0d238156c6..83cf79b5ba 100644 --- a/packages/mock/src/faker/getters/scalar.ts +++ b/packages/mock/src/faker/getters/scalar.ts @@ -25,8 +25,8 @@ import { resolveMockOverride, resolveMockValue, } from '../resolvers'; -import { getMockObject } from './object'; import { extractArrayItemMock } from './array-item-factory'; +import { getMockObject } from './object'; interface GetMockScalarOptions { item: MockSchemaObject; From 2fbccfe7ecc0258615358e9b67193e904ae87e2d Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Mon, 1 Jun 2026 15:37:00 +0200 Subject: [PATCH 03/11] fix(mock): use full ContextSpec in scalar tests for arrayItems guard Partial test contexts omitted mock, causing runtime failures when extractArrayItemMock runs during array scalar tests. Co-authored-by: Cursor --- .../mock/src/faker/getters/scalar.test.ts | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/packages/mock/src/faker/getters/scalar.test.ts b/packages/mock/src/faker/getters/scalar.test.ts index 37e02d046d..1641180a8d 100644 --- a/packages/mock/src/faker/getters/scalar.test.ts +++ b/packages/mock/src/faker/getters/scalar.test.ts @@ -2,8 +2,14 @@ import type { ContextSpec, OpenApiSchemaObjectType } from '@orval/core'; import { describe, expect, it } from 'vitest'; +import { createTestContextSpec } from '../../../../core/src/test-utils/context'; import { getMockScalar } from './scalar'; +const scalarContext = ( + override: Partial = {}, + output?: Partial, +) => createTestContextSpec({ override, output }); + describe('getMockScalar (int64 format handling)', () => { const baseArg = { item: { @@ -23,7 +29,7 @@ describe('getMockScalar (int64 format handling)', () => { it('should return faker.number.bigInt() when format is int64, useBigInt is true, and mockOptions.format.int64 is NOT specified', () => { const result = getMockScalar({ ...baseArg, - context: { output: { override: { useBigInt: true } } } as ContextSpec, + context: scalarContext({ useBigInt: true }), }); expect(result.value).toBe('faker.number.bigInt({min: 1, max: 100})'); @@ -32,7 +38,7 @@ describe('getMockScalar (int64 format handling)', () => { it('should return faker.number.int() when format is int64, useBigInt is false, and mockOptions.format.int64 is NOT specified', () => { const result = getMockScalar({ ...baseArg, - context: { output: { override: { useBigInt: false } } } as ContextSpec, + context: scalarContext({ useBigInt: false }), }); expect(result.value).toBe('faker.number.int({min: 1, max: 100})'); @@ -48,7 +54,7 @@ describe('getMockScalar (int64 format handling)', () => { int64: specified, }, }, - context: { output: { override: { useBigInt: true } } } as ContextSpec, + context: scalarContext({ useBigInt: true }), }); expect(result.value).toBe(specified); @@ -74,7 +80,7 @@ describe('getMockScalar (uint64 format handling)', () => { it('should return faker.number.bigInt() when format is uint64, useBigInt is true, and mockOptions.format.uint64 is NOT specified', () => { const result = getMockScalar({ ...baseArg, - context: { output: { override: { useBigInt: true } } } as ContextSpec, + context: scalarContext({ useBigInt: true }), }); expect(result.value).toBe('faker.number.bigInt({min: 1, max: 100})'); @@ -83,7 +89,7 @@ describe('getMockScalar (uint64 format handling)', () => { it('should return faker.number.int() when format is uint64, useBigInt is false, and mockOptions.format.uint64 is NOT specified', () => { const result = getMockScalar({ ...baseArg, - context: { output: { override: { useBigInt: false } } } as ContextSpec, + context: scalarContext({ useBigInt: false }), }); expect(result.value).toBe('faker.number.int({min: 1, max: 100})'); @@ -99,7 +105,7 @@ describe('getMockScalar (uint64 format handling)', () => { uint64: specified, }, }, - context: { output: { override: { useBigInt: true } } } as ContextSpec, + context: scalarContext({ useBigInt: true }), }); expect(result.value).toBe(specified); @@ -119,7 +125,7 @@ describe('getMockScalar (example handling with falsy values)', () => { existingReferencedProperties: [], splitMockImplementations: [], mockOptions: { useExamples: true }, - context: { output: { override: {} } } as ContextSpec, // TODO this should be: satisfies ContextSpec + context: scalarContext(), }; it('should return the example value when it is a false value', () => { @@ -153,17 +159,13 @@ describe('getMockScalar (example handling with falsy values)', () => { describe('getMockScalar (multipleOf handling)', () => { const createContext = ( packageJsonDeps?: Record, - ): ContextSpec => { - const context = { - output: { - override: {}, - ...(packageJsonDeps && { - packageJson: { dependencies: packageJsonDeps }, - }), - }, - } as ContextSpec; - return context; - }; + ): ContextSpec => + scalarContext( + {}, + packageJsonDeps + ? { packageJson: { dependencies: packageJsonDeps } } + : undefined, + ); const baseArg = { imports: [], @@ -321,7 +323,7 @@ describe('getMockScalar (nested arrays handling)', () => { tags: [], existingReferencedProperties: [], splitMockImplementations: [], - context: { output: { override: {} } } as ContextSpec, + context: scalarContext(), combine: { separator: 'anyOf' as const, includedProperties: [] }, }); // Should avoid putting Array.from in an object { @@ -343,7 +345,7 @@ describe('getMockScalar (nested arrays handling)', () => { tags: [], existingReferencedProperties: [], splitMockImplementations: [], - context: { output: { override: {} } } as ContextSpec, + context: scalarContext(), mockOptions: { arrayMin: 1, arrayMax: 5 }, }); @@ -358,7 +360,7 @@ describe('getMockScalar (undefined filtering)', () => { tags: [], existingReferencedProperties: [], splitMockImplementations: [], - context: { output: { override: {} } } as ContextSpec, + context: scalarContext(), }; it('should not include min/max when they are undefined for integer type', () => { @@ -652,7 +654,7 @@ describe('getMockScalar (exclusiveMinimum/exclusiveMaximum handling)', () => { tags: [], existingReferencedProperties: [], splitMockImplementations: [], - context: { output: { override: {} } } as ContextSpec, + context: scalarContext(), }; describe('OpenAPI 3.0 (boolean exclusiveMinimum/exclusiveMaximum)', () => { @@ -768,7 +770,7 @@ describe('getMockScalar (@-prefixed property names)', () => { tags: [], existingReferencedProperties: [], splitMockImplementations: [], - context: { output: { override: {} } } as ContextSpec, + context: scalarContext(), }; it('should preserve @type as a quoted property key in mock objects', () => { @@ -803,7 +805,7 @@ describe('getMockScalar (pattern-backed string escaping)', () => { tags: [], existingReferencedProperties: [], splitMockImplementations: [], - context: { output: { override: {} } } as ContextSpec, + context: scalarContext(), }); expect(result.value).toBe( @@ -823,7 +825,7 @@ describe('getMockScalar (pattern-backed string escaping)', () => { tags: [], existingReferencedProperties: [], splitMockImplementations: [], - context: { output: { override: {} } } as ContextSpec, + context: scalarContext(), }); expect(result.value).toBe( @@ -844,7 +846,7 @@ describe('getMockScalar (post-upgrader OAS 3.0 example handling)', () => { existingReferencedProperties: [], splitMockImplementations: [], mockOptions: { useExamples: true }, - context: { output: { override: {} } } as ContextSpec, + context: scalarContext(), }; it('uses examples[0] for a string property when useExamples is true', () => { @@ -868,7 +870,7 @@ describe('getMockScalar (array items $ref extraction and recursion guard)', () = tags: [], splitMockImplementations: [], existingReferencedProperties: ['Foo'], - context: { output: { override: {} } } as ContextSpec, + context: scalarContext(), }; it('returns [] when items.$ref is a circular reference', () => { From 80c1218edd2ec8f49afa9c282d9f0efc67eff3fa Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Mon, 1 Jun 2026 15:58:16 +0200 Subject: [PATCH 04/11] fix(core): consolidate schema type imports in single-mode mock output Merge mock-only schema types into the main import pass so single-file outputs do not emit duplicate import type lines from the same module. Co-authored-by: Cursor --- packages/core/src/writers/single-mode.ts | 25 ++++++++++++++++--- .../mock/faker-array-items/endpoints.ts | 9 ++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/packages/core/src/writers/single-mode.ts b/packages/core/src/writers/single-mode.ts index f1e7e5accb..294f628555 100644 --- a/packages/core/src/writers/single-mode.ts +++ b/packages/core/src/writers/single-mode.ts @@ -76,7 +76,26 @@ export async function writeSingleMode({ output.tsconfig, ); - const implementationImports = imports.filter((imp) => { + const implementationForImports = + implementationMock.length > 0 + ? `${implementation}\n${implementationMock}` + : implementation; + + const mergedImports = [...imports]; + for (const mockImport of importsMock) { + if ( + mergedImports.some( + (imp) => + imp.name === mockImport.name && + (imp.alias ?? '') === (mockImport.alias ?? ''), + ) + ) { + continue; + } + mergedImports.push(mockImport); + } + + const implementationImports = mergedImports.filter((imp) => { const searchWords = [imp.alias, imp.name] .filter((part): part is string => Boolean(part?.length)) .map((part) => escapeRegExp(part)) @@ -86,7 +105,7 @@ export async function writeSingleMode({ } return new RegExp(String.raw`\b(${searchWords})\b`, 'g').test( - implementation, + implementationForImports, ); }); @@ -125,7 +144,7 @@ export async function writeSingleMode({ data += builder.imports({ client: output.client, - implementation, + implementation: implementationForImports, imports: importsForBuilder, projectName, hasSchemaDir: !!output.schemas, diff --git a/tests/__snapshots__/mock/faker-array-items/endpoints.ts b/tests/__snapshots__/mock/faker-array-items/endpoints.ts index c16baf2f84..d2cfa1112a 100644 --- a/tests/__snapshots__/mock/faker-array-items/endpoints.ts +++ b/tests/__snapshots__/mock/faker-array-items/endpoints.ts @@ -7,12 +7,15 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { GetTenants200, TenantListResponse } from './model'; +import type { + GetTenants200, + GetTenants200ValueItem, + TenantListResponse, + TenantResponseModelDto, +} from './model'; import { faker } from '@faker-js/faker'; -import type { GetTenants200ValueItem, TenantResponseModelDto } from './model'; - export const getFakerArrayItemFactories = ( axiosInstance: AxiosInstance = axios, ) => { From 66d53ffcafc5f0feb0c45830c46f7468600ddf3a Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Mon, 1 Jun 2026 16:11:59 +0200 Subject: [PATCH 05/11] chore(tests): update snapshots for consolidated single-mode imports Refresh endpoint snapshots after single-mode mock import consolidation. Co-authored-by: Cursor --- .../angular/custom-client/endpoints.ts | 11 +- .../http-resource-zod-disabled/endpoints.ts | 15 +- .../angular/http-resource-zod/endpoints.ts | 15 +- .../angular/petstore/endpoints.ts | 6 +- .../angular/zod-schema-response/endpoints.ts | 6 +- .../axios/multi-arguments/endpoints.ts | 6 +- .../__snapshots__/axios/mutator/endpoints.ts | 6 +- .../__snapshots__/axios/petstore/endpoints.ts | 6 +- .../axios/zod-schema-response/endpoints.ts | 6 +- .../default/all-of-all-of/endpoints.ts | 3 +- .../default/all-of-strict/endpoints.ts | 4 +- .../default/combine-enum/combinedEnums.ts | 3 +- .../default/enums/native/endpoints.ts | 5 +- .../default/http-status-mocks/endpoints.ts | 7 +- .../default/nullable-oneof-enums/endpoints.ts | 3 +- .../default/one-of-nested/endpoints.ts | 13 +- .../__snapshots__/default/one-of/endpoints.ts | 4 +- .../default/petstore-transformer/endpoints.ts | 6 +- .../default/runtime-mock-delay/endpoints.ts | 6 +- .../form-data-optional-request/endpoints.ts | 4 +- .../form-data-with-custom-fetch/endpoints.ts | 4 +- .../endpoints.ts | 6 +- .../fetch/multi-arguments/endpoints.ts | 6 +- .../__snapshots__/fetch/mutator/endpoints.ts | 6 +- .../health/health.apis.ts | 7 + .../health/health.ts | 100 +++++ .../model/cat.ts | 12 + .../model/catType.ts | 12 + .../model/createPetsBody.ts | 11 + .../model/createPetsParams.ts | 20 + .../model/createPetsSort.ts | 16 + .../model/dachshund.ts | 12 + .../model/dachshundBreed.ts | 13 + .../model/dog.ts | 19 + .../model/dogType.ts | 12 + .../model/error.ts | 11 + .../model/index.ts | 26 ++ .../model/labradoodle.ts | 12 + .../model/labradoodleBreed.ts | 13 + .../model/listPetsParams.ts | 20 + .../model/listPetsSort.ts | 15 + .../model/pet.ts | 30 ++ .../model/petCallingCode.ts | 14 + .../model/petCountry.ts | 13 + .../model/petWithTag.ts | 12 + .../model/pets.ts | 9 + .../pets/pets.apis.ts | 15 + .../pets/pets.ts | 311 +++++++++++++++ .../petstore-url-matchers/endpoints.apis.ts | 17 + .../fetch/petstore-url-matchers/endpoints.ts | 362 ++++++++++++++++++ .../fetch/petstore-url-matchers/model/cat.ts | 12 + .../petstore-url-matchers/model/catType.ts | 12 + .../model/createPetsBody.ts | 11 + .../model/createPetsParams.ts | 20 + .../model/createPetsSort.ts | 16 + .../petstore-url-matchers/model/dachshund.ts | 12 + .../model/dachshundBreed.ts | 13 + .../fetch/petstore-url-matchers/model/dog.ts | 19 + .../petstore-url-matchers/model/dogType.ts | 12 + .../petstore-url-matchers/model/error.ts | 11 + .../petstore-url-matchers/model/index.ts | 26 ++ .../model/labradoodle.ts | 12 + .../model/labradoodleBreed.ts | 13 + .../model/listPetsParams.ts | 20 + .../model/listPetsSort.ts | 15 + .../fetch/petstore-url-matchers/model/pet.ts | 30 ++ .../model/petCallingCode.ts | 14 + .../petstore-url-matchers/model/petCountry.ts | 13 + .../petstore-url-matchers/model/petWithTag.ts | 12 + .../fetch/petstore-url-matchers/model/pets.ts | 9 + .../__snapshots__/fetch/petstore/endpoints.ts | 6 +- .../endpoints.ts | 4 +- .../discriminator-oneof-allof/endpoints.ts | 4 +- .../discriminator-oneof-union/endpoints.ts | 4 +- .../mock/issue-3200/endpoints.ts | 4 +- .../endpoints.ts | 4 +- .../endpoints.ts | 4 +- .../__snapshots__/mock/petstore/endpoints.ts | 6 +- .../mock/typelessEnum/typelessEnums.ts | 3 +- .../mock/zod-schema-response/endpoints.ts | 6 +- .../react-query/basic/endpoints.ts | 6 +- .../react-query/deprecated/endpoints.ts | 12 +- .../react-query/error-type/endpoints.ts | 6 +- .../form-data-with-hook/endpoints.ts | 4 +- .../form-data-with-mutator/endpoints.ts | 4 +- .../react-query/form-data/endpoints.ts | 4 +- .../endpoints.ts | 6 +- .../react-query/invalidates/endpoints.ts | 6 +- .../react-query/mockOverride/endpoints.ts | 6 +- .../react-query/mockWithoutDelay/endpoints.ts | 6 +- .../react-query/mutator-client/endpoints.ts | 6 +- .../mutator-multi-arguments/endpoints.ts | 6 +- .../react-query/mutator/endpoints.ts | 6 +- .../zod-schema-response/endpoints.ts | 6 +- .../endpoints.ts | 6 +- .../svelte-query/invalidates/endpoints.ts | 6 +- .../svelte-query/mutator/endpoints.ts | 6 +- .../svelte-query/petstore/endpoints.ts | 6 +- .../zod-schema-response/endpoints.ts | 6 +- .../swr/custom-client/endpoints.ts | 6 +- .../form-data-optional-request/endpoints.ts | 4 +- .../endpoints.ts | 6 +- tests/__snapshots__/swr/mutator/endpoints.ts | 6 +- tests/__snapshots__/swr/petstore/endpoints.ts | 6 +- .../swr/zod-schema-response/endpoints.ts | 6 +- .../all-params-optional/endpoints.ts | 6 +- .../endpoints.ts | 6 +- .../endpoints.ts | 6 +- .../vue-query/mutator/endpoints.ts | 6 +- .../vue-query/petstore/endpoints.ts | 6 +- .../url-encode-parameters/endpoints.ts | 6 +- .../zod-schema-response/endpoints.ts | 6 +- tests/__snapshots__/zod/petstore/endpoints.ts | 10 +- 113 files changed, 1653 insertions(+), 165 deletions(-) create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.apis.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/cat.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/catType.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsBody.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsParams.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsSort.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshund.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshundBreed.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dog.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dogType.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/error.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/index.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodle.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodleBreed.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsParams.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsSort.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pet.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCallingCode.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCountry.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petWithTag.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pets.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.apis.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/endpoints.apis.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/endpoints.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/cat.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/catType.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsBody.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsParams.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsSort.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/dachshund.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/dachshundBreed.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/dog.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/dogType.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/error.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/index.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodle.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodleBreed.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsParams.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsSort.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/pet.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/petCallingCode.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/petCountry.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/petWithTag.ts create mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/pets.ts diff --git a/tests/__snapshots__/angular/custom-client/endpoints.ts b/tests/__snapshots__/angular/custom-client/endpoints.ts index 26895f93f6..a91d0483d0 100644 --- a/tests/__snapshots__/angular/custom-client/endpoints.ts +++ b/tests/__snapshots__/angular/custom-client/endpoints.ts @@ -4,13 +4,20 @@ * Swagger Petstore * OpenAPI spec version: 1.0.0 */ -import { HttpClient } from '@angular/common/http'; +import { + HttpClient, + HttpResponse as AngularHttpResponse, +} from '@angular/common/http'; import { Injectable, inject } from '@angular/core'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -22,8 +29,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import listPetsMutator from '../../../mutators/custom-client-angular'; import createPetsMutator from '../../../mutators/custom-client-angular'; import showPetByIdMutator from '../../../mutators/custom-client-angular'; diff --git a/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts b/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts index 9c2a9612fa..31119776d2 100644 --- a/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts +++ b/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts @@ -37,11 +37,19 @@ import { Pets } from './model'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams } from './model'; +import { + map +} from 'rxjs'; + import { faker } from '@faker-js/faker'; @@ -54,13 +62,6 @@ import type { RequestHandlerOptions } from 'msw'; -import type { - Cat, - Dachshund, - Dog, - Labradoodle -} from './model'; - export type OrvalHttpResourceOptions = TOmitParse extends true ? Omit, 'parse'> : HttpResourceOptions; diff --git a/tests/__snapshots__/angular/http-resource-zod/endpoints.ts b/tests/__snapshots__/angular/http-resource-zod/endpoints.ts index 9c2a9612fa..31119776d2 100644 --- a/tests/__snapshots__/angular/http-resource-zod/endpoints.ts +++ b/tests/__snapshots__/angular/http-resource-zod/endpoints.ts @@ -37,11 +37,19 @@ import { Pets } from './model'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams } from './model'; +import { + map +} from 'rxjs'; + import { faker } from '@faker-js/faker'; @@ -54,13 +62,6 @@ import type { RequestHandlerOptions } from 'msw'; -import type { - Cat, - Dachshund, - Dog, - Labradoodle -} from './model'; - export type OrvalHttpResourceOptions = TOmitParse extends true ? Omit, 'parse'> : HttpResourceOptions; diff --git a/tests/__snapshots__/angular/petstore/endpoints.ts b/tests/__snapshots__/angular/petstore/endpoints.ts index 608ce620d2..8a8473203d 100644 --- a/tests/__snapshots__/angular/petstore/endpoints.ts +++ b/tests/__snapshots__/angular/petstore/endpoints.ts @@ -16,8 +16,12 @@ import { Injectable, inject } from '@angular/core'; import { Observable } from 'rxjs'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -29,8 +33,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - interface HttpClientOptions { readonly headers?: HttpHeaders | Record; readonly context?: HttpContext; diff --git a/tests/__snapshots__/angular/zod-schema-response/endpoints.ts b/tests/__snapshots__/angular/zod-schema-response/endpoints.ts index 541f17e0e4..49a934c68e 100644 --- a/tests/__snapshots__/angular/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/angular/zod-schema-response/endpoints.ts @@ -16,8 +16,12 @@ import { Injectable, inject } from '@angular/core'; import { Observable } from 'rxjs'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -29,8 +33,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - interface HttpClientOptions { readonly headers?: HttpHeaders | Record; readonly context?: HttpContext; diff --git a/tests/__snapshots__/axios/multi-arguments/endpoints.ts b/tests/__snapshots__/axios/multi-arguments/endpoints.ts index 160c03b9eb..4f22cb926e 100644 --- a/tests/__snapshots__/axios/multi-arguments/endpoints.ts +++ b/tests/__snapshots__/axios/multi-arguments/endpoints.ts @@ -5,8 +5,12 @@ * OpenAPI spec version: 1.0.0 */ import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -18,8 +22,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import listPetsMutator from '../../../mutators/multi-arguments'; import createPetsMutator from '../../../mutators/multi-arguments'; import showPetByIdMutator from '../../../mutators/multi-arguments'; diff --git a/tests/__snapshots__/axios/mutator/endpoints.ts b/tests/__snapshots__/axios/mutator/endpoints.ts index 72273d2258..6c5f6f22d6 100644 --- a/tests/__snapshots__/axios/mutator/endpoints.ts +++ b/tests/__snapshots__/axios/mutator/endpoints.ts @@ -5,8 +5,12 @@ * OpenAPI spec version: 1.0.0 */ import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -18,8 +22,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import listPetsMutator from '../../../mutators/custom-client'; import createPetsMutator from '../../../mutators/custom-client'; import type { BodyType as CreatePetsBodyType } from '../../../mutators/custom-client'; diff --git a/tests/__snapshots__/axios/petstore/endpoints.ts b/tests/__snapshots__/axios/petstore/endpoints.ts index 9e3a505241..203b3c43d7 100644 --- a/tests/__snapshots__/axios/petstore/endpoints.ts +++ b/tests/__snapshots__/axios/petstore/endpoints.ts @@ -8,8 +8,12 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -21,8 +25,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export const getSwaggerPetstore = (axiosInstance: AxiosInstance = axios) => { /** * @summary List all pets diff --git a/tests/__snapshots__/axios/zod-schema-response/endpoints.ts b/tests/__snapshots__/axios/zod-schema-response/endpoints.ts index 204d6688e8..6d42341db3 100644 --- a/tests/__snapshots__/axios/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/axios/zod-schema-response/endpoints.ts @@ -8,8 +8,12 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -21,8 +25,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export const getSwaggerPetstore = (axiosInstance: AxiosInstance = axios) => { /** * @summary List all pets diff --git a/tests/__snapshots__/default/all-of-all-of/endpoints.ts b/tests/__snapshots__/default/all-of-all-of/endpoints.ts index 8c8953d3d8..d8af822e71 100644 --- a/tests/__snapshots__/default/all-of-all-of/endpoints.ts +++ b/tests/__snapshots__/default/all-of-all-of/endpoints.ts @@ -7,6 +7,7 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; +import { NoteType } from './model'; import type { PrivateNote, SharedNote } from './model'; import { faker } from '@faker-js/faker'; @@ -14,8 +15,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import { NoteType } from './model'; - export const createSharedNote = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/default/all-of-strict/endpoints.ts b/tests/__snapshots__/default/all-of-strict/endpoints.ts index 087c476997..5478759283 100644 --- a/tests/__snapshots__/default/all-of-strict/endpoints.ts +++ b/tests/__snapshots__/default/all-of-strict/endpoints.ts @@ -6,13 +6,13 @@ */ import * as zod from 'zod'; +import type { PostFish200 } from './model'; + import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { PostFish200 } from './model'; - export const PostFishBody = zod .object({ name: zod.string(), diff --git a/tests/__snapshots__/default/combine-enum/combinedEnums.ts b/tests/__snapshots__/default/combine-enum/combinedEnums.ts index cd20d6cfa4..e29fee6710 100644 --- a/tests/__snapshots__/default/combine-enum/combinedEnums.ts +++ b/tests/__snapshots__/default/combine-enum/combinedEnums.ts @@ -7,6 +7,7 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; +import { Colors1, Colors2 } from './schemas'; import type { ColorObject } from './schemas'; import { faker } from '@faker-js/faker'; @@ -14,8 +15,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import { Colors1, Colors2 } from './schemas'; - /** * @summary sample colors */ diff --git a/tests/__snapshots__/default/enums/native/endpoints.ts b/tests/__snapshots__/default/enums/native/endpoints.ts index 60d583825a..a51d8a1796 100644 --- a/tests/__snapshots__/default/enums/native/endpoints.ts +++ b/tests/__snapshots__/default/enums/native/endpoints.ts @@ -8,12 +8,15 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import type { + Bulldog, CatDog, Dog, DogGroup, Duck, + RequiredBulldog, RequiredCat, RequiredDog, + RequiredSiamese, } from './model'; import { faker } from '@faker-js/faker'; @@ -21,8 +24,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Bulldog, RequiredBulldog, RequiredSiamese } from './model'; - /** * @summary sample cat */ diff --git a/tests/__snapshots__/default/http-status-mocks/endpoints.ts b/tests/__snapshots__/default/http-status-mocks/endpoints.ts index c703cbd233..ddd6d71121 100644 --- a/tests/__snapshots__/default/http-status-mocks/endpoints.ts +++ b/tests/__snapshots__/default/http-status-mocks/endpoints.ts @@ -8,8 +8,13 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -21,8 +26,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Error, Labradoodle } from './model'; - /** * @summary List all pets */ diff --git a/tests/__snapshots__/default/nullable-oneof-enums/endpoints.ts b/tests/__snapshots__/default/nullable-oneof-enums/endpoints.ts index 5ed4804a6b..9a8d00229d 100644 --- a/tests/__snapshots__/default/nullable-oneof-enums/endpoints.ts +++ b/tests/__snapshots__/default/nullable-oneof-enums/endpoints.ts @@ -8,6 +8,7 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; +import { BlankEnum, HelloEnum, NotNullEnum } from './model'; import type { Item1, Item3, @@ -21,8 +22,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import { BlankEnum, HelloEnum, NotNullEnum } from './model'; - export const getItems = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/default/one-of-nested/endpoints.ts b/tests/__snapshots__/default/one-of-nested/endpoints.ts index 6affe1499b..22c345de71 100644 --- a/tests/__snapshots__/default/one-of-nested/endpoints.ts +++ b/tests/__snapshots__/default/one-of-nested/endpoints.ts @@ -8,20 +8,19 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { Example } from './model'; - -import { faker } from '@faker-js/faker'; - -import { HttpResponse, http } from 'msw'; -import type { RequestHandlerOptions } from 'msw'; - import type { + Example, Example1, Example2, PointInFutureAbsolute, PointInFutureRelative, } from './model'; +import { faker } from '@faker-js/faker'; + +import { HttpResponse, http } from 'msw'; +import type { RequestHandlerOptions } from 'msw'; + export const example = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/default/one-of/endpoints.ts b/tests/__snapshots__/default/one-of/endpoints.ts index a25f07b8d2..3c315572b1 100644 --- a/tests/__snapshots__/default/one-of/endpoints.ts +++ b/tests/__snapshots__/default/one-of/endpoints.ts @@ -7,15 +7,13 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { Pet } from './model'; +import type { Cat, Pet } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat } from './model'; - /** * oneOf with nullable object. */ diff --git a/tests/__snapshots__/default/petstore-transformer/endpoints.ts b/tests/__snapshots__/default/petstore-transformer/endpoints.ts index 03ff64ff56..366659445f 100644 --- a/tests/__snapshots__/default/petstore-transformer/endpoints.ts +++ b/tests/__snapshots__/default/petstore-transformer/endpoints.ts @@ -8,8 +8,12 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -21,8 +25,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - /** * @summary List all pets */ diff --git a/tests/__snapshots__/default/runtime-mock-delay/endpoints.ts b/tests/__snapshots__/default/runtime-mock-delay/endpoints.ts index 08585f7e3d..074a0a6499 100644 --- a/tests/__snapshots__/default/runtime-mock-delay/endpoints.ts +++ b/tests/__snapshots__/default/runtime-mock-delay/endpoints.ts @@ -8,8 +8,12 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -21,8 +25,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, delay, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - /** * @summary List all pets */ diff --git a/tests/__snapshots__/fetch/form-data-optional-request/endpoints.ts b/tests/__snapshots__/fetch/form-data-optional-request/endpoints.ts index 43da987e60..48fbf9f8b2 100644 --- a/tests/__snapshots__/fetch/form-data-optional-request/endpoints.ts +++ b/tests/__snapshots__/fetch/form-data-optional-request/endpoints.ts @@ -4,15 +4,13 @@ * Swagger Petstore * OpenAPI spec version: 1.0.0 */ -import type { Error, Pet } from './model'; +import type { Error, Pet, PetBase, PetExtended } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { PetBase, PetExtended } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/fetch/form-data-with-custom-fetch/endpoints.ts b/tests/__snapshots__/fetch/form-data-with-custom-fetch/endpoints.ts index 565667060a..5d31cb0b9a 100644 --- a/tests/__snapshots__/fetch/form-data-with-custom-fetch/endpoints.ts +++ b/tests/__snapshots__/fetch/form-data-with-custom-fetch/endpoints.ts @@ -4,15 +4,13 @@ * Swagger Petstore * OpenAPI spec version: 1.0.0 */ -import type { Error, Pet } from './model'; +import type { Error, Pet, PetBase, PetExtended } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { PetBase, PetExtended } from './model'; - import { customFetch } from '../../../mutators/custom-fetch'; export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; diff --git a/tests/__snapshots__/fetch/include-http-status-return-type/endpoints.ts b/tests/__snapshots__/fetch/include-http-status-return-type/endpoints.ts index 32f63844c1..ceab8d557e 100644 --- a/tests/__snapshots__/fetch/include-http-status-return-type/endpoints.ts +++ b/tests/__snapshots__/fetch/include-http-status-return-type/endpoints.ts @@ -5,8 +5,12 @@ * OpenAPI spec version: 1.0.0 */ import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -18,8 +22,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export const getListPetsUrl = (params: ListPetsParams) => { const normalizedParams = new URLSearchParams(); diff --git a/tests/__snapshots__/fetch/multi-arguments/endpoints.ts b/tests/__snapshots__/fetch/multi-arguments/endpoints.ts index fbc6d06b4b..ee56d98e4c 100644 --- a/tests/__snapshots__/fetch/multi-arguments/endpoints.ts +++ b/tests/__snapshots__/fetch/multi-arguments/endpoints.ts @@ -5,9 +5,13 @@ * OpenAPI spec version: 1.0.0 */ import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -19,8 +23,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/fetch/mutator/endpoints.ts b/tests/__snapshots__/fetch/mutator/endpoints.ts index 27610b07ed..8728386981 100644 --- a/tests/__snapshots__/fetch/mutator/endpoints.ts +++ b/tests/__snapshots__/fetch/mutator/endpoints.ts @@ -5,9 +5,13 @@ * OpenAPI spec version: 1.0.0 */ import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -19,8 +23,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customFetch } from '../../../mutators/custom-fetch'; export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.apis.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.apis.ts new file mode 100644 index 0000000000..8d115700d6 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.apis.ts @@ -0,0 +1,7 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +export const healthCheckApi = /(.*)\/health$/; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.ts new file mode 100644 index 0000000000..d0c55c25d6 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.ts @@ -0,0 +1,100 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { Error } from '../model'; + +export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; +export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; +export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; +export type HTTPStatusCode4xx = + | 400 + | 401 + | 402 + | 403 + | 404 + | 405 + | 406 + | 407 + | 408 + | 409 + | 410 + | 411 + | 412 + | 413 + | 414 + | 415 + | 416 + | 417 + | 418 + | 419 + | 420 + | 421 + | 422 + | 423 + | 424 + | 426 + | 428 + | 429 + | 431 + | 451; +export type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511; +export type HTTPStatusCodes = + | HTTPStatusCode1xx + | HTTPStatusCode2xx + | HTTPStatusCode3xx + | HTTPStatusCode4xx + | HTTPStatusCode5xx; + +export type healthCheckResponse200 = { + data: string; + status: 200; +}; + +export type healthCheckResponseDefault = { + data: Error; + status: Exclude; +}; + +export type healthCheckResponseSuccess = healthCheckResponse200 & { + headers: Headers; +}; +export type healthCheckResponseError = healthCheckResponseDefault & { + headers: Headers; +}; + +export type healthCheckResponse = + | healthCheckResponseSuccess + | healthCheckResponseError; + +export const getHealthCheckUrl = () => { + return `/health`; +}; + +/** + * @summary health check + */ +export const healthCheck = async ( + options?: RequestInit, +): Promise => { + const res = await fetch(getHealthCheckUrl(), { + ...options, + method: 'GET', + }); + + const contentType = (res.headers.get('content-type') ?? '').toLowerCase(); + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: healthCheckResponse['data'] = body + ? contentType.includes('json') + ? JSON.parse(body) + : body + : {}; + return { + data, + status: res.status, + headers: res.headers, + } as healthCheckResponse; +}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/cat.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/cat.ts new file mode 100644 index 0000000000..12cb113fa5 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/cat.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { CatType } from './catType'; + +export interface Cat { + petsRequested?: number; + type: CatType; +} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/catType.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/catType.ts new file mode 100644 index 0000000000..3ffefb556b --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/catType.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type CatType = (typeof CatType)[keyof typeof CatType]; + +export const CatType = { + cat: 'cat', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsBody.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsBody.ts new file mode 100644 index 0000000000..66f5dcd899 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsBody.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type CreatePetsBody = { + name: string; + tag: string; +}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsParams.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsParams.ts new file mode 100644 index 0000000000..4866303333 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { CreatePetsSort } from './createPetsSort'; + +export type CreatePetsParams = { + /** + * How many items to return at one time (max 100) + */ + limit?: string; + /** + * Which property to sort by? + * Example: name sorts ASC while -name sorts DESC. + * + */ + sort: CreatePetsSort; +}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsSort.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsSort.ts new file mode 100644 index 0000000000..3fa8bf869a --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type CreatePetsSort = + (typeof CreatePetsSort)[keyof typeof CreatePetsSort]; + +export const CreatePetsSort = { + name: 'name', + '-name': '-name', + email: 'email', + '-email': '-email', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshund.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshund.ts new file mode 100644 index 0000000000..63f59b544c --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshund.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { DachshundBreed } from './dachshundBreed'; + +export interface Dachshund { + length: number; + breed: DachshundBreed; +} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshundBreed.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshundBreed.ts new file mode 100644 index 0000000000..cb96ff6641 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshundBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type DachshundBreed = + (typeof DachshundBreed)[keyof typeof DachshundBreed]; + +export const DachshundBreed = { + Dachshund: 'Dachshund', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dog.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dog.ts new file mode 100644 index 0000000000..edf04cb115 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dog.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { Dachshund } from './dachshund'; +import type { DogType } from './dogType'; +import type { Labradoodle } from './labradoodle'; + +export type Dog = + | (Labradoodle & { + barksPerMinute?: number; + type: DogType; + }) + | (Dachshund & { + barksPerMinute?: number; + type: DogType; + }); diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dogType.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dogType.ts new file mode 100644 index 0000000000..b7344d0cc0 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dogType.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type DogType = (typeof DogType)[keyof typeof DogType]; + +export const DogType = { + dog: 'dog', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/error.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/error.ts new file mode 100644 index 0000000000..b0a03afbfd --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/error.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export interface Error { + code: number; + message: string; +} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/index.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/index.ts new file mode 100644 index 0000000000..ff7af2b0b2 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/index.ts @@ -0,0 +1,26 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export * from './cat'; +export * from './catType'; +export * from './createPetsBody'; +export * from './createPetsParams'; +export * from './createPetsSort'; +export * from './dachshund'; +export * from './dachshundBreed'; +export * from './dog'; +export * from './dogType'; +export * from './error'; +export * from './labradoodle'; +export * from './labradoodleBreed'; +export * from './listPetsParams'; +export * from './listPetsSort'; +export * from './pet'; +export * from './petCallingCode'; +export * from './petCountry'; +export * from './pets'; +export * from './petWithTag'; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodle.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodle.ts new file mode 100644 index 0000000000..359008145c --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodle.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { LabradoodleBreed } from './labradoodleBreed'; + +export interface Labradoodle { + cuteness: number; + breed: LabradoodleBreed; +} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodleBreed.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodleBreed.ts new file mode 100644 index 0000000000..804aa239e7 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodleBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type LabradoodleBreed = + (typeof LabradoodleBreed)[keyof typeof LabradoodleBreed]; + +export const LabradoodleBreed = { + Labradoodle: 'Labradoodle', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsParams.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsParams.ts new file mode 100644 index 0000000000..f8a26309de --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { ListPetsSort } from './listPetsSort'; + +export type ListPetsParams = { + /** + * How many items to return at one time (max 100) + */ + limit?: string; + /** + * Which property to sort by? + * Example: name sorts ASC while -name sorts DESC. + * + */ + sort: ListPetsSort; +}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsSort.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsSort.ts new file mode 100644 index 0000000000..d334807265 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsSort.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type ListPetsSort = (typeof ListPetsSort)[keyof typeof ListPetsSort]; + +export const ListPetsSort = { + name: 'name', + '-name': '-name', + email: 'email', + '-email': '-email', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pet.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pet.ts new file mode 100644 index 0000000000..9892066bae --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pet.ts @@ -0,0 +1,30 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { Cat } from './cat'; +import type { Dog } from './dog'; +import type { PetCallingCode } from './petCallingCode'; +import type { PetCountry } from './petCountry'; + +export type Pet = + | (Dog & { + '@id'?: string; + id: number; + name: string; + tag?: string; + email?: string; + callingCode?: PetCallingCode; + country?: PetCountry; + }) + | (Cat & { + '@id'?: string; + id: number; + name: string; + tag?: string; + email?: string; + callingCode?: PetCallingCode; + country?: PetCountry; + }); diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCallingCode.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCallingCode.ts new file mode 100644 index 0000000000..8c936dc7bf --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCallingCode.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type PetCallingCode = + (typeof PetCallingCode)[keyof typeof PetCallingCode]; + +export const PetCallingCode = { + '+33': '+33', + '+420': '+420', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCountry.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCountry.ts new file mode 100644 index 0000000000..16ff760582 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCountry.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry]; + +export const PetCountry = { + "People's_Republic_of_China": "People's Republic of China", + Uruguay: 'Uruguay', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petWithTag.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petWithTag.ts new file mode 100644 index 0000000000..89d5b99af4 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petWithTag.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { Pet } from './pet'; + +export interface PetWithTag { + tag: string; + pet: Pet | null; +} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pets.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pets.ts new file mode 100644 index 0000000000..bd8268ca60 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pets.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { Pet } from './pet'; + +export type Pets = Pet[]; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.apis.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.apis.ts new file mode 100644 index 0000000000..c68219cf2f --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.apis.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +export const createPetsApi = /(.*)\/pets(\?.*)?$/; + +export const deletePetByIdApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)$/; + +export const listPetsApi = /(.*)\/pets(\?.*)?$/; + +export const showPetByIdApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)$/; + +export const showPetWithOwnerApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)\/owner$/; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.ts new file mode 100644 index 0000000000..6224094fb7 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.ts @@ -0,0 +1,311 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { + CreatePetsBody, + CreatePetsParams, + Error, + ListPetsParams, + Pet, + PetWithTag, + Pets, +} from '../model'; + +export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; +export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; +export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; +export type HTTPStatusCode4xx = + | 400 + | 401 + | 402 + | 403 + | 404 + | 405 + | 406 + | 407 + | 408 + | 409 + | 410 + | 411 + | 412 + | 413 + | 414 + | 415 + | 416 + | 417 + | 418 + | 419 + | 420 + | 421 + | 422 + | 423 + | 424 + | 426 + | 428 + | 429 + | 431 + | 451; +export type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511; +export type HTTPStatusCodes = + | HTTPStatusCode1xx + | HTTPStatusCode2xx + | HTTPStatusCode3xx + | HTTPStatusCode4xx + | HTTPStatusCode5xx; + +export type listPetsResponse200 = { + data: Pets; + status: 200; +}; + +export type listPetsResponseDefault = { + data: Error; + status: Exclude; +}; + +export type listPetsResponseSuccess = listPetsResponse200 & { + headers: Headers; +}; +export type listPetsResponseError = listPetsResponseDefault & { + headers: Headers; +}; + +export type listPetsResponse = listPetsResponseSuccess | listPetsResponseError; + +export const getListPetsUrl = (params: ListPetsParams) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : String(value)); + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/pets`; +}; + +/** + * @summary List all pets + */ +export const listPets = async ( + params: ListPetsParams, + options?: RequestInit, +): Promise => { + const res = await fetch(getListPetsUrl(params), { + ...options, + method: 'GET', + }); + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: listPetsResponse['data'] = body ? JSON.parse(body) : {}; + return { data, status: res.status, headers: res.headers } as listPetsResponse; +}; + +export type createPetsResponse200 = { + data: Pet; + status: 200; +}; + +export type createPetsResponseDefault = { + data: Error; + status: Exclude; +}; + +export type createPetsResponseSuccess = createPetsResponse200 & { + headers: Headers; +}; +export type createPetsResponseError = createPetsResponseDefault & { + headers: Headers; +}; + +export type createPetsResponse = + | createPetsResponseSuccess + | createPetsResponseError; + +export const getCreatePetsUrl = (params: CreatePetsParams) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : String(value)); + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/pets`; +}; + +/** + * @summary Create a pet + */ +export const createPets = async ( + createPetsBody: CreatePetsBody, + params: CreatePetsParams, + options?: RequestInit, +): Promise => { + const res = await fetch(getCreatePetsUrl(params), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(createPetsBody), + }); + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: createPetsResponse['data'] = body ? JSON.parse(body) : {}; + return { + data, + status: res.status, + headers: res.headers, + } as createPetsResponse; +}; + +export type showPetByIdResponse200 = { + data: Pet; + status: 200; +}; + +export type showPetByIdResponseDefault = { + data: Error; + status: Exclude; +}; + +export type showPetByIdResponseSuccess = showPetByIdResponse200 & { + headers: Headers; +}; +export type showPetByIdResponseError = showPetByIdResponseDefault & { + headers: Headers; +}; + +export type showPetByIdResponse = + | showPetByIdResponseSuccess + | showPetByIdResponseError; + +export const getShowPetByIdUrl = (petId: string) => { + return `/pets/${petId}`; +}; + +/** + * @summary Info for a specific pet + */ +export const showPetById = async ( + petId: string, + options?: RequestInit, +): Promise => { + const res = await fetch(getShowPetByIdUrl(petId), { + ...options, + method: 'GET', + }); + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: showPetByIdResponse['data'] = body ? JSON.parse(body) : {}; + return { + data, + status: res.status, + headers: res.headers, + } as showPetByIdResponse; +}; + +export type deletePetByIdResponse204 = { + data: void; + status: 204; +}; + +export type deletePetByIdResponseDefault = { + data: Error; + status: Exclude; +}; + +export type deletePetByIdResponseSuccess = deletePetByIdResponse204 & { + headers: Headers; +}; +export type deletePetByIdResponseError = deletePetByIdResponseDefault & { + headers: Headers; +}; + +export type deletePetByIdResponse = + | deletePetByIdResponseSuccess + | deletePetByIdResponseError; + +export const getDeletePetByIdUrl = (petId: string) => { + return `/pets/${petId}`; +}; + +/** + * @summary Deletes a specific pet + */ +export const deletePetById = async ( + petId: string, + options?: RequestInit, +): Promise => { + const res = await fetch(getDeletePetByIdUrl(petId), { + ...options, + method: 'DELETE', + }); + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: deletePetByIdResponse['data'] = body + ? JSON.parse(body) + : undefined; + return { + data, + status: res.status, + headers: res.headers, + } as deletePetByIdResponse; +}; + +export type showPetWithOwnerResponse200 = { + data: PetWithTag; + status: 200; +}; + +export type showPetWithOwnerResponseDefault = { + data: Error; + status: Exclude; +}; + +export type showPetWithOwnerResponseSuccess = showPetWithOwnerResponse200 & { + headers: Headers; +}; +export type showPetWithOwnerResponseError = showPetWithOwnerResponseDefault & { + headers: Headers; +}; + +export type showPetWithOwnerResponse = + | showPetWithOwnerResponseSuccess + | showPetWithOwnerResponseError; + +export const getShowPetWithOwnerUrl = (petId: string) => { + return `/pets/${petId}/owner`; +}; + +/** + * @summary combinate nullable and $ref + */ +export const showPetWithOwner = async ( + petId: string, + options?: RequestInit, +): Promise => { + const res = await fetch(getShowPetWithOwnerUrl(petId), { + ...options, + method: 'GET', + }); + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: showPetWithOwnerResponse['data'] = body ? JSON.parse(body) : {}; + return { + data, + status: res.status, + headers: res.headers, + } as showPetWithOwnerResponse; +}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.apis.ts b/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.apis.ts new file mode 100644 index 0000000000..ef4e71b9f3 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.apis.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +export const createPetsApi = /(.*)\/pets(\?.*)?$/; + +export const deletePetByIdApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)$/; + +export const healthCheckApi = /(.*)\/health$/; + +export const listPetsApi = /(.*)\/pets(\?.*)?$/; + +export const showPetByIdApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)$/; + +export const showPetWithOwnerApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)\/owner$/; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.ts b/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.ts new file mode 100644 index 0000000000..c9e668f5cb --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.ts @@ -0,0 +1,362 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { + CreatePetsBody, + CreatePetsParams, + Error, + ListPetsParams, + Pet, + PetWithTag, + Pets, +} from './model'; + +export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; +export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; +export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; +export type HTTPStatusCode4xx = + | 400 + | 401 + | 402 + | 403 + | 404 + | 405 + | 406 + | 407 + | 408 + | 409 + | 410 + | 411 + | 412 + | 413 + | 414 + | 415 + | 416 + | 417 + | 418 + | 419 + | 420 + | 421 + | 422 + | 423 + | 424 + | 426 + | 428 + | 429 + | 431 + | 451; +export type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511; +export type HTTPStatusCodes = + | HTTPStatusCode1xx + | HTTPStatusCode2xx + | HTTPStatusCode3xx + | HTTPStatusCode4xx + | HTTPStatusCode5xx; + +export type listPetsResponse200 = { + data: Pets; + status: 200; +}; + +export type listPetsResponseDefault = { + data: Error; + status: Exclude; +}; + +export type listPetsResponseSuccess = listPetsResponse200 & { + headers: Headers; +}; +export type listPetsResponseError = listPetsResponseDefault & { + headers: Headers; +}; + +export type listPetsResponse = listPetsResponseSuccess | listPetsResponseError; + +export const getListPetsUrl = (params: ListPetsParams) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : String(value)); + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/pets`; +}; + +/** + * @summary List all pets + */ +export const listPets = async ( + params: ListPetsParams, + options?: RequestInit, +): Promise => { + const res = await fetch(getListPetsUrl(params), { + ...options, + method: 'GET', + }); + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: listPetsResponse['data'] = body ? JSON.parse(body) : {}; + return { data, status: res.status, headers: res.headers } as listPetsResponse; +}; + +export type createPetsResponse200 = { + data: Pet; + status: 200; +}; + +export type createPetsResponseDefault = { + data: Error; + status: Exclude; +}; + +export type createPetsResponseSuccess = createPetsResponse200 & { + headers: Headers; +}; +export type createPetsResponseError = createPetsResponseDefault & { + headers: Headers; +}; + +export type createPetsResponse = + | createPetsResponseSuccess + | createPetsResponseError; + +export const getCreatePetsUrl = (params: CreatePetsParams) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : String(value)); + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/pets`; +}; + +/** + * @summary Create a pet + */ +export const createPets = async ( + createPetsBody: CreatePetsBody, + params: CreatePetsParams, + options?: RequestInit, +): Promise => { + const res = await fetch(getCreatePetsUrl(params), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(createPetsBody), + }); + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: createPetsResponse['data'] = body ? JSON.parse(body) : {}; + return { + data, + status: res.status, + headers: res.headers, + } as createPetsResponse; +}; + +export type showPetByIdResponse200 = { + data: Pet; + status: 200; +}; + +export type showPetByIdResponseDefault = { + data: Error; + status: Exclude; +}; + +export type showPetByIdResponseSuccess = showPetByIdResponse200 & { + headers: Headers; +}; +export type showPetByIdResponseError = showPetByIdResponseDefault & { + headers: Headers; +}; + +export type showPetByIdResponse = + | showPetByIdResponseSuccess + | showPetByIdResponseError; + +export const getShowPetByIdUrl = (petId: string) => { + return `/pets/${petId}`; +}; + +/** + * @summary Info for a specific pet + */ +export const showPetById = async ( + petId: string, + options?: RequestInit, +): Promise => { + const res = await fetch(getShowPetByIdUrl(petId), { + ...options, + method: 'GET', + }); + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: showPetByIdResponse['data'] = body ? JSON.parse(body) : {}; + return { + data, + status: res.status, + headers: res.headers, + } as showPetByIdResponse; +}; + +export type deletePetByIdResponse204 = { + data: void; + status: 204; +}; + +export type deletePetByIdResponseDefault = { + data: Error; + status: Exclude; +}; + +export type deletePetByIdResponseSuccess = deletePetByIdResponse204 & { + headers: Headers; +}; +export type deletePetByIdResponseError = deletePetByIdResponseDefault & { + headers: Headers; +}; + +export type deletePetByIdResponse = + | deletePetByIdResponseSuccess + | deletePetByIdResponseError; + +export const getDeletePetByIdUrl = (petId: string) => { + return `/pets/${petId}`; +}; + +/** + * @summary Deletes a specific pet + */ +export const deletePetById = async ( + petId: string, + options?: RequestInit, +): Promise => { + const res = await fetch(getDeletePetByIdUrl(petId), { + ...options, + method: 'DELETE', + }); + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: deletePetByIdResponse['data'] = body + ? JSON.parse(body) + : undefined; + return { + data, + status: res.status, + headers: res.headers, + } as deletePetByIdResponse; +}; + +export type healthCheckResponse200 = { + data: string; + status: 200; +}; + +export type healthCheckResponseDefault = { + data: Error; + status: Exclude; +}; + +export type healthCheckResponseSuccess = healthCheckResponse200 & { + headers: Headers; +}; +export type healthCheckResponseError = healthCheckResponseDefault & { + headers: Headers; +}; + +export type healthCheckResponse = + | healthCheckResponseSuccess + | healthCheckResponseError; + +export const getHealthCheckUrl = () => { + return `/health`; +}; + +/** + * @summary health check + */ +export const healthCheck = async ( + options?: RequestInit, +): Promise => { + const res = await fetch(getHealthCheckUrl(), { + ...options, + method: 'GET', + }); + + const contentType = (res.headers.get('content-type') ?? '').toLowerCase(); + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: healthCheckResponse['data'] = body + ? contentType.includes('json') + ? JSON.parse(body) + : body + : {}; + return { + data, + status: res.status, + headers: res.headers, + } as healthCheckResponse; +}; + +export type showPetWithOwnerResponse200 = { + data: PetWithTag; + status: 200; +}; + +export type showPetWithOwnerResponseDefault = { + data: Error; + status: Exclude; +}; + +export type showPetWithOwnerResponseSuccess = showPetWithOwnerResponse200 & { + headers: Headers; +}; +export type showPetWithOwnerResponseError = showPetWithOwnerResponseDefault & { + headers: Headers; +}; + +export type showPetWithOwnerResponse = + | showPetWithOwnerResponseSuccess + | showPetWithOwnerResponseError; + +export const getShowPetWithOwnerUrl = (petId: string) => { + return `/pets/${petId}/owner`; +}; + +/** + * @summary combinate nullable and $ref + */ +export const showPetWithOwner = async ( + petId: string, + options?: RequestInit, +): Promise => { + const res = await fetch(getShowPetWithOwnerUrl(petId), { + ...options, + method: 'GET', + }); + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: showPetWithOwnerResponse['data'] = body ? JSON.parse(body) : {}; + return { + data, + status: res.status, + headers: res.headers, + } as showPetWithOwnerResponse; +}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/cat.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/cat.ts new file mode 100644 index 0000000000..12cb113fa5 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/cat.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { CatType } from './catType'; + +export interface Cat { + petsRequested?: number; + type: CatType; +} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/catType.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/catType.ts new file mode 100644 index 0000000000..3ffefb556b --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/catType.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type CatType = (typeof CatType)[keyof typeof CatType]; + +export const CatType = { + cat: 'cat', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsBody.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsBody.ts new file mode 100644 index 0000000000..66f5dcd899 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsBody.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type CreatePetsBody = { + name: string; + tag: string; +}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsParams.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsParams.ts new file mode 100644 index 0000000000..4866303333 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { CreatePetsSort } from './createPetsSort'; + +export type CreatePetsParams = { + /** + * How many items to return at one time (max 100) + */ + limit?: string; + /** + * Which property to sort by? + * Example: name sorts ASC while -name sorts DESC. + * + */ + sort: CreatePetsSort; +}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsSort.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsSort.ts new file mode 100644 index 0000000000..3fa8bf869a --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type CreatePetsSort = + (typeof CreatePetsSort)[keyof typeof CreatePetsSort]; + +export const CreatePetsSort = { + name: 'name', + '-name': '-name', + email: 'email', + '-email': '-email', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshund.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshund.ts new file mode 100644 index 0000000000..63f59b544c --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshund.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { DachshundBreed } from './dachshundBreed'; + +export interface Dachshund { + length: number; + breed: DachshundBreed; +} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshundBreed.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshundBreed.ts new file mode 100644 index 0000000000..cb96ff6641 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshundBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type DachshundBreed = + (typeof DachshundBreed)[keyof typeof DachshundBreed]; + +export const DachshundBreed = { + Dachshund: 'Dachshund', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/dog.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/dog.ts new file mode 100644 index 0000000000..edf04cb115 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/dog.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { Dachshund } from './dachshund'; +import type { DogType } from './dogType'; +import type { Labradoodle } from './labradoodle'; + +export type Dog = + | (Labradoodle & { + barksPerMinute?: number; + type: DogType; + }) + | (Dachshund & { + barksPerMinute?: number; + type: DogType; + }); diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/dogType.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/dogType.ts new file mode 100644 index 0000000000..b7344d0cc0 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/dogType.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type DogType = (typeof DogType)[keyof typeof DogType]; + +export const DogType = { + dog: 'dog', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/error.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/error.ts new file mode 100644 index 0000000000..b0a03afbfd --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/error.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export interface Error { + code: number; + message: string; +} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/index.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/index.ts new file mode 100644 index 0000000000..ff7af2b0b2 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/index.ts @@ -0,0 +1,26 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export * from './cat'; +export * from './catType'; +export * from './createPetsBody'; +export * from './createPetsParams'; +export * from './createPetsSort'; +export * from './dachshund'; +export * from './dachshundBreed'; +export * from './dog'; +export * from './dogType'; +export * from './error'; +export * from './labradoodle'; +export * from './labradoodleBreed'; +export * from './listPetsParams'; +export * from './listPetsSort'; +export * from './pet'; +export * from './petCallingCode'; +export * from './petCountry'; +export * from './pets'; +export * from './petWithTag'; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodle.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodle.ts new file mode 100644 index 0000000000..359008145c --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodle.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { LabradoodleBreed } from './labradoodleBreed'; + +export interface Labradoodle { + cuteness: number; + breed: LabradoodleBreed; +} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodleBreed.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodleBreed.ts new file mode 100644 index 0000000000..804aa239e7 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodleBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type LabradoodleBreed = + (typeof LabradoodleBreed)[keyof typeof LabradoodleBreed]; + +export const LabradoodleBreed = { + Labradoodle: 'Labradoodle', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsParams.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsParams.ts new file mode 100644 index 0000000000..f8a26309de --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { ListPetsSort } from './listPetsSort'; + +export type ListPetsParams = { + /** + * How many items to return at one time (max 100) + */ + limit?: string; + /** + * Which property to sort by? + * Example: name sorts ASC while -name sorts DESC. + * + */ + sort: ListPetsSort; +}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsSort.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsSort.ts new file mode 100644 index 0000000000..d334807265 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsSort.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type ListPetsSort = (typeof ListPetsSort)[keyof typeof ListPetsSort]; + +export const ListPetsSort = { + name: 'name', + '-name': '-name', + email: 'email', + '-email': '-email', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/pet.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/pet.ts new file mode 100644 index 0000000000..9892066bae --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/pet.ts @@ -0,0 +1,30 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { Cat } from './cat'; +import type { Dog } from './dog'; +import type { PetCallingCode } from './petCallingCode'; +import type { PetCountry } from './petCountry'; + +export type Pet = + | (Dog & { + '@id'?: string; + id: number; + name: string; + tag?: string; + email?: string; + callingCode?: PetCallingCode; + country?: PetCountry; + }) + | (Cat & { + '@id'?: string; + id: number; + name: string; + tag?: string; + email?: string; + callingCode?: PetCallingCode; + country?: PetCountry; + }); diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/petCallingCode.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/petCallingCode.ts new file mode 100644 index 0000000000..8c936dc7bf --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/petCallingCode.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type PetCallingCode = + (typeof PetCallingCode)[keyof typeof PetCallingCode]; + +export const PetCallingCode = { + '+33': '+33', + '+420': '+420', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/petCountry.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/petCountry.ts new file mode 100644 index 0000000000..16ff760582 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/petCountry.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry]; + +export const PetCountry = { + "People's_Republic_of_China": "People's Republic of China", + Uruguay: 'Uruguay', +} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/petWithTag.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/petWithTag.ts new file mode 100644 index 0000000000..89d5b99af4 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/petWithTag.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { Pet } from './pet'; + +export interface PetWithTag { + tag: string; + pet: Pet | null; +} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/pets.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/pets.ts new file mode 100644 index 0000000000..bd8268ca60 --- /dev/null +++ b/tests/__snapshots__/fetch/petstore-url-matchers/model/pets.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v8.13.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import type { Pet } from './pet'; + +export type Pets = Pet[]; diff --git a/tests/__snapshots__/fetch/petstore/endpoints.ts b/tests/__snapshots__/fetch/petstore/endpoints.ts index fbc6d06b4b..ee56d98e4c 100644 --- a/tests/__snapshots__/fetch/petstore/endpoints.ts +++ b/tests/__snapshots__/fetch/petstore/endpoints.ts @@ -5,9 +5,13 @@ * OpenAPI spec version: 1.0.0 */ import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -19,8 +23,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/mock/discriminator-oneof-allof-inherited/endpoints.ts b/tests/__snapshots__/mock/discriminator-oneof-allof-inherited/endpoints.ts index 9c6e9ae1de..5370782ef2 100644 --- a/tests/__snapshots__/mock/discriminator-oneof-allof-inherited/endpoints.ts +++ b/tests/__snapshots__/mock/discriminator-oneof-allof-inherited/endpoints.ts @@ -7,15 +7,13 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { Animal } from './model'; +import type { Animal, Cat, Dog } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dog } from './model'; - export const getAnimal = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/mock/discriminator-oneof-allof/endpoints.ts b/tests/__snapshots__/mock/discriminator-oneof-allof/endpoints.ts index 0e43383d21..3386ab236b 100644 --- a/tests/__snapshots__/mock/discriminator-oneof-allof/endpoints.ts +++ b/tests/__snapshots__/mock/discriminator-oneof-allof/endpoints.ts @@ -7,15 +7,13 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { DiscriminatorTest } from './model'; +import type { DiscriminatorTest, Item1, Item2, Item3 } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Item1, Item2, Item3 } from './model'; - export const getTest = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/mock/discriminator-oneof-union/endpoints.ts b/tests/__snapshots__/mock/discriminator-oneof-union/endpoints.ts index 8441084f1f..c6390dadc6 100644 --- a/tests/__snapshots__/mock/discriminator-oneof-union/endpoints.ts +++ b/tests/__snapshots__/mock/discriminator-oneof-union/endpoints.ts @@ -7,15 +7,13 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { DiscriminatorTest } from './model'; +import type { DiscriminatorTest, Item1, Item2, Item3 } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Item1, Item2, Item3 } from './model'; - export const getTest = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/mock/issue-3200/endpoints.ts b/tests/__snapshots__/mock/issue-3200/endpoints.ts index e05a6ef7ea..bea56b0c9d 100644 --- a/tests/__snapshots__/mock/issue-3200/endpoints.ts +++ b/tests/__snapshots__/mock/issue-3200/endpoints.ts @@ -17,10 +17,10 @@ import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { StringToIntegerMap, StringToNumberMap } from './model'; -import { faker } from '@faker-js/faker'; - import { getIntegerLikeMock, getNumberLikeMock } from './model/index.faker'; +import { faker } from '@faker-js/faker'; + export const getIssue3200 = (axiosInstance: AxiosInstance = axios) => { const getIntegerMap = ( options?: AxiosRequestConfig, diff --git a/tests/__snapshots__/mock/msw-mixed-content-union-each-status/endpoints.ts b/tests/__snapshots__/mock/msw-mixed-content-union-each-status/endpoints.ts index edc594039b..f7f75ed98a 100644 --- a/tests/__snapshots__/mock/msw-mixed-content-union-each-status/endpoints.ts +++ b/tests/__snapshots__/mock/msw-mixed-content-union-each-status/endpoints.ts @@ -7,15 +7,13 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { Pet } from './model'; +import type { Error, Pet } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Error } from './model'; - export const getMSWMixedContentEachStatusRegression = ( axiosInstance: AxiosInstance = axios, ) => { diff --git a/tests/__snapshots__/mock/petstore-faker-schemas-and-ops/endpoints.ts b/tests/__snapshots__/mock/petstore-faker-schemas-and-ops/endpoints.ts index 8821a72421..25c1c458ce 100644 --- a/tests/__snapshots__/mock/petstore-faker-schemas-and-ops/endpoints.ts +++ b/tests/__snapshots__/mock/petstore-faker-schemas-and-ops/endpoints.ts @@ -16,10 +16,10 @@ import type { Pets, } from './model'; -import { faker } from '@faker-js/faker'; - import { getCatMock, getDogMock, getPetMock } from './model/index.faker'; +import { faker } from '@faker-js/faker'; + export const getSwaggerPetstore = (axiosInstance: AxiosInstance = axios) => { /** * @summary List all pets diff --git a/tests/__snapshots__/mock/petstore/endpoints.ts b/tests/__snapshots__/mock/petstore/endpoints.ts index 1fe1ce2602..1b5f834684 100644 --- a/tests/__snapshots__/mock/petstore/endpoints.ts +++ b/tests/__snapshots__/mock/petstore/endpoints.ts @@ -8,8 +8,12 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -21,8 +25,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, delay, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export const getSwaggerPetstore = (axiosInstance: AxiosInstance = axios) => { /** * @summary List all pets diff --git a/tests/__snapshots__/mock/typelessEnum/typelessEnums.ts b/tests/__snapshots__/mock/typelessEnum/typelessEnums.ts index 48711a8b4a..9b2be28bec 100644 --- a/tests/__snapshots__/mock/typelessEnum/typelessEnums.ts +++ b/tests/__snapshots__/mock/typelessEnum/typelessEnums.ts @@ -7,6 +7,7 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; +import { Colors1, Colors2 } from './schemas'; import type { ColorObject } from './schemas'; import { faker } from '@faker-js/faker'; @@ -14,8 +15,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import { Colors1, Colors2 } from './schemas'; - /** * @summary sample colors */ diff --git a/tests/__snapshots__/mock/zod-schema-response/endpoints.ts b/tests/__snapshots__/mock/zod-schema-response/endpoints.ts index 204d6688e8..6d42341db3 100644 --- a/tests/__snapshots__/mock/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/mock/zod-schema-response/endpoints.ts @@ -8,8 +8,12 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -21,8 +25,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export const getSwaggerPetstore = (axiosInstance: AxiosInstance = axios) => { /** * @summary List all pets diff --git a/tests/__snapshots__/react-query/basic/endpoints.ts b/tests/__snapshots__/react-query/basic/endpoints.ts index 6391918fde..5555f90fbb 100644 --- a/tests/__snapshots__/react-query/basic/endpoints.ts +++ b/tests/__snapshots__/react-query/basic/endpoints.ts @@ -21,10 +21,14 @@ import type { } from '@tanstack/react-query'; import type { + Cat, CreatePetsBody, CreatePetsHeaders, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsHeaders, ListPetsParams, Pet, @@ -37,8 +41,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/react-query/deprecated/endpoints.ts b/tests/__snapshots__/react-query/deprecated/endpoints.ts index b40c8e1283..4d288f185d 100644 --- a/tests/__snapshots__/react-query/deprecated/endpoints.ts +++ b/tests/__snapshots__/react-query/deprecated/endpoints.ts @@ -17,15 +17,21 @@ import type { UseQueryResult, } from '@tanstack/react-query'; -import type { Error, ListPetsParams, Pets } from './model'; +import type { + Cat, + Dachshund, + Dog, + Error, + Labradoodle, + ListPetsParams, + Pets, +} from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/react-query/error-type/endpoints.ts b/tests/__snapshots__/react-query/error-type/endpoints.ts index a32ed95e97..292e4a5b7b 100644 --- a/tests/__snapshots__/react-query/error-type/endpoints.ts +++ b/tests/__snapshots__/react-query/error-type/endpoints.ts @@ -22,9 +22,13 @@ import type { } from '@tanstack/react-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -36,8 +40,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customInstance } from '../../../mutators/error-type'; import type { ErrorType } from '../../../mutators/error-type'; /** diff --git a/tests/__snapshots__/react-query/form-data-with-hook/endpoints.ts b/tests/__snapshots__/react-query/form-data-with-hook/endpoints.ts index 104e3cad95..bdd05c37f0 100644 --- a/tests/__snapshots__/react-query/form-data-with-hook/endpoints.ts +++ b/tests/__snapshots__/react-query/form-data-with-hook/endpoints.ts @@ -14,15 +14,13 @@ import type { import { useCallback } from 'react'; -import type { Error, Pet } from './model'; +import type { Error, Pet, PetBase, PetExtended } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { PetBase, PetExtended } from './model'; - import { useCustomInstance } from '../../../mutators/use-custom-instance'; /** * @summary Create a pet diff --git a/tests/__snapshots__/react-query/form-data-with-mutator/endpoints.ts b/tests/__snapshots__/react-query/form-data-with-mutator/endpoints.ts index a7a08099b4..3b77669185 100644 --- a/tests/__snapshots__/react-query/form-data-with-mutator/endpoints.ts +++ b/tests/__snapshots__/react-query/form-data-with-mutator/endpoints.ts @@ -12,15 +12,13 @@ import type { UseMutationResult, } from '@tanstack/react-query'; -import type { Error, Pet } from './model'; +import type { Error, Pet, PetBase, PetExtended } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { PetBase, PetExtended } from './model'; - import { customInstance } from '../../../mutators/custom-instance'; import { customFormData } from '../../../mutators/custom-form-data'; /** diff --git a/tests/__snapshots__/react-query/form-data/endpoints.ts b/tests/__snapshots__/react-query/form-data/endpoints.ts index 0bcd2ed387..55498f7f29 100644 --- a/tests/__snapshots__/react-query/form-data/endpoints.ts +++ b/tests/__snapshots__/react-query/form-data/endpoints.ts @@ -12,15 +12,13 @@ import type { UseMutationResult, } from '@tanstack/react-query'; -import type { Error, Pet } from './model'; +import type { Error, Pet, PetBase, PetExtended } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { PetBase, PetExtended } from './model'; - import { customInstance } from '../../../mutators/custom-instance'; /** * @summary Create a pet diff --git a/tests/__snapshots__/react-query/http-client-fetch-with-custom-fetch/endpoints.ts b/tests/__snapshots__/react-query/http-client-fetch-with-custom-fetch/endpoints.ts index 60a4f6e9ce..05a6b643fd 100644 --- a/tests/__snapshots__/react-query/http-client-fetch-with-custom-fetch/endpoints.ts +++ b/tests/__snapshots__/react-query/http-client-fetch-with-custom-fetch/endpoints.ts @@ -21,9 +21,13 @@ import type { } from '@tanstack/react-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -35,8 +39,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customFetch } from '../../../mutators/custom-fetch'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/react-query/invalidates/endpoints.ts b/tests/__snapshots__/react-query/invalidates/endpoints.ts index 4580a9c081..90e1f87865 100644 --- a/tests/__snapshots__/react-query/invalidates/endpoints.ts +++ b/tests/__snapshots__/react-query/invalidates/endpoints.ts @@ -21,10 +21,14 @@ import type { } from '@tanstack/react-query'; import type { + Cat, CreatePetsBody, CreatePetsHeaders, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsHeaders, ListPetsParams, Pet, @@ -37,8 +41,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/react-query/mockOverride/endpoints.ts b/tests/__snapshots__/react-query/mockOverride/endpoints.ts index f56ed31b98..e994ba8e81 100644 --- a/tests/__snapshots__/react-query/mockOverride/endpoints.ts +++ b/tests/__snapshots__/react-query/mockOverride/endpoints.ts @@ -21,9 +21,13 @@ import type { } from '@tanstack/react-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -35,8 +39,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/react-query/mockWithoutDelay/endpoints.ts b/tests/__snapshots__/react-query/mockWithoutDelay/endpoints.ts index 87da4bb494..4d5f25501f 100644 --- a/tests/__snapshots__/react-query/mockWithoutDelay/endpoints.ts +++ b/tests/__snapshots__/react-query/mockWithoutDelay/endpoints.ts @@ -21,9 +21,13 @@ import type { } from '@tanstack/react-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -35,8 +39,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/react-query/mutator-client/endpoints.ts b/tests/__snapshots__/react-query/mutator-client/endpoints.ts index b869cd2d17..d6b38bd8af 100644 --- a/tests/__snapshots__/react-query/mutator-client/endpoints.ts +++ b/tests/__snapshots__/react-query/mutator-client/endpoints.ts @@ -22,10 +22,14 @@ import type { } from '@tanstack/react-query'; import type { + Cat, CreatePetsBody, CreatePetsHeaders, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsHeaders, ListPetsParams, Pet, @@ -38,8 +42,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customClient } from '../../../mutators/custom-client'; import type { ErrorType, BodyType } from '../../../mutators/custom-client'; /** diff --git a/tests/__snapshots__/react-query/mutator-multi-arguments/endpoints.ts b/tests/__snapshots__/react-query/mutator-multi-arguments/endpoints.ts index 5ef02c19f0..a026d50f16 100644 --- a/tests/__snapshots__/react-query/mutator-multi-arguments/endpoints.ts +++ b/tests/__snapshots__/react-query/mutator-multi-arguments/endpoints.ts @@ -22,9 +22,13 @@ import type { } from '@tanstack/react-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -36,8 +40,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customInstance } from '../../../mutators/multi-arguments'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/react-query/mutator/endpoints.ts b/tests/__snapshots__/react-query/mutator/endpoints.ts index 51bbd3aa9d..094a8778c7 100644 --- a/tests/__snapshots__/react-query/mutator/endpoints.ts +++ b/tests/__snapshots__/react-query/mutator/endpoints.ts @@ -35,9 +35,13 @@ import type { } from '@tanstack/react-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -49,8 +53,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customInstance } from '../../../mutators/custom-instance'; /** * @summary List all pets diff --git a/tests/__snapshots__/react-query/zod-schema-response/endpoints.ts b/tests/__snapshots__/react-query/zod-schema-response/endpoints.ts index 87da4bb494..4d5f25501f 100644 --- a/tests/__snapshots__/react-query/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/react-query/zod-schema-response/endpoints.ts @@ -21,9 +21,13 @@ import type { } from '@tanstack/react-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -35,8 +39,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/svelte-query/http-client-fetch-with-custom-fetch/endpoints.ts b/tests/__snapshots__/svelte-query/http-client-fetch-with-custom-fetch/endpoints.ts index 504b065f80..e2998811f9 100644 --- a/tests/__snapshots__/svelte-query/http-client-fetch-with-custom-fetch/endpoints.ts +++ b/tests/__snapshots__/svelte-query/http-client-fetch-with-custom-fetch/endpoints.ts @@ -16,9 +16,13 @@ import type { } from '@tanstack/svelte-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -30,8 +34,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customFetch } from '../../../mutators/custom-fetch'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/svelte-query/invalidates/endpoints.ts b/tests/__snapshots__/svelte-query/invalidates/endpoints.ts index 53e71f0eaf..f482c27891 100644 --- a/tests/__snapshots__/svelte-query/invalidates/endpoints.ts +++ b/tests/__snapshots__/svelte-query/invalidates/endpoints.ts @@ -21,10 +21,14 @@ import type { } from '@tanstack/svelte-query'; import type { + Cat, CreatePetsBody, CreatePetsHeaders, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsHeaders, ListPetsParams, Pet, @@ -37,8 +41,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/svelte-query/mutator/endpoints.ts b/tests/__snapshots__/svelte-query/mutator/endpoints.ts index a472a32927..5f714c9ac1 100644 --- a/tests/__snapshots__/svelte-query/mutator/endpoints.ts +++ b/tests/__snapshots__/svelte-query/mutator/endpoints.ts @@ -15,9 +15,13 @@ import type { } from '@tanstack/svelte-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -29,8 +33,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customInstance } from '../../../mutators/custom-instance'; /** * @summary List all pets diff --git a/tests/__snapshots__/svelte-query/petstore/endpoints.ts b/tests/__snapshots__/svelte-query/petstore/endpoints.ts index 30688c6822..6c659798f0 100644 --- a/tests/__snapshots__/svelte-query/petstore/endpoints.ts +++ b/tests/__snapshots__/svelte-query/petstore/endpoints.ts @@ -15,9 +15,13 @@ import type { } from '@tanstack/svelte-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -29,8 +33,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/svelte-query/zod-schema-response/endpoints.ts b/tests/__snapshots__/svelte-query/zod-schema-response/endpoints.ts index 656cfe1e6d..56d47ca474 100644 --- a/tests/__snapshots__/svelte-query/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/svelte-query/zod-schema-response/endpoints.ts @@ -16,9 +16,13 @@ import type { } from '@tanstack/svelte-query'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -30,8 +34,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/swr/custom-client/endpoints.ts b/tests/__snapshots__/swr/custom-client/endpoints.ts index 67dc7d9d52..90f404c54d 100644 --- a/tests/__snapshots__/swr/custom-client/endpoints.ts +++ b/tests/__snapshots__/swr/custom-client/endpoints.ts @@ -11,9 +11,13 @@ import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,8 +29,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customClient } from '../../../mutators/custom-client'; import type { ErrorType, BodyType } from '../../../mutators/custom-client'; /** diff --git a/tests/__snapshots__/swr/form-data-optional-request/endpoints.ts b/tests/__snapshots__/swr/form-data-optional-request/endpoints.ts index 05094c866d..c1e432f82d 100644 --- a/tests/__snapshots__/swr/form-data-optional-request/endpoints.ts +++ b/tests/__snapshots__/swr/form-data-optional-request/endpoints.ts @@ -9,15 +9,13 @@ import type { Key } from 'swr'; import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; -import type { Error, Pet } from './model'; +import type { Error, Pet, PetBase, PetExtended } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { PetBase, PetExtended } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/swr/http-client-fetch-with-custom-fetch/endpoints.ts b/tests/__snapshots__/swr/http-client-fetch-with-custom-fetch/endpoints.ts index 9851cf584d..f18ba17d26 100644 --- a/tests/__snapshots__/swr/http-client-fetch-with-custom-fetch/endpoints.ts +++ b/tests/__snapshots__/swr/http-client-fetch-with-custom-fetch/endpoints.ts @@ -11,9 +11,13 @@ import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,8 +29,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customFetch } from '../../../mutators/custom-fetch'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/swr/mutator/endpoints.ts b/tests/__snapshots__/swr/mutator/endpoints.ts index fd6cd64283..fe4e9991f9 100644 --- a/tests/__snapshots__/swr/mutator/endpoints.ts +++ b/tests/__snapshots__/swr/mutator/endpoints.ts @@ -11,9 +11,13 @@ import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,8 +29,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customInstance } from '../../../mutators/multi-arguments'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/swr/petstore/endpoints.ts b/tests/__snapshots__/swr/petstore/endpoints.ts index bdb369c778..50401a8b35 100644 --- a/tests/__snapshots__/swr/petstore/endpoints.ts +++ b/tests/__snapshots__/swr/petstore/endpoints.ts @@ -11,9 +11,13 @@ import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,8 +29,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/swr/zod-schema-response/endpoints.ts b/tests/__snapshots__/swr/zod-schema-response/endpoints.ts index f28398d0bb..ccf15fffe5 100644 --- a/tests/__snapshots__/swr/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/swr/zod-schema-response/endpoints.ts @@ -11,9 +11,13 @@ import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,8 +29,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/vue-query/all-params-optional/endpoints.ts b/tests/__snapshots__/vue-query/all-params-optional/endpoints.ts index 2989fa6da7..9fdc2846b8 100644 --- a/tests/__snapshots__/vue-query/all-params-optional/endpoints.ts +++ b/tests/__snapshots__/vue-query/all-params-optional/endpoints.ts @@ -21,9 +21,13 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -35,8 +39,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/vue-query/combination-used-by-maxim-mazurok/endpoints.ts b/tests/__snapshots__/vue-query/combination-used-by-maxim-mazurok/endpoints.ts index 9e225fd025..6035b4fb98 100644 --- a/tests/__snapshots__/vue-query/combination-used-by-maxim-mazurok/endpoints.ts +++ b/tests/__snapshots__/vue-query/combination-used-by-maxim-mazurok/endpoints.ts @@ -21,9 +21,13 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -35,8 +39,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/vue-query/http-client-fetch-with-custom-fetch/endpoints.ts b/tests/__snapshots__/vue-query/http-client-fetch-with-custom-fetch/endpoints.ts index a0ab810f8f..ef5f70fd1e 100644 --- a/tests/__snapshots__/vue-query/http-client-fetch-with-custom-fetch/endpoints.ts +++ b/tests/__snapshots__/vue-query/http-client-fetch-with-custom-fetch/endpoints.ts @@ -21,9 +21,13 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -35,8 +39,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customFetch } from '../../../mutators/custom-fetch'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/vue-query/mutator/endpoints.ts b/tests/__snapshots__/vue-query/mutator/endpoints.ts index 949c797a64..76a1636dbd 100644 --- a/tests/__snapshots__/vue-query/mutator/endpoints.ts +++ b/tests/__snapshots__/vue-query/mutator/endpoints.ts @@ -21,9 +21,13 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -35,8 +39,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - import { customInstance } from '../../../mutators/custom-instance'; /** * @summary List all pets diff --git a/tests/__snapshots__/vue-query/petstore/endpoints.ts b/tests/__snapshots__/vue-query/petstore/endpoints.ts index 0ffb9c06cc..95a68fc982 100644 --- a/tests/__snapshots__/vue-query/petstore/endpoints.ts +++ b/tests/__snapshots__/vue-query/petstore/endpoints.ts @@ -24,9 +24,13 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -38,8 +42,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - /** * @summary List all pets */ diff --git a/tests/__snapshots__/vue-query/url-encode-parameters/endpoints.ts b/tests/__snapshots__/vue-query/url-encode-parameters/endpoints.ts index 84f96519ae..e77ee904b3 100644 --- a/tests/__snapshots__/vue-query/url-encode-parameters/endpoints.ts +++ b/tests/__snapshots__/vue-query/url-encode-parameters/endpoints.ts @@ -21,9 +21,13 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -35,8 +39,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/vue-query/zod-schema-response/endpoints.ts b/tests/__snapshots__/vue-query/zod-schema-response/endpoints.ts index 2c9e050b54..ef055bdeac 100644 --- a/tests/__snapshots__/vue-query/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/vue-query/zod-schema-response/endpoints.ts @@ -24,9 +24,13 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { + Cat, CreatePetsBody, CreatePetsParams, + Dachshund, + Dog, Error, + Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -38,8 +42,6 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; -import type { Cat, Dachshund, Dog, Labradoodle } from './model'; - /** * @summary List all pets */ diff --git a/tests/__snapshots__/zod/petstore/endpoints.ts b/tests/__snapshots__/zod/petstore/endpoints.ts index 6d23dfcedf..b2e1504791 100644 --- a/tests/__snapshots__/zod/petstore/endpoints.ts +++ b/tests/__snapshots__/zod/petstore/endpoints.ts @@ -6,11 +6,6 @@ */ import * as zod from 'zod'; -import { faker } from '@faker-js/faker'; - -import { HttpResponse, http } from 'msw'; -import type { RequestHandlerOptions } from 'msw'; - import type { Cat, Dachshund, @@ -21,6 +16,11 @@ import type { Pets, } from './model'; +import { faker } from '@faker-js/faker'; + +import { HttpResponse, http } from 'msw'; +import type { RequestHandlerOptions } from 'msw'; + /** * @summary List all pets */ From 68a05c813adaa87d1aaecb55db1ed4ad67b5a391 Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Mon, 1 Jun 2026 16:16:27 +0200 Subject: [PATCH 06/11] chore(tests): remove stale petstore-url-matchers snapshots Drop orphaned v8.13.0 snapshot files with no master config or generated source. Co-authored-by: Cursor --- .../health/health.apis.ts | 7 - .../health/health.ts | 100 ----- .../model/cat.ts | 12 - .../model/catType.ts | 12 - .../model/createPetsBody.ts | 11 - .../model/createPetsParams.ts | 20 - .../model/createPetsSort.ts | 16 - .../model/dachshund.ts | 12 - .../model/dachshundBreed.ts | 13 - .../model/dog.ts | 19 - .../model/dogType.ts | 12 - .../model/error.ts | 11 - .../model/index.ts | 26 -- .../model/labradoodle.ts | 12 - .../model/labradoodleBreed.ts | 13 - .../model/listPetsParams.ts | 20 - .../model/listPetsSort.ts | 15 - .../model/pet.ts | 30 -- .../model/petCallingCode.ts | 14 - .../model/petCountry.ts | 13 - .../model/petWithTag.ts | 12 - .../model/pets.ts | 9 - .../pets/pets.apis.ts | 15 - .../pets/pets.ts | 311 --------------- .../petstore-url-matchers/endpoints.apis.ts | 17 - .../fetch/petstore-url-matchers/endpoints.ts | 362 ------------------ .../fetch/petstore-url-matchers/model/cat.ts | 12 - .../petstore-url-matchers/model/catType.ts | 12 - .../model/createPetsBody.ts | 11 - .../model/createPetsParams.ts | 20 - .../model/createPetsSort.ts | 16 - .../petstore-url-matchers/model/dachshund.ts | 12 - .../model/dachshundBreed.ts | 13 - .../fetch/petstore-url-matchers/model/dog.ts | 19 - .../petstore-url-matchers/model/dogType.ts | 12 - .../petstore-url-matchers/model/error.ts | 11 - .../petstore-url-matchers/model/index.ts | 26 -- .../model/labradoodle.ts | 12 - .../model/labradoodleBreed.ts | 13 - .../model/listPetsParams.ts | 20 - .../model/listPetsSort.ts | 15 - .../fetch/petstore-url-matchers/model/pet.ts | 30 -- .../model/petCallingCode.ts | 14 - .../petstore-url-matchers/model/petCountry.ts | 13 - .../petstore-url-matchers/model/petWithTag.ts | 12 - .../fetch/petstore-url-matchers/model/pets.ts | 9 - 46 files changed, 1416 deletions(-) delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.apis.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/cat.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/catType.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsBody.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsParams.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsSort.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshund.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshundBreed.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dog.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dogType.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/error.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/index.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodle.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodleBreed.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsParams.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsSort.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pet.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCallingCode.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCountry.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petWithTag.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pets.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.apis.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/endpoints.apis.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/endpoints.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/cat.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/catType.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsBody.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsParams.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsSort.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/dachshund.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/dachshundBreed.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/dog.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/dogType.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/error.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/index.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodle.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodleBreed.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsParams.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsSort.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/pet.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/petCallingCode.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/petCountry.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/petWithTag.ts delete mode 100644 tests/__snapshots__/fetch/petstore-url-matchers/model/pets.ts diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.apis.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.apis.ts deleted file mode 100644 index 8d115700d6..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.apis.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -export const healthCheckApi = /(.*)\/health$/; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.ts deleted file mode 100644 index d0c55c25d6..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/health/health.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { Error } from '../model'; - -export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; -export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; -export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; -export type HTTPStatusCode4xx = - | 400 - | 401 - | 402 - | 403 - | 404 - | 405 - | 406 - | 407 - | 408 - | 409 - | 410 - | 411 - | 412 - | 413 - | 414 - | 415 - | 416 - | 417 - | 418 - | 419 - | 420 - | 421 - | 422 - | 423 - | 424 - | 426 - | 428 - | 429 - | 431 - | 451; -export type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511; -export type HTTPStatusCodes = - | HTTPStatusCode1xx - | HTTPStatusCode2xx - | HTTPStatusCode3xx - | HTTPStatusCode4xx - | HTTPStatusCode5xx; - -export type healthCheckResponse200 = { - data: string; - status: 200; -}; - -export type healthCheckResponseDefault = { - data: Error; - status: Exclude; -}; - -export type healthCheckResponseSuccess = healthCheckResponse200 & { - headers: Headers; -}; -export type healthCheckResponseError = healthCheckResponseDefault & { - headers: Headers; -}; - -export type healthCheckResponse = - | healthCheckResponseSuccess - | healthCheckResponseError; - -export const getHealthCheckUrl = () => { - return `/health`; -}; - -/** - * @summary health check - */ -export const healthCheck = async ( - options?: RequestInit, -): Promise => { - const res = await fetch(getHealthCheckUrl(), { - ...options, - method: 'GET', - }); - - const contentType = (res.headers.get('content-type') ?? '').toLowerCase(); - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: healthCheckResponse['data'] = body - ? contentType.includes('json') - ? JSON.parse(body) - : body - : {}; - return { - data, - status: res.status, - headers: res.headers, - } as healthCheckResponse; -}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/cat.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/cat.ts deleted file mode 100644 index 12cb113fa5..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/cat.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { CatType } from './catType'; - -export interface Cat { - petsRequested?: number; - type: CatType; -} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/catType.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/catType.ts deleted file mode 100644 index 3ffefb556b..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/catType.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type CatType = (typeof CatType)[keyof typeof CatType]; - -export const CatType = { - cat: 'cat', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsBody.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsBody.ts deleted file mode 100644 index 66f5dcd899..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsBody.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type CreatePetsBody = { - name: string; - tag: string; -}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsParams.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsParams.ts deleted file mode 100644 index 4866303333..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { CreatePetsSort } from './createPetsSort'; - -export type CreatePetsParams = { - /** - * How many items to return at one time (max 100) - */ - limit?: string; - /** - * Which property to sort by? - * Example: name sorts ASC while -name sorts DESC. - * - */ - sort: CreatePetsSort; -}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsSort.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsSort.ts deleted file mode 100644 index 3fa8bf869a..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/createPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type CreatePetsSort = - (typeof CreatePetsSort)[keyof typeof CreatePetsSort]; - -export const CreatePetsSort = { - name: 'name', - '-name': '-name', - email: 'email', - '-email': '-email', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshund.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshund.ts deleted file mode 100644 index 63f59b544c..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshund.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { DachshundBreed } from './dachshundBreed'; - -export interface Dachshund { - length: number; - breed: DachshundBreed; -} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshundBreed.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshundBreed.ts deleted file mode 100644 index cb96ff6641..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dachshundBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type DachshundBreed = - (typeof DachshundBreed)[keyof typeof DachshundBreed]; - -export const DachshundBreed = { - Dachshund: 'Dachshund', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dog.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dog.ts deleted file mode 100644 index edf04cb115..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dog.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { Dachshund } from './dachshund'; -import type { DogType } from './dogType'; -import type { Labradoodle } from './labradoodle'; - -export type Dog = - | (Labradoodle & { - barksPerMinute?: number; - type: DogType; - }) - | (Dachshund & { - barksPerMinute?: number; - type: DogType; - }); diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dogType.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dogType.ts deleted file mode 100644 index b7344d0cc0..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/dogType.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type DogType = (typeof DogType)[keyof typeof DogType]; - -export const DogType = { - dog: 'dog', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/error.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/error.ts deleted file mode 100644 index b0a03afbfd..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/error.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export interface Error { - code: number; - message: string; -} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/index.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/index.ts deleted file mode 100644 index ff7af2b0b2..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export * from './cat'; -export * from './catType'; -export * from './createPetsBody'; -export * from './createPetsParams'; -export * from './createPetsSort'; -export * from './dachshund'; -export * from './dachshundBreed'; -export * from './dog'; -export * from './dogType'; -export * from './error'; -export * from './labradoodle'; -export * from './labradoodleBreed'; -export * from './listPetsParams'; -export * from './listPetsSort'; -export * from './pet'; -export * from './petCallingCode'; -export * from './petCountry'; -export * from './pets'; -export * from './petWithTag'; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodle.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodle.ts deleted file mode 100644 index 359008145c..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodle.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { LabradoodleBreed } from './labradoodleBreed'; - -export interface Labradoodle { - cuteness: number; - breed: LabradoodleBreed; -} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodleBreed.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodleBreed.ts deleted file mode 100644 index 804aa239e7..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/labradoodleBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type LabradoodleBreed = - (typeof LabradoodleBreed)[keyof typeof LabradoodleBreed]; - -export const LabradoodleBreed = { - Labradoodle: 'Labradoodle', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsParams.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsParams.ts deleted file mode 100644 index f8a26309de..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { ListPetsSort } from './listPetsSort'; - -export type ListPetsParams = { - /** - * How many items to return at one time (max 100) - */ - limit?: string; - /** - * Which property to sort by? - * Example: name sorts ASC while -name sorts DESC. - * - */ - sort: ListPetsSort; -}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsSort.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsSort.ts deleted file mode 100644 index d334807265..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/listPetsSort.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type ListPetsSort = (typeof ListPetsSort)[keyof typeof ListPetsSort]; - -export const ListPetsSort = { - name: 'name', - '-name': '-name', - email: 'email', - '-email': '-email', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pet.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pet.ts deleted file mode 100644 index 9892066bae..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pet.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { Cat } from './cat'; -import type { Dog } from './dog'; -import type { PetCallingCode } from './petCallingCode'; -import type { PetCountry } from './petCountry'; - -export type Pet = - | (Dog & { - '@id'?: string; - id: number; - name: string; - tag?: string; - email?: string; - callingCode?: PetCallingCode; - country?: PetCountry; - }) - | (Cat & { - '@id'?: string; - id: number; - name: string; - tag?: string; - email?: string; - callingCode?: PetCallingCode; - country?: PetCountry; - }); diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCallingCode.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCallingCode.ts deleted file mode 100644 index 8c936dc7bf..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCallingCode.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type PetCallingCode = - (typeof PetCallingCode)[keyof typeof PetCallingCode]; - -export const PetCallingCode = { - '+33': '+33', - '+420': '+420', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCountry.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCountry.ts deleted file mode 100644 index 16ff760582..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petCountry.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry]; - -export const PetCountry = { - "People's_Republic_of_China": "People's Republic of China", - Uruguay: 'Uruguay', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petWithTag.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petWithTag.ts deleted file mode 100644 index 89d5b99af4..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/petWithTag.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { Pet } from './pet'; - -export interface PetWithTag { - tag: string; - pet: Pet | null; -} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pets.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pets.ts deleted file mode 100644 index bd8268ca60..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/model/pets.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { Pet } from './pet'; - -export type Pets = Pet[]; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.apis.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.apis.ts deleted file mode 100644 index c68219cf2f..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.apis.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -export const createPetsApi = /(.*)\/pets(\?.*)?$/; - -export const deletePetByIdApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)$/; - -export const listPetsApi = /(.*)\/pets(\?.*)?$/; - -export const showPetByIdApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)$/; - -export const showPetWithOwnerApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)\/owner$/; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.ts b/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.ts deleted file mode 100644 index 6224094fb7..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers-tags-split/pets/pets.ts +++ /dev/null @@ -1,311 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { - CreatePetsBody, - CreatePetsParams, - Error, - ListPetsParams, - Pet, - PetWithTag, - Pets, -} from '../model'; - -export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; -export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; -export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; -export type HTTPStatusCode4xx = - | 400 - | 401 - | 402 - | 403 - | 404 - | 405 - | 406 - | 407 - | 408 - | 409 - | 410 - | 411 - | 412 - | 413 - | 414 - | 415 - | 416 - | 417 - | 418 - | 419 - | 420 - | 421 - | 422 - | 423 - | 424 - | 426 - | 428 - | 429 - | 431 - | 451; -export type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511; -export type HTTPStatusCodes = - | HTTPStatusCode1xx - | HTTPStatusCode2xx - | HTTPStatusCode3xx - | HTTPStatusCode4xx - | HTTPStatusCode5xx; - -export type listPetsResponse200 = { - data: Pets; - status: 200; -}; - -export type listPetsResponseDefault = { - data: Error; - status: Exclude; -}; - -export type listPetsResponseSuccess = listPetsResponse200 & { - headers: Headers; -}; -export type listPetsResponseError = listPetsResponseDefault & { - headers: Headers; -}; - -export type listPetsResponse = listPetsResponseSuccess | listPetsResponseError; - -export const getListPetsUrl = (params: ListPetsParams) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : String(value)); - } - }); - - const stringifiedParams = normalizedParams.toString(); - - return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/pets`; -}; - -/** - * @summary List all pets - */ -export const listPets = async ( - params: ListPetsParams, - options?: RequestInit, -): Promise => { - const res = await fetch(getListPetsUrl(params), { - ...options, - method: 'GET', - }); - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: listPetsResponse['data'] = body ? JSON.parse(body) : {}; - return { data, status: res.status, headers: res.headers } as listPetsResponse; -}; - -export type createPetsResponse200 = { - data: Pet; - status: 200; -}; - -export type createPetsResponseDefault = { - data: Error; - status: Exclude; -}; - -export type createPetsResponseSuccess = createPetsResponse200 & { - headers: Headers; -}; -export type createPetsResponseError = createPetsResponseDefault & { - headers: Headers; -}; - -export type createPetsResponse = - | createPetsResponseSuccess - | createPetsResponseError; - -export const getCreatePetsUrl = (params: CreatePetsParams) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : String(value)); - } - }); - - const stringifiedParams = normalizedParams.toString(); - - return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/pets`; -}; - -/** - * @summary Create a pet - */ -export const createPets = async ( - createPetsBody: CreatePetsBody, - params: CreatePetsParams, - options?: RequestInit, -): Promise => { - const res = await fetch(getCreatePetsUrl(params), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(createPetsBody), - }); - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: createPetsResponse['data'] = body ? JSON.parse(body) : {}; - return { - data, - status: res.status, - headers: res.headers, - } as createPetsResponse; -}; - -export type showPetByIdResponse200 = { - data: Pet; - status: 200; -}; - -export type showPetByIdResponseDefault = { - data: Error; - status: Exclude; -}; - -export type showPetByIdResponseSuccess = showPetByIdResponse200 & { - headers: Headers; -}; -export type showPetByIdResponseError = showPetByIdResponseDefault & { - headers: Headers; -}; - -export type showPetByIdResponse = - | showPetByIdResponseSuccess - | showPetByIdResponseError; - -export const getShowPetByIdUrl = (petId: string) => { - return `/pets/${petId}`; -}; - -/** - * @summary Info for a specific pet - */ -export const showPetById = async ( - petId: string, - options?: RequestInit, -): Promise => { - const res = await fetch(getShowPetByIdUrl(petId), { - ...options, - method: 'GET', - }); - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: showPetByIdResponse['data'] = body ? JSON.parse(body) : {}; - return { - data, - status: res.status, - headers: res.headers, - } as showPetByIdResponse; -}; - -export type deletePetByIdResponse204 = { - data: void; - status: 204; -}; - -export type deletePetByIdResponseDefault = { - data: Error; - status: Exclude; -}; - -export type deletePetByIdResponseSuccess = deletePetByIdResponse204 & { - headers: Headers; -}; -export type deletePetByIdResponseError = deletePetByIdResponseDefault & { - headers: Headers; -}; - -export type deletePetByIdResponse = - | deletePetByIdResponseSuccess - | deletePetByIdResponseError; - -export const getDeletePetByIdUrl = (petId: string) => { - return `/pets/${petId}`; -}; - -/** - * @summary Deletes a specific pet - */ -export const deletePetById = async ( - petId: string, - options?: RequestInit, -): Promise => { - const res = await fetch(getDeletePetByIdUrl(petId), { - ...options, - method: 'DELETE', - }); - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: deletePetByIdResponse['data'] = body - ? JSON.parse(body) - : undefined; - return { - data, - status: res.status, - headers: res.headers, - } as deletePetByIdResponse; -}; - -export type showPetWithOwnerResponse200 = { - data: PetWithTag; - status: 200; -}; - -export type showPetWithOwnerResponseDefault = { - data: Error; - status: Exclude; -}; - -export type showPetWithOwnerResponseSuccess = showPetWithOwnerResponse200 & { - headers: Headers; -}; -export type showPetWithOwnerResponseError = showPetWithOwnerResponseDefault & { - headers: Headers; -}; - -export type showPetWithOwnerResponse = - | showPetWithOwnerResponseSuccess - | showPetWithOwnerResponseError; - -export const getShowPetWithOwnerUrl = (petId: string) => { - return `/pets/${petId}/owner`; -}; - -/** - * @summary combinate nullable and $ref - */ -export const showPetWithOwner = async ( - petId: string, - options?: RequestInit, -): Promise => { - const res = await fetch(getShowPetWithOwnerUrl(petId), { - ...options, - method: 'GET', - }); - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: showPetWithOwnerResponse['data'] = body ? JSON.parse(body) : {}; - return { - data, - status: res.status, - headers: res.headers, - } as showPetWithOwnerResponse; -}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.apis.ts b/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.apis.ts deleted file mode 100644 index ef4e71b9f3..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.apis.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -export const createPetsApi = /(.*)\/pets(\?.*)?$/; - -export const deletePetByIdApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)$/; - -export const healthCheckApi = /(.*)\/health$/; - -export const listPetsApi = /(.*)\/pets(\?.*)?$/; - -export const showPetByIdApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)$/; - -export const showPetWithOwnerApi = /(.*)\/pets\/([A-Za-z0-9_\-.]+)\/owner$/; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.ts b/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.ts deleted file mode 100644 index c9e668f5cb..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/endpoints.ts +++ /dev/null @@ -1,362 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { - CreatePetsBody, - CreatePetsParams, - Error, - ListPetsParams, - Pet, - PetWithTag, - Pets, -} from './model'; - -export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; -export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; -export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; -export type HTTPStatusCode4xx = - | 400 - | 401 - | 402 - | 403 - | 404 - | 405 - | 406 - | 407 - | 408 - | 409 - | 410 - | 411 - | 412 - | 413 - | 414 - | 415 - | 416 - | 417 - | 418 - | 419 - | 420 - | 421 - | 422 - | 423 - | 424 - | 426 - | 428 - | 429 - | 431 - | 451; -export type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511; -export type HTTPStatusCodes = - | HTTPStatusCode1xx - | HTTPStatusCode2xx - | HTTPStatusCode3xx - | HTTPStatusCode4xx - | HTTPStatusCode5xx; - -export type listPetsResponse200 = { - data: Pets; - status: 200; -}; - -export type listPetsResponseDefault = { - data: Error; - status: Exclude; -}; - -export type listPetsResponseSuccess = listPetsResponse200 & { - headers: Headers; -}; -export type listPetsResponseError = listPetsResponseDefault & { - headers: Headers; -}; - -export type listPetsResponse = listPetsResponseSuccess | listPetsResponseError; - -export const getListPetsUrl = (params: ListPetsParams) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : String(value)); - } - }); - - const stringifiedParams = normalizedParams.toString(); - - return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/pets`; -}; - -/** - * @summary List all pets - */ -export const listPets = async ( - params: ListPetsParams, - options?: RequestInit, -): Promise => { - const res = await fetch(getListPetsUrl(params), { - ...options, - method: 'GET', - }); - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: listPetsResponse['data'] = body ? JSON.parse(body) : {}; - return { data, status: res.status, headers: res.headers } as listPetsResponse; -}; - -export type createPetsResponse200 = { - data: Pet; - status: 200; -}; - -export type createPetsResponseDefault = { - data: Error; - status: Exclude; -}; - -export type createPetsResponseSuccess = createPetsResponse200 & { - headers: Headers; -}; -export type createPetsResponseError = createPetsResponseDefault & { - headers: Headers; -}; - -export type createPetsResponse = - | createPetsResponseSuccess - | createPetsResponseError; - -export const getCreatePetsUrl = (params: CreatePetsParams) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : String(value)); - } - }); - - const stringifiedParams = normalizedParams.toString(); - - return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/pets`; -}; - -/** - * @summary Create a pet - */ -export const createPets = async ( - createPetsBody: CreatePetsBody, - params: CreatePetsParams, - options?: RequestInit, -): Promise => { - const res = await fetch(getCreatePetsUrl(params), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(createPetsBody), - }); - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: createPetsResponse['data'] = body ? JSON.parse(body) : {}; - return { - data, - status: res.status, - headers: res.headers, - } as createPetsResponse; -}; - -export type showPetByIdResponse200 = { - data: Pet; - status: 200; -}; - -export type showPetByIdResponseDefault = { - data: Error; - status: Exclude; -}; - -export type showPetByIdResponseSuccess = showPetByIdResponse200 & { - headers: Headers; -}; -export type showPetByIdResponseError = showPetByIdResponseDefault & { - headers: Headers; -}; - -export type showPetByIdResponse = - | showPetByIdResponseSuccess - | showPetByIdResponseError; - -export const getShowPetByIdUrl = (petId: string) => { - return `/pets/${petId}`; -}; - -/** - * @summary Info for a specific pet - */ -export const showPetById = async ( - petId: string, - options?: RequestInit, -): Promise => { - const res = await fetch(getShowPetByIdUrl(petId), { - ...options, - method: 'GET', - }); - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: showPetByIdResponse['data'] = body ? JSON.parse(body) : {}; - return { - data, - status: res.status, - headers: res.headers, - } as showPetByIdResponse; -}; - -export type deletePetByIdResponse204 = { - data: void; - status: 204; -}; - -export type deletePetByIdResponseDefault = { - data: Error; - status: Exclude; -}; - -export type deletePetByIdResponseSuccess = deletePetByIdResponse204 & { - headers: Headers; -}; -export type deletePetByIdResponseError = deletePetByIdResponseDefault & { - headers: Headers; -}; - -export type deletePetByIdResponse = - | deletePetByIdResponseSuccess - | deletePetByIdResponseError; - -export const getDeletePetByIdUrl = (petId: string) => { - return `/pets/${petId}`; -}; - -/** - * @summary Deletes a specific pet - */ -export const deletePetById = async ( - petId: string, - options?: RequestInit, -): Promise => { - const res = await fetch(getDeletePetByIdUrl(petId), { - ...options, - method: 'DELETE', - }); - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: deletePetByIdResponse['data'] = body - ? JSON.parse(body) - : undefined; - return { - data, - status: res.status, - headers: res.headers, - } as deletePetByIdResponse; -}; - -export type healthCheckResponse200 = { - data: string; - status: 200; -}; - -export type healthCheckResponseDefault = { - data: Error; - status: Exclude; -}; - -export type healthCheckResponseSuccess = healthCheckResponse200 & { - headers: Headers; -}; -export type healthCheckResponseError = healthCheckResponseDefault & { - headers: Headers; -}; - -export type healthCheckResponse = - | healthCheckResponseSuccess - | healthCheckResponseError; - -export const getHealthCheckUrl = () => { - return `/health`; -}; - -/** - * @summary health check - */ -export const healthCheck = async ( - options?: RequestInit, -): Promise => { - const res = await fetch(getHealthCheckUrl(), { - ...options, - method: 'GET', - }); - - const contentType = (res.headers.get('content-type') ?? '').toLowerCase(); - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: healthCheckResponse['data'] = body - ? contentType.includes('json') - ? JSON.parse(body) - : body - : {}; - return { - data, - status: res.status, - headers: res.headers, - } as healthCheckResponse; -}; - -export type showPetWithOwnerResponse200 = { - data: PetWithTag; - status: 200; -}; - -export type showPetWithOwnerResponseDefault = { - data: Error; - status: Exclude; -}; - -export type showPetWithOwnerResponseSuccess = showPetWithOwnerResponse200 & { - headers: Headers; -}; -export type showPetWithOwnerResponseError = showPetWithOwnerResponseDefault & { - headers: Headers; -}; - -export type showPetWithOwnerResponse = - | showPetWithOwnerResponseSuccess - | showPetWithOwnerResponseError; - -export const getShowPetWithOwnerUrl = (petId: string) => { - return `/pets/${petId}/owner`; -}; - -/** - * @summary combinate nullable and $ref - */ -export const showPetWithOwner = async ( - petId: string, - options?: RequestInit, -): Promise => { - const res = await fetch(getShowPetWithOwnerUrl(petId), { - ...options, - method: 'GET', - }); - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: showPetWithOwnerResponse['data'] = body ? JSON.parse(body) : {}; - return { - data, - status: res.status, - headers: res.headers, - } as showPetWithOwnerResponse; -}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/cat.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/cat.ts deleted file mode 100644 index 12cb113fa5..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/cat.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { CatType } from './catType'; - -export interface Cat { - petsRequested?: number; - type: CatType; -} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/catType.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/catType.ts deleted file mode 100644 index 3ffefb556b..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/catType.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type CatType = (typeof CatType)[keyof typeof CatType]; - -export const CatType = { - cat: 'cat', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsBody.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsBody.ts deleted file mode 100644 index 66f5dcd899..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsBody.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type CreatePetsBody = { - name: string; - tag: string; -}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsParams.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsParams.ts deleted file mode 100644 index 4866303333..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { CreatePetsSort } from './createPetsSort'; - -export type CreatePetsParams = { - /** - * How many items to return at one time (max 100) - */ - limit?: string; - /** - * Which property to sort by? - * Example: name sorts ASC while -name sorts DESC. - * - */ - sort: CreatePetsSort; -}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsSort.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsSort.ts deleted file mode 100644 index 3fa8bf869a..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/createPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type CreatePetsSort = - (typeof CreatePetsSort)[keyof typeof CreatePetsSort]; - -export const CreatePetsSort = { - name: 'name', - '-name': '-name', - email: 'email', - '-email': '-email', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshund.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshund.ts deleted file mode 100644 index 63f59b544c..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshund.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { DachshundBreed } from './dachshundBreed'; - -export interface Dachshund { - length: number; - breed: DachshundBreed; -} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshundBreed.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshundBreed.ts deleted file mode 100644 index cb96ff6641..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/dachshundBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type DachshundBreed = - (typeof DachshundBreed)[keyof typeof DachshundBreed]; - -export const DachshundBreed = { - Dachshund: 'Dachshund', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/dog.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/dog.ts deleted file mode 100644 index edf04cb115..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/dog.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { Dachshund } from './dachshund'; -import type { DogType } from './dogType'; -import type { Labradoodle } from './labradoodle'; - -export type Dog = - | (Labradoodle & { - barksPerMinute?: number; - type: DogType; - }) - | (Dachshund & { - barksPerMinute?: number; - type: DogType; - }); diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/dogType.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/dogType.ts deleted file mode 100644 index b7344d0cc0..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/dogType.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type DogType = (typeof DogType)[keyof typeof DogType]; - -export const DogType = { - dog: 'dog', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/error.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/error.ts deleted file mode 100644 index b0a03afbfd..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/error.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export interface Error { - code: number; - message: string; -} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/index.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/index.ts deleted file mode 100644 index ff7af2b0b2..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export * from './cat'; -export * from './catType'; -export * from './createPetsBody'; -export * from './createPetsParams'; -export * from './createPetsSort'; -export * from './dachshund'; -export * from './dachshundBreed'; -export * from './dog'; -export * from './dogType'; -export * from './error'; -export * from './labradoodle'; -export * from './labradoodleBreed'; -export * from './listPetsParams'; -export * from './listPetsSort'; -export * from './pet'; -export * from './petCallingCode'; -export * from './petCountry'; -export * from './pets'; -export * from './petWithTag'; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodle.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodle.ts deleted file mode 100644 index 359008145c..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodle.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { LabradoodleBreed } from './labradoodleBreed'; - -export interface Labradoodle { - cuteness: number; - breed: LabradoodleBreed; -} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodleBreed.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodleBreed.ts deleted file mode 100644 index 804aa239e7..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/labradoodleBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type LabradoodleBreed = - (typeof LabradoodleBreed)[keyof typeof LabradoodleBreed]; - -export const LabradoodleBreed = { - Labradoodle: 'Labradoodle', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsParams.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsParams.ts deleted file mode 100644 index f8a26309de..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { ListPetsSort } from './listPetsSort'; - -export type ListPetsParams = { - /** - * How many items to return at one time (max 100) - */ - limit?: string; - /** - * Which property to sort by? - * Example: name sorts ASC while -name sorts DESC. - * - */ - sort: ListPetsSort; -}; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsSort.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsSort.ts deleted file mode 100644 index d334807265..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/listPetsSort.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type ListPetsSort = (typeof ListPetsSort)[keyof typeof ListPetsSort]; - -export const ListPetsSort = { - name: 'name', - '-name': '-name', - email: 'email', - '-email': '-email', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/pet.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/pet.ts deleted file mode 100644 index 9892066bae..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/pet.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { Cat } from './cat'; -import type { Dog } from './dog'; -import type { PetCallingCode } from './petCallingCode'; -import type { PetCountry } from './petCountry'; - -export type Pet = - | (Dog & { - '@id'?: string; - id: number; - name: string; - tag?: string; - email?: string; - callingCode?: PetCallingCode; - country?: PetCountry; - }) - | (Cat & { - '@id'?: string; - id: number; - name: string; - tag?: string; - email?: string; - callingCode?: PetCallingCode; - country?: PetCountry; - }); diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/petCallingCode.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/petCallingCode.ts deleted file mode 100644 index 8c936dc7bf..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/petCallingCode.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type PetCallingCode = - (typeof PetCallingCode)[keyof typeof PetCallingCode]; - -export const PetCallingCode = { - '+33': '+33', - '+420': '+420', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/petCountry.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/petCountry.ts deleted file mode 100644 index 16ff760582..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/petCountry.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry]; - -export const PetCountry = { - "People's_Republic_of_China": "People's Republic of China", - Uruguay: 'Uruguay', -} as const; diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/petWithTag.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/petWithTag.ts deleted file mode 100644 index 89d5b99af4..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/petWithTag.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { Pet } from './pet'; - -export interface PetWithTag { - tag: string; - pet: Pet | null; -} diff --git a/tests/__snapshots__/fetch/petstore-url-matchers/model/pets.ts b/tests/__snapshots__/fetch/petstore-url-matchers/model/pets.ts deleted file mode 100644 index bd8268ca60..0000000000 --- a/tests/__snapshots__/fetch/petstore-url-matchers/model/pets.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Generated by orval v8.13.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import type { Pet } from './pet'; - -export type Pets = Pet[]; From fbdacb55b36b484fa00ee3d445cea5530a9346f1 Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Tue, 2 Jun 2026 06:27:44 +0200 Subject: [PATCH 07/11] fix(mock): dedupe shared array-item factories across operations Track factory names on ContextSpec. Revert single-mode import merge false positives. Co-authored-by: Cursor --- packages/core/src/types.ts | 6 ++ packages/core/src/writers/single-mode.ts | 25 +------ .../faker/getters/array-item-factory.test.ts | 73 ++++++++++++++----- .../src/faker/getters/array-item-factory.ts | 20 +++-- .../angular/custom-client/endpoints.ts | 11 +-- .../http-resource-zod-disabled/endpoints.ts | 15 ++-- .../angular/http-resource-zod/endpoints.ts | 15 ++-- .../angular/petstore/endpoints.ts | 6 +- .../angular/zod-schema-response/endpoints.ts | 6 +- .../axios/multi-arguments/endpoints.ts | 6 +- .../__snapshots__/axios/mutator/endpoints.ts | 6 +- .../__snapshots__/axios/petstore/endpoints.ts | 6 +- .../axios/zod-schema-response/endpoints.ts | 6 +- .../default/all-of-all-of/endpoints.ts | 3 +- .../default/all-of-strict/endpoints.ts | 4 +- .../default/combine-enum/combinedEnums.ts | 3 +- .../default/enums/native/endpoints.ts | 5 +- .../default/http-status-mocks/endpoints.ts | 7 +- .../default/nullable-oneof-enums/endpoints.ts | 3 +- .../default/one-of-nested/endpoints.ts | 13 ++-- .../__snapshots__/default/one-of/endpoints.ts | 4 +- .../default/petstore-transformer/endpoints.ts | 6 +- .../default/runtime-mock-delay/endpoints.ts | 6 +- .../form-data-optional-request/endpoints.ts | 4 +- .../form-data-with-custom-fetch/endpoints.ts | 4 +- .../endpoints.ts | 6 +- .../fetch/multi-arguments/endpoints.ts | 6 +- .../__snapshots__/fetch/mutator/endpoints.ts | 6 +- .../__snapshots__/fetch/petstore/endpoints.ts | 6 +- .../endpoints.ts | 4 +- .../discriminator-oneof-allof/endpoints.ts | 4 +- .../discriminator-oneof-union/endpoints.ts | 4 +- .../mock/faker-array-items/endpoints.ts | 47 ++++++++++-- .../mock/issue-3200/endpoints.ts | 4 +- .../endpoints.ts | 4 +- .../endpoints.ts | 4 +- .../__snapshots__/mock/petstore/endpoints.ts | 6 +- .../mock/typelessEnum/typelessEnums.ts | 3 +- .../mock/zod-schema-response/endpoints.ts | 6 +- .../react-query/basic/endpoints.ts | 6 +- .../react-query/deprecated/endpoints.ts | 12 +-- .../react-query/error-type/endpoints.ts | 6 +- .../form-data-with-hook/endpoints.ts | 4 +- .../form-data-with-mutator/endpoints.ts | 4 +- .../react-query/form-data/endpoints.ts | 4 +- .../endpoints.ts | 6 +- .../react-query/invalidates/endpoints.ts | 6 +- .../react-query/mockOverride/endpoints.ts | 6 +- .../react-query/mockWithoutDelay/endpoints.ts | 6 +- .../react-query/mutator-client/endpoints.ts | 6 +- .../mutator-multi-arguments/endpoints.ts | 6 +- .../react-query/mutator/endpoints.ts | 6 +- .../zod-schema-response/endpoints.ts | 6 +- .../endpoints.ts | 6 +- .../svelte-query/invalidates/endpoints.ts | 6 +- .../svelte-query/mutator/endpoints.ts | 6 +- .../svelte-query/petstore/endpoints.ts | 6 +- .../zod-schema-response/endpoints.ts | 6 +- .../swr/custom-client/endpoints.ts | 6 +- .../form-data-optional-request/endpoints.ts | 4 +- .../endpoints.ts | 6 +- tests/__snapshots__/swr/mutator/endpoints.ts | 6 +- tests/__snapshots__/swr/petstore/endpoints.ts | 6 +- .../swr/zod-schema-response/endpoints.ts | 6 +- .../all-params-optional/endpoints.ts | 6 +- .../endpoints.ts | 6 +- .../endpoints.ts | 6 +- .../vue-query/mutator/endpoints.ts | 6 +- .../vue-query/petstore/endpoints.ts | 6 +- .../url-encode-parameters/endpoints.ts | 6 +- .../zod-schema-response/endpoints.ts | 6 +- tests/__snapshots__/zod/petstore/endpoints.ts | 10 +-- tests/specifications/faker-array-items.yaml | 24 ++++++ 73 files changed, 308 insertions(+), 289 deletions(-) diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 2dc8f18ef0..a95087c3b2 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -1117,6 +1117,12 @@ export interface ContextSpec { * entries or generic parameter placeholders. Populated by `buildDynamicScope`. */ dynamicScope?: Partial>; + /** + * Tracks array-item mock factory names already emitted in the current output + * file. Populated by `@orval/mock` when `arrayItems: true` so shared `$ref` + * item factories are not re-declared per operation. + */ + arrayItemMockFactories?: Set; } /** diff --git a/packages/core/src/writers/single-mode.ts b/packages/core/src/writers/single-mode.ts index 294f628555..f1e7e5accb 100644 --- a/packages/core/src/writers/single-mode.ts +++ b/packages/core/src/writers/single-mode.ts @@ -76,26 +76,7 @@ export async function writeSingleMode({ output.tsconfig, ); - const implementationForImports = - implementationMock.length > 0 - ? `${implementation}\n${implementationMock}` - : implementation; - - const mergedImports = [...imports]; - for (const mockImport of importsMock) { - if ( - mergedImports.some( - (imp) => - imp.name === mockImport.name && - (imp.alias ?? '') === (mockImport.alias ?? ''), - ) - ) { - continue; - } - mergedImports.push(mockImport); - } - - const implementationImports = mergedImports.filter((imp) => { + const implementationImports = imports.filter((imp) => { const searchWords = [imp.alias, imp.name] .filter((part): part is string => Boolean(part?.length)) .map((part) => escapeRegExp(part)) @@ -105,7 +86,7 @@ export async function writeSingleMode({ } return new RegExp(String.raw`\b(${searchWords})\b`, 'g').test( - implementationForImports, + implementation, ); }); @@ -144,7 +125,7 @@ export async function writeSingleMode({ data += builder.imports({ client: output.client, - implementation: implementationForImports, + implementation, imports: importsForBuilder, projectName, hasSchemaDir: !!output.schemas, diff --git a/packages/mock/src/faker/getters/array-item-factory.test.ts b/packages/mock/src/faker/getters/array-item-factory.test.ts index 18f0273a35..acfdf8a78c 100644 --- a/packages/mock/src/faker/getters/array-item-factory.test.ts +++ b/packages/mock/src/faker/getters/array-item-factory.test.ts @@ -6,16 +6,17 @@ import { shouldExtractArrayItemFactories, } from './array-item-factory'; -const contextWithArrayItems = { - output: { - mock: { - generators: [{ type: 'faker', arrayItems: true }], - }, - override: { - components: { schemas: { suffix: '', itemSuffix: 'Item' } }, +const createContextWithArrayItems = (): ContextSpec => + ({ + output: { + mock: { + generators: [{ type: 'faker', arrayItems: true }], + }, + override: { + components: { schemas: { suffix: '', itemSuffix: 'Item' } }, + }, }, - }, -} as unknown as ContextSpec; + }) as unknown as ContextSpec; const contextWithoutArrayItems = { output: { @@ -30,7 +31,9 @@ const contextWithoutArrayItems = { describe('shouldExtractArrayItemFactories', () => { it('returns true when arrayItems is enabled', () => { - expect(shouldExtractArrayItemFactories(contextWithArrayItems)).toBe(true); + expect(shouldExtractArrayItemFactories(createContextWithArrayItems())).toBe( + true, + ); }); it('returns false when arrayItems is not enabled', () => { @@ -51,7 +54,7 @@ describe('extractArrayItemMock', () => { operationId: 'getTenantsByRef', mapValue: '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}', - context: contextWithArrayItems, + context: createContextWithArrayItems(), splitMockImplementations, imports, }); @@ -83,7 +86,7 @@ describe('extractArrayItemMock', () => { operationId: 'getTenants', mapValue: '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}', - context: contextWithArrayItems, + context: createContextWithArrayItems(), splitMockImplementations, imports: [], }); @@ -97,7 +100,8 @@ describe('extractArrayItemMock', () => { ); }); - it('deduplicates factories with the same name', () => { + it('deduplicates factories with the same name within one operation', () => { + const context = createContextWithArrayItems(); const splitMockImplementations: string[] = []; const mapValue = '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}'; @@ -107,7 +111,7 @@ describe('extractArrayItemMock', () => { propertyName: 'value', operationId: 'getTenantsByRef', mapValue, - context: contextWithArrayItems, + context, splitMockImplementations, imports: [], }); @@ -116,7 +120,7 @@ describe('extractArrayItemMock', () => { propertyName: 'items', operationId: 'getTenantsByRef', mapValue, - context: contextWithArrayItems, + context, splitMockImplementations, imports: [], }); @@ -124,6 +128,39 @@ describe('extractArrayItemMock', () => { expect(splitMockImplementations).toHaveLength(1); }); + it('deduplicates $ref factories across operations in the same output file', () => { + const context = createContextWithArrayItems(); + const mapValue = + '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}'; + const splitMockImplementationsA: string[] = []; + const splitMockImplementationsB: string[] = []; + + extractArrayItemMock({ + items: { $ref: '#/components/schemas/TenantResponseModelDto' }, + propertyName: 'value', + operationId: 'getTenantsA', + mapValue, + context, + splitMockImplementations: splitMockImplementationsA, + imports: [], + }); + extractArrayItemMock({ + items: { $ref: '#/components/schemas/TenantResponseModelDto' }, + propertyName: 'value', + operationId: 'getTenantsB', + mapValue, + context, + splitMockImplementations: splitMockImplementationsB, + imports: [], + }); + + expect(splitMockImplementationsA).toHaveLength(1); + expect(splitMockImplementationsB).toHaveLength(0); + expect( + context.arrayItemMockFactories?.has('getTenantResponseModelDtoMock'), + ).toBe(true); + }); + it('skips primitive array items', () => { const splitMockImplementations: string[] = []; @@ -132,7 +169,7 @@ describe('extractArrayItemMock', () => { propertyName: 'tags', operationId: 'getTenants', mapValue: 'faker.string.alpha({length: {min: 10, max: 20}})', - context: contextWithArrayItems, + context: createContextWithArrayItems(), splitMockImplementations, imports: [], }); @@ -149,7 +186,7 @@ describe('extractArrayItemMock', () => { propertyName: 'value', operationId: 'getTenantsByRef', mapValue: '{...getTenantResponseModelDtoMock()}', - context: contextWithArrayItems, + context: createContextWithArrayItems(), splitMockImplementations, imports: [], }); @@ -174,7 +211,7 @@ describe('extractArrayItemMock', () => { operationId: 'getTenants', mapValue: '{id: faker.string.uuid(), pet: {...getPetMock()}, name: faker.string.alpha({length: {min: 10, max: 20}})}', - context: contextWithArrayItems, + context: createContextWithArrayItems(), splitMockImplementations, imports: [], }); diff --git a/packages/mock/src/faker/getters/array-item-factory.ts b/packages/mock/src/faker/getters/array-item-factory.ts index 133f4cd5c4..a6d0e40966 100644 --- a/packages/mock/src/faker/getters/array-item-factory.ts +++ b/packages/mock/src/faker/getters/array-item-factory.ts @@ -13,6 +13,13 @@ import type { MockSchema } from '../../types'; import { overrideVarName } from './object'; import { extractItemsRef } from './scalar'; +function getFileLevelExtractedFactories(context: ContextSpec): Set { + if (!context.arrayItemMockFactories) { + context.arrayItemMockFactories = new Set(); + } + return context.arrayItemMockFactories; +} + /** * True when the active faker generator entry opts into reusable array-item * mock factories for object-like array item schemas in operation responses. @@ -185,18 +192,21 @@ export function extractArrayItemMock({ } const { factoryName, typeName } = names; - - if ( - !splitMockImplementations.some((f) => + const fileLevelFactories = getFileLevelExtractedFactories(context); + const alreadyExtracted = + fileLevelFactories.has(factoryName) || + splitMockImplementations.some((f) => f.includes(`export const ${factoryName}`), - ) - ) { + ); + + if (!alreadyExtracted) { const args = `${overrideVarName}: Partial<${typeName}> = {}`; const spreadPrefix = mapValue.startsWith('...') ? '' : '...'; const func = `export const ${factoryName} = (${args}): ${typeName} => ` + `({${spreadPrefix}${mapValue}, ...${overrideVarName}});`; splitMockImplementations.push(func); + fileLevelFactories.add(factoryName); } imports.push({ name: typeName }); diff --git a/tests/__snapshots__/angular/custom-client/endpoints.ts b/tests/__snapshots__/angular/custom-client/endpoints.ts index a91d0483d0..26895f93f6 100644 --- a/tests/__snapshots__/angular/custom-client/endpoints.ts +++ b/tests/__snapshots__/angular/custom-client/endpoints.ts @@ -4,20 +4,13 @@ * Swagger Petstore * OpenAPI spec version: 1.0.0 */ -import { - HttpClient, - HttpResponse as AngularHttpResponse, -} from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; import { Injectable, inject } from '@angular/core'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -29,6 +22,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import listPetsMutator from '../../../mutators/custom-client-angular'; import createPetsMutator from '../../../mutators/custom-client-angular'; import showPetByIdMutator from '../../../mutators/custom-client-angular'; diff --git a/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts b/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts index 31119776d2..9c2a9612fa 100644 --- a/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts +++ b/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts @@ -37,19 +37,11 @@ import { Pets } from './model'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams } from './model'; -import { - map -} from 'rxjs'; - import { faker } from '@faker-js/faker'; @@ -62,6 +54,13 @@ import type { RequestHandlerOptions } from 'msw'; +import type { + Cat, + Dachshund, + Dog, + Labradoodle +} from './model'; + export type OrvalHttpResourceOptions = TOmitParse extends true ? Omit, 'parse'> : HttpResourceOptions; diff --git a/tests/__snapshots__/angular/http-resource-zod/endpoints.ts b/tests/__snapshots__/angular/http-resource-zod/endpoints.ts index 31119776d2..9c2a9612fa 100644 --- a/tests/__snapshots__/angular/http-resource-zod/endpoints.ts +++ b/tests/__snapshots__/angular/http-resource-zod/endpoints.ts @@ -37,19 +37,11 @@ import { Pets } from './model'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams } from './model'; -import { - map -} from 'rxjs'; - import { faker } from '@faker-js/faker'; @@ -62,6 +54,13 @@ import type { RequestHandlerOptions } from 'msw'; +import type { + Cat, + Dachshund, + Dog, + Labradoodle +} from './model'; + export type OrvalHttpResourceOptions = TOmitParse extends true ? Omit, 'parse'> : HttpResourceOptions; diff --git a/tests/__snapshots__/angular/petstore/endpoints.ts b/tests/__snapshots__/angular/petstore/endpoints.ts index 8a8473203d..608ce620d2 100644 --- a/tests/__snapshots__/angular/petstore/endpoints.ts +++ b/tests/__snapshots__/angular/petstore/endpoints.ts @@ -16,12 +16,8 @@ import { Injectable, inject } from '@angular/core'; import { Observable } from 'rxjs'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -33,6 +29,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + interface HttpClientOptions { readonly headers?: HttpHeaders | Record; readonly context?: HttpContext; diff --git a/tests/__snapshots__/angular/zod-schema-response/endpoints.ts b/tests/__snapshots__/angular/zod-schema-response/endpoints.ts index 49a934c68e..541f17e0e4 100644 --- a/tests/__snapshots__/angular/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/angular/zod-schema-response/endpoints.ts @@ -16,12 +16,8 @@ import { Injectable, inject } from '@angular/core'; import { Observable } from 'rxjs'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -33,6 +29,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + interface HttpClientOptions { readonly headers?: HttpHeaders | Record; readonly context?: HttpContext; diff --git a/tests/__snapshots__/axios/multi-arguments/endpoints.ts b/tests/__snapshots__/axios/multi-arguments/endpoints.ts index 4f22cb926e..160c03b9eb 100644 --- a/tests/__snapshots__/axios/multi-arguments/endpoints.ts +++ b/tests/__snapshots__/axios/multi-arguments/endpoints.ts @@ -5,12 +5,8 @@ * OpenAPI spec version: 1.0.0 */ import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -22,6 +18,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import listPetsMutator from '../../../mutators/multi-arguments'; import createPetsMutator from '../../../mutators/multi-arguments'; import showPetByIdMutator from '../../../mutators/multi-arguments'; diff --git a/tests/__snapshots__/axios/mutator/endpoints.ts b/tests/__snapshots__/axios/mutator/endpoints.ts index 6c5f6f22d6..72273d2258 100644 --- a/tests/__snapshots__/axios/mutator/endpoints.ts +++ b/tests/__snapshots__/axios/mutator/endpoints.ts @@ -5,12 +5,8 @@ * OpenAPI spec version: 1.0.0 */ import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -22,6 +18,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import listPetsMutator from '../../../mutators/custom-client'; import createPetsMutator from '../../../mutators/custom-client'; import type { BodyType as CreatePetsBodyType } from '../../../mutators/custom-client'; diff --git a/tests/__snapshots__/axios/petstore/endpoints.ts b/tests/__snapshots__/axios/petstore/endpoints.ts index 203b3c43d7..9e3a505241 100644 --- a/tests/__snapshots__/axios/petstore/endpoints.ts +++ b/tests/__snapshots__/axios/petstore/endpoints.ts @@ -8,12 +8,8 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,6 +21,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export const getSwaggerPetstore = (axiosInstance: AxiosInstance = axios) => { /** * @summary List all pets diff --git a/tests/__snapshots__/axios/zod-schema-response/endpoints.ts b/tests/__snapshots__/axios/zod-schema-response/endpoints.ts index 6d42341db3..204d6688e8 100644 --- a/tests/__snapshots__/axios/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/axios/zod-schema-response/endpoints.ts @@ -8,12 +8,8 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,6 +21,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export const getSwaggerPetstore = (axiosInstance: AxiosInstance = axios) => { /** * @summary List all pets diff --git a/tests/__snapshots__/default/all-of-all-of/endpoints.ts b/tests/__snapshots__/default/all-of-all-of/endpoints.ts index d8af822e71..8c8953d3d8 100644 --- a/tests/__snapshots__/default/all-of-all-of/endpoints.ts +++ b/tests/__snapshots__/default/all-of-all-of/endpoints.ts @@ -7,7 +7,6 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import { NoteType } from './model'; import type { PrivateNote, SharedNote } from './model'; import { faker } from '@faker-js/faker'; @@ -15,6 +14,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import { NoteType } from './model'; + export const createSharedNote = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/default/all-of-strict/endpoints.ts b/tests/__snapshots__/default/all-of-strict/endpoints.ts index 5478759283..087c476997 100644 --- a/tests/__snapshots__/default/all-of-strict/endpoints.ts +++ b/tests/__snapshots__/default/all-of-strict/endpoints.ts @@ -6,13 +6,13 @@ */ import * as zod from 'zod'; -import type { PostFish200 } from './model'; - import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { PostFish200 } from './model'; + export const PostFishBody = zod .object({ name: zod.string(), diff --git a/tests/__snapshots__/default/combine-enum/combinedEnums.ts b/tests/__snapshots__/default/combine-enum/combinedEnums.ts index e29fee6710..cd20d6cfa4 100644 --- a/tests/__snapshots__/default/combine-enum/combinedEnums.ts +++ b/tests/__snapshots__/default/combine-enum/combinedEnums.ts @@ -7,7 +7,6 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import { Colors1, Colors2 } from './schemas'; import type { ColorObject } from './schemas'; import { faker } from '@faker-js/faker'; @@ -15,6 +14,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import { Colors1, Colors2 } from './schemas'; + /** * @summary sample colors */ diff --git a/tests/__snapshots__/default/enums/native/endpoints.ts b/tests/__snapshots__/default/enums/native/endpoints.ts index a51d8a1796..60d583825a 100644 --- a/tests/__snapshots__/default/enums/native/endpoints.ts +++ b/tests/__snapshots__/default/enums/native/endpoints.ts @@ -8,15 +8,12 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import type { - Bulldog, CatDog, Dog, DogGroup, Duck, - RequiredBulldog, RequiredCat, RequiredDog, - RequiredSiamese, } from './model'; import { faker } from '@faker-js/faker'; @@ -24,6 +21,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Bulldog, RequiredBulldog, RequiredSiamese } from './model'; + /** * @summary sample cat */ diff --git a/tests/__snapshots__/default/http-status-mocks/endpoints.ts b/tests/__snapshots__/default/http-status-mocks/endpoints.ts index ddd6d71121..c703cbd233 100644 --- a/tests/__snapshots__/default/http-status-mocks/endpoints.ts +++ b/tests/__snapshots__/default/http-status-mocks/endpoints.ts @@ -8,13 +8,8 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -26,6 +21,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Error, Labradoodle } from './model'; + /** * @summary List all pets */ diff --git a/tests/__snapshots__/default/nullable-oneof-enums/endpoints.ts b/tests/__snapshots__/default/nullable-oneof-enums/endpoints.ts index 9a8d00229d..5ed4804a6b 100644 --- a/tests/__snapshots__/default/nullable-oneof-enums/endpoints.ts +++ b/tests/__snapshots__/default/nullable-oneof-enums/endpoints.ts @@ -8,7 +8,6 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import { BlankEnum, HelloEnum, NotNullEnum } from './model'; import type { Item1, Item3, @@ -22,6 +21,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import { BlankEnum, HelloEnum, NotNullEnum } from './model'; + export const getItems = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/default/one-of-nested/endpoints.ts b/tests/__snapshots__/default/one-of-nested/endpoints.ts index 22c345de71..6affe1499b 100644 --- a/tests/__snapshots__/default/one-of-nested/endpoints.ts +++ b/tests/__snapshots__/default/one-of-nested/endpoints.ts @@ -8,19 +8,20 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; +import type { Example } from './model'; + +import { faker } from '@faker-js/faker'; + +import { HttpResponse, http } from 'msw'; +import type { RequestHandlerOptions } from 'msw'; + import type { - Example, Example1, Example2, PointInFutureAbsolute, PointInFutureRelative, } from './model'; -import { faker } from '@faker-js/faker'; - -import { HttpResponse, http } from 'msw'; -import type { RequestHandlerOptions } from 'msw'; - export const example = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/default/one-of/endpoints.ts b/tests/__snapshots__/default/one-of/endpoints.ts index 3c315572b1..a25f07b8d2 100644 --- a/tests/__snapshots__/default/one-of/endpoints.ts +++ b/tests/__snapshots__/default/one-of/endpoints.ts @@ -7,13 +7,15 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { Cat, Pet } from './model'; +import type { Pet } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat } from './model'; + /** * oneOf with nullable object. */ diff --git a/tests/__snapshots__/default/petstore-transformer/endpoints.ts b/tests/__snapshots__/default/petstore-transformer/endpoints.ts index 366659445f..03ff64ff56 100644 --- a/tests/__snapshots__/default/petstore-transformer/endpoints.ts +++ b/tests/__snapshots__/default/petstore-transformer/endpoints.ts @@ -8,12 +8,8 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,6 +21,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + /** * @summary List all pets */ diff --git a/tests/__snapshots__/default/runtime-mock-delay/endpoints.ts b/tests/__snapshots__/default/runtime-mock-delay/endpoints.ts index 074a0a6499..08585f7e3d 100644 --- a/tests/__snapshots__/default/runtime-mock-delay/endpoints.ts +++ b/tests/__snapshots__/default/runtime-mock-delay/endpoints.ts @@ -8,12 +8,8 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,6 +21,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, delay, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + /** * @summary List all pets */ diff --git a/tests/__snapshots__/fetch/form-data-optional-request/endpoints.ts b/tests/__snapshots__/fetch/form-data-optional-request/endpoints.ts index 48fbf9f8b2..43da987e60 100644 --- a/tests/__snapshots__/fetch/form-data-optional-request/endpoints.ts +++ b/tests/__snapshots__/fetch/form-data-optional-request/endpoints.ts @@ -4,13 +4,15 @@ * Swagger Petstore * OpenAPI spec version: 1.0.0 */ -import type { Error, Pet, PetBase, PetExtended } from './model'; +import type { Error, Pet } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { PetBase, PetExtended } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/fetch/form-data-with-custom-fetch/endpoints.ts b/tests/__snapshots__/fetch/form-data-with-custom-fetch/endpoints.ts index 5d31cb0b9a..565667060a 100644 --- a/tests/__snapshots__/fetch/form-data-with-custom-fetch/endpoints.ts +++ b/tests/__snapshots__/fetch/form-data-with-custom-fetch/endpoints.ts @@ -4,13 +4,15 @@ * Swagger Petstore * OpenAPI spec version: 1.0.0 */ -import type { Error, Pet, PetBase, PetExtended } from './model'; +import type { Error, Pet } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { PetBase, PetExtended } from './model'; + import { customFetch } from '../../../mutators/custom-fetch'; export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; diff --git a/tests/__snapshots__/fetch/include-http-status-return-type/endpoints.ts b/tests/__snapshots__/fetch/include-http-status-return-type/endpoints.ts index ceab8d557e..32f63844c1 100644 --- a/tests/__snapshots__/fetch/include-http-status-return-type/endpoints.ts +++ b/tests/__snapshots__/fetch/include-http-status-return-type/endpoints.ts @@ -5,12 +5,8 @@ * OpenAPI spec version: 1.0.0 */ import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -22,6 +18,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export const getListPetsUrl = (params: ListPetsParams) => { const normalizedParams = new URLSearchParams(); diff --git a/tests/__snapshots__/fetch/multi-arguments/endpoints.ts b/tests/__snapshots__/fetch/multi-arguments/endpoints.ts index ee56d98e4c..fbc6d06b4b 100644 --- a/tests/__snapshots__/fetch/multi-arguments/endpoints.ts +++ b/tests/__snapshots__/fetch/multi-arguments/endpoints.ts @@ -5,13 +5,9 @@ * OpenAPI spec version: 1.0.0 */ import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -23,6 +19,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/fetch/mutator/endpoints.ts b/tests/__snapshots__/fetch/mutator/endpoints.ts index 8728386981..27610b07ed 100644 --- a/tests/__snapshots__/fetch/mutator/endpoints.ts +++ b/tests/__snapshots__/fetch/mutator/endpoints.ts @@ -5,13 +5,9 @@ * OpenAPI spec version: 1.0.0 */ import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -23,6 +19,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customFetch } from '../../../mutators/custom-fetch'; export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; diff --git a/tests/__snapshots__/fetch/petstore/endpoints.ts b/tests/__snapshots__/fetch/petstore/endpoints.ts index ee56d98e4c..fbc6d06b4b 100644 --- a/tests/__snapshots__/fetch/petstore/endpoints.ts +++ b/tests/__snapshots__/fetch/petstore/endpoints.ts @@ -5,13 +5,9 @@ * OpenAPI spec version: 1.0.0 */ import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -23,6 +19,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/mock/discriminator-oneof-allof-inherited/endpoints.ts b/tests/__snapshots__/mock/discriminator-oneof-allof-inherited/endpoints.ts index 5370782ef2..9c6e9ae1de 100644 --- a/tests/__snapshots__/mock/discriminator-oneof-allof-inherited/endpoints.ts +++ b/tests/__snapshots__/mock/discriminator-oneof-allof-inherited/endpoints.ts @@ -7,13 +7,15 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { Animal, Cat, Dog } from './model'; +import type { Animal } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dog } from './model'; + export const getAnimal = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/mock/discriminator-oneof-allof/endpoints.ts b/tests/__snapshots__/mock/discriminator-oneof-allof/endpoints.ts index 3386ab236b..0e43383d21 100644 --- a/tests/__snapshots__/mock/discriminator-oneof-allof/endpoints.ts +++ b/tests/__snapshots__/mock/discriminator-oneof-allof/endpoints.ts @@ -7,13 +7,15 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { DiscriminatorTest, Item1, Item2, Item3 } from './model'; +import type { DiscriminatorTest } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Item1, Item2, Item3 } from './model'; + export const getTest = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/mock/discriminator-oneof-union/endpoints.ts b/tests/__snapshots__/mock/discriminator-oneof-union/endpoints.ts index c6390dadc6..8441084f1f 100644 --- a/tests/__snapshots__/mock/discriminator-oneof-union/endpoints.ts +++ b/tests/__snapshots__/mock/discriminator-oneof-union/endpoints.ts @@ -7,13 +7,15 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { DiscriminatorTest, Item1, Item2, Item3 } from './model'; +import type { DiscriminatorTest } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Item1, Item2, Item3 } from './model'; + export const getTest = ( options?: AxiosRequestConfig, ): Promise> => { diff --git a/tests/__snapshots__/mock/faker-array-items/endpoints.ts b/tests/__snapshots__/mock/faker-array-items/endpoints.ts index d2cfa1112a..50cbc60bec 100644 --- a/tests/__snapshots__/mock/faker-array-items/endpoints.ts +++ b/tests/__snapshots__/mock/faker-array-items/endpoints.ts @@ -7,15 +7,12 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { - GetTenants200, - GetTenants200ValueItem, - TenantListResponse, - TenantResponseModelDto, -} from './model'; +import type { GetTenants200, TenantListResponse } from './model'; import { faker } from '@faker-js/faker'; +import type { GetTenants200ValueItem, TenantResponseModelDto } from './model'; + export const getFakerArrayItemFactories = ( axiosInstance: AxiosInstance = axios, ) => { @@ -31,10 +28,24 @@ export const getFakerArrayItemFactories = ( return axiosInstance.get(`/tenants-by-ref`, options); }; - return { getTenants, getTenantsByRef }; + const getTenantsA = ( + options?: AxiosRequestConfig, + ): Promise> => { + return axiosInstance.get(`/tenants-a`, options); + }; + + const getTenantsB = ( + options?: AxiosRequestConfig, + ): Promise> => { + return axiosInstance.get(`/tenants-b`, options); + }; + + return { getTenants, getTenantsByRef, getTenantsA, getTenantsB }; }; export type GetTenantsResult = AxiosResponse; export type GetTenantsByRefResult = AxiosResponse; +export type GetTenantsAResult = AxiosResponse; +export type GetTenantsBResult = AxiosResponse; export const getGetTenantsResponseValueItemMock = ( overrideResponse: Partial = {}, @@ -77,3 +88,25 @@ export const getGetTenantsByRefResponseMock = ( count: faker.number.int(), ...overrideResponse, }); + +export const getGetTenantsAResponseMock = ( + overrideResponse: Partial> = {}, +): TenantListResponse => ({ + value: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ ...getTenantResponseModelDtoMock() })), + count: faker.number.int(), + ...overrideResponse, +}); + +export const getGetTenantsBResponseMock = ( + overrideResponse: Partial> = {}, +): TenantListResponse => ({ + value: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ ...getTenantResponseModelDtoMock() })), + count: faker.number.int(), + ...overrideResponse, +}); diff --git a/tests/__snapshots__/mock/issue-3200/endpoints.ts b/tests/__snapshots__/mock/issue-3200/endpoints.ts index bea56b0c9d..e05a6ef7ea 100644 --- a/tests/__snapshots__/mock/issue-3200/endpoints.ts +++ b/tests/__snapshots__/mock/issue-3200/endpoints.ts @@ -17,10 +17,10 @@ import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { StringToIntegerMap, StringToNumberMap } from './model'; -import { getIntegerLikeMock, getNumberLikeMock } from './model/index.faker'; - import { faker } from '@faker-js/faker'; +import { getIntegerLikeMock, getNumberLikeMock } from './model/index.faker'; + export const getIssue3200 = (axiosInstance: AxiosInstance = axios) => { const getIntegerMap = ( options?: AxiosRequestConfig, diff --git a/tests/__snapshots__/mock/msw-mixed-content-union-each-status/endpoints.ts b/tests/__snapshots__/mock/msw-mixed-content-union-each-status/endpoints.ts index f7f75ed98a..edc594039b 100644 --- a/tests/__snapshots__/mock/msw-mixed-content-union-each-status/endpoints.ts +++ b/tests/__snapshots__/mock/msw-mixed-content-union-each-status/endpoints.ts @@ -7,13 +7,15 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { Error, Pet } from './model'; +import type { Pet } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Error } from './model'; + export const getMSWMixedContentEachStatusRegression = ( axiosInstance: AxiosInstance = axios, ) => { diff --git a/tests/__snapshots__/mock/petstore-faker-schemas-and-ops/endpoints.ts b/tests/__snapshots__/mock/petstore-faker-schemas-and-ops/endpoints.ts index 25c1c458ce..8821a72421 100644 --- a/tests/__snapshots__/mock/petstore-faker-schemas-and-ops/endpoints.ts +++ b/tests/__snapshots__/mock/petstore-faker-schemas-and-ops/endpoints.ts @@ -16,10 +16,10 @@ import type { Pets, } from './model'; -import { getCatMock, getDogMock, getPetMock } from './model/index.faker'; - import { faker } from '@faker-js/faker'; +import { getCatMock, getDogMock, getPetMock } from './model/index.faker'; + export const getSwaggerPetstore = (axiosInstance: AxiosInstance = axios) => { /** * @summary List all pets diff --git a/tests/__snapshots__/mock/petstore/endpoints.ts b/tests/__snapshots__/mock/petstore/endpoints.ts index 1b5f834684..1fe1ce2602 100644 --- a/tests/__snapshots__/mock/petstore/endpoints.ts +++ b/tests/__snapshots__/mock/petstore/endpoints.ts @@ -8,12 +8,8 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,6 +21,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, delay, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export const getSwaggerPetstore = (axiosInstance: AxiosInstance = axios) => { /** * @summary List all pets diff --git a/tests/__snapshots__/mock/typelessEnum/typelessEnums.ts b/tests/__snapshots__/mock/typelessEnum/typelessEnums.ts index 9b2be28bec..48711a8b4a 100644 --- a/tests/__snapshots__/mock/typelessEnum/typelessEnums.ts +++ b/tests/__snapshots__/mock/typelessEnum/typelessEnums.ts @@ -7,7 +7,6 @@ import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import { Colors1, Colors2 } from './schemas'; import type { ColorObject } from './schemas'; import { faker } from '@faker-js/faker'; @@ -15,6 +14,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import { Colors1, Colors2 } from './schemas'; + /** * @summary sample colors */ diff --git a/tests/__snapshots__/mock/zod-schema-response/endpoints.ts b/tests/__snapshots__/mock/zod-schema-response/endpoints.ts index 6d42341db3..204d6688e8 100644 --- a/tests/__snapshots__/mock/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/mock/zod-schema-response/endpoints.ts @@ -8,12 +8,8 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -25,6 +21,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export const getSwaggerPetstore = (axiosInstance: AxiosInstance = axios) => { /** * @summary List all pets diff --git a/tests/__snapshots__/react-query/basic/endpoints.ts b/tests/__snapshots__/react-query/basic/endpoints.ts index 5555f90fbb..6391918fde 100644 --- a/tests/__snapshots__/react-query/basic/endpoints.ts +++ b/tests/__snapshots__/react-query/basic/endpoints.ts @@ -21,14 +21,10 @@ import type { } from '@tanstack/react-query'; import type { - Cat, CreatePetsBody, CreatePetsHeaders, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsHeaders, ListPetsParams, Pet, @@ -41,6 +37,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/react-query/deprecated/endpoints.ts b/tests/__snapshots__/react-query/deprecated/endpoints.ts index 4d288f185d..b40c8e1283 100644 --- a/tests/__snapshots__/react-query/deprecated/endpoints.ts +++ b/tests/__snapshots__/react-query/deprecated/endpoints.ts @@ -17,21 +17,15 @@ import type { UseQueryResult, } from '@tanstack/react-query'; -import type { - Cat, - Dachshund, - Dog, - Error, - Labradoodle, - ListPetsParams, - Pets, -} from './model'; +import type { Error, ListPetsParams, Pets } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/react-query/error-type/endpoints.ts b/tests/__snapshots__/react-query/error-type/endpoints.ts index 292e4a5b7b..a32ed95e97 100644 --- a/tests/__snapshots__/react-query/error-type/endpoints.ts +++ b/tests/__snapshots__/react-query/error-type/endpoints.ts @@ -22,13 +22,9 @@ import type { } from '@tanstack/react-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -40,6 +36,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customInstance } from '../../../mutators/error-type'; import type { ErrorType } from '../../../mutators/error-type'; /** diff --git a/tests/__snapshots__/react-query/form-data-with-hook/endpoints.ts b/tests/__snapshots__/react-query/form-data-with-hook/endpoints.ts index bdd05c37f0..104e3cad95 100644 --- a/tests/__snapshots__/react-query/form-data-with-hook/endpoints.ts +++ b/tests/__snapshots__/react-query/form-data-with-hook/endpoints.ts @@ -14,13 +14,15 @@ import type { import { useCallback } from 'react'; -import type { Error, Pet, PetBase, PetExtended } from './model'; +import type { Error, Pet } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { PetBase, PetExtended } from './model'; + import { useCustomInstance } from '../../../mutators/use-custom-instance'; /** * @summary Create a pet diff --git a/tests/__snapshots__/react-query/form-data-with-mutator/endpoints.ts b/tests/__snapshots__/react-query/form-data-with-mutator/endpoints.ts index 3b77669185..a7a08099b4 100644 --- a/tests/__snapshots__/react-query/form-data-with-mutator/endpoints.ts +++ b/tests/__snapshots__/react-query/form-data-with-mutator/endpoints.ts @@ -12,13 +12,15 @@ import type { UseMutationResult, } from '@tanstack/react-query'; -import type { Error, Pet, PetBase, PetExtended } from './model'; +import type { Error, Pet } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { PetBase, PetExtended } from './model'; + import { customInstance } from '../../../mutators/custom-instance'; import { customFormData } from '../../../mutators/custom-form-data'; /** diff --git a/tests/__snapshots__/react-query/form-data/endpoints.ts b/tests/__snapshots__/react-query/form-data/endpoints.ts index 55498f7f29..0bcd2ed387 100644 --- a/tests/__snapshots__/react-query/form-data/endpoints.ts +++ b/tests/__snapshots__/react-query/form-data/endpoints.ts @@ -12,13 +12,15 @@ import type { UseMutationResult, } from '@tanstack/react-query'; -import type { Error, Pet, PetBase, PetExtended } from './model'; +import type { Error, Pet } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { PetBase, PetExtended } from './model'; + import { customInstance } from '../../../mutators/custom-instance'; /** * @summary Create a pet diff --git a/tests/__snapshots__/react-query/http-client-fetch-with-custom-fetch/endpoints.ts b/tests/__snapshots__/react-query/http-client-fetch-with-custom-fetch/endpoints.ts index 05a6b643fd..60a4f6e9ce 100644 --- a/tests/__snapshots__/react-query/http-client-fetch-with-custom-fetch/endpoints.ts +++ b/tests/__snapshots__/react-query/http-client-fetch-with-custom-fetch/endpoints.ts @@ -21,13 +21,9 @@ import type { } from '@tanstack/react-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -39,6 +35,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customFetch } from '../../../mutators/custom-fetch'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/react-query/invalidates/endpoints.ts b/tests/__snapshots__/react-query/invalidates/endpoints.ts index 90e1f87865..4580a9c081 100644 --- a/tests/__snapshots__/react-query/invalidates/endpoints.ts +++ b/tests/__snapshots__/react-query/invalidates/endpoints.ts @@ -21,14 +21,10 @@ import type { } from '@tanstack/react-query'; import type { - Cat, CreatePetsBody, CreatePetsHeaders, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsHeaders, ListPetsParams, Pet, @@ -41,6 +37,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/react-query/mockOverride/endpoints.ts b/tests/__snapshots__/react-query/mockOverride/endpoints.ts index e994ba8e81..f56ed31b98 100644 --- a/tests/__snapshots__/react-query/mockOverride/endpoints.ts +++ b/tests/__snapshots__/react-query/mockOverride/endpoints.ts @@ -21,13 +21,9 @@ import type { } from '@tanstack/react-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -39,6 +35,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/react-query/mockWithoutDelay/endpoints.ts b/tests/__snapshots__/react-query/mockWithoutDelay/endpoints.ts index 4d5f25501f..87da4bb494 100644 --- a/tests/__snapshots__/react-query/mockWithoutDelay/endpoints.ts +++ b/tests/__snapshots__/react-query/mockWithoutDelay/endpoints.ts @@ -21,13 +21,9 @@ import type { } from '@tanstack/react-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -39,6 +35,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/react-query/mutator-client/endpoints.ts b/tests/__snapshots__/react-query/mutator-client/endpoints.ts index d6b38bd8af..b869cd2d17 100644 --- a/tests/__snapshots__/react-query/mutator-client/endpoints.ts +++ b/tests/__snapshots__/react-query/mutator-client/endpoints.ts @@ -22,14 +22,10 @@ import type { } from '@tanstack/react-query'; import type { - Cat, CreatePetsBody, CreatePetsHeaders, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsHeaders, ListPetsParams, Pet, @@ -42,6 +38,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customClient } from '../../../mutators/custom-client'; import type { ErrorType, BodyType } from '../../../mutators/custom-client'; /** diff --git a/tests/__snapshots__/react-query/mutator-multi-arguments/endpoints.ts b/tests/__snapshots__/react-query/mutator-multi-arguments/endpoints.ts index a026d50f16..5ef02c19f0 100644 --- a/tests/__snapshots__/react-query/mutator-multi-arguments/endpoints.ts +++ b/tests/__snapshots__/react-query/mutator-multi-arguments/endpoints.ts @@ -22,13 +22,9 @@ import type { } from '@tanstack/react-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -40,6 +36,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customInstance } from '../../../mutators/multi-arguments'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/react-query/mutator/endpoints.ts b/tests/__snapshots__/react-query/mutator/endpoints.ts index 094a8778c7..51bbd3aa9d 100644 --- a/tests/__snapshots__/react-query/mutator/endpoints.ts +++ b/tests/__snapshots__/react-query/mutator/endpoints.ts @@ -35,13 +35,9 @@ import type { } from '@tanstack/react-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -53,6 +49,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customInstance } from '../../../mutators/custom-instance'; /** * @summary List all pets diff --git a/tests/__snapshots__/react-query/zod-schema-response/endpoints.ts b/tests/__snapshots__/react-query/zod-schema-response/endpoints.ts index 4d5f25501f..87da4bb494 100644 --- a/tests/__snapshots__/react-query/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/react-query/zod-schema-response/endpoints.ts @@ -21,13 +21,9 @@ import type { } from '@tanstack/react-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -39,6 +35,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/svelte-query/http-client-fetch-with-custom-fetch/endpoints.ts b/tests/__snapshots__/svelte-query/http-client-fetch-with-custom-fetch/endpoints.ts index e2998811f9..504b065f80 100644 --- a/tests/__snapshots__/svelte-query/http-client-fetch-with-custom-fetch/endpoints.ts +++ b/tests/__snapshots__/svelte-query/http-client-fetch-with-custom-fetch/endpoints.ts @@ -16,13 +16,9 @@ import type { } from '@tanstack/svelte-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -34,6 +30,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customFetch } from '../../../mutators/custom-fetch'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/svelte-query/invalidates/endpoints.ts b/tests/__snapshots__/svelte-query/invalidates/endpoints.ts index f482c27891..53e71f0eaf 100644 --- a/tests/__snapshots__/svelte-query/invalidates/endpoints.ts +++ b/tests/__snapshots__/svelte-query/invalidates/endpoints.ts @@ -21,14 +21,10 @@ import type { } from '@tanstack/svelte-query'; import type { - Cat, CreatePetsBody, CreatePetsHeaders, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsHeaders, ListPetsParams, Pet, @@ -41,6 +37,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/svelte-query/mutator/endpoints.ts b/tests/__snapshots__/svelte-query/mutator/endpoints.ts index 5f714c9ac1..a472a32927 100644 --- a/tests/__snapshots__/svelte-query/mutator/endpoints.ts +++ b/tests/__snapshots__/svelte-query/mutator/endpoints.ts @@ -15,13 +15,9 @@ import type { } from '@tanstack/svelte-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -33,6 +29,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customInstance } from '../../../mutators/custom-instance'; /** * @summary List all pets diff --git a/tests/__snapshots__/svelte-query/petstore/endpoints.ts b/tests/__snapshots__/svelte-query/petstore/endpoints.ts index 6c659798f0..30688c6822 100644 --- a/tests/__snapshots__/svelte-query/petstore/endpoints.ts +++ b/tests/__snapshots__/svelte-query/petstore/endpoints.ts @@ -15,13 +15,9 @@ import type { } from '@tanstack/svelte-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -33,6 +29,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/svelte-query/zod-schema-response/endpoints.ts b/tests/__snapshots__/svelte-query/zod-schema-response/endpoints.ts index 56d47ca474..656cfe1e6d 100644 --- a/tests/__snapshots__/svelte-query/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/svelte-query/zod-schema-response/endpoints.ts @@ -16,13 +16,9 @@ import type { } from '@tanstack/svelte-query'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -34,6 +30,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/swr/custom-client/endpoints.ts b/tests/__snapshots__/swr/custom-client/endpoints.ts index 90f404c54d..67dc7d9d52 100644 --- a/tests/__snapshots__/swr/custom-client/endpoints.ts +++ b/tests/__snapshots__/swr/custom-client/endpoints.ts @@ -11,13 +11,9 @@ import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -29,6 +25,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customClient } from '../../../mutators/custom-client'; import type { ErrorType, BodyType } from '../../../mutators/custom-client'; /** diff --git a/tests/__snapshots__/swr/form-data-optional-request/endpoints.ts b/tests/__snapshots__/swr/form-data-optional-request/endpoints.ts index c1e432f82d..05094c866d 100644 --- a/tests/__snapshots__/swr/form-data-optional-request/endpoints.ts +++ b/tests/__snapshots__/swr/form-data-optional-request/endpoints.ts @@ -9,13 +9,15 @@ import type { Key } from 'swr'; import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; -import type { Error, Pet, PetBase, PetExtended } from './model'; +import type { Error, Pet } from './model'; import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { PetBase, PetExtended } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/swr/http-client-fetch-with-custom-fetch/endpoints.ts b/tests/__snapshots__/swr/http-client-fetch-with-custom-fetch/endpoints.ts index f18ba17d26..9851cf584d 100644 --- a/tests/__snapshots__/swr/http-client-fetch-with-custom-fetch/endpoints.ts +++ b/tests/__snapshots__/swr/http-client-fetch-with-custom-fetch/endpoints.ts @@ -11,13 +11,9 @@ import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -29,6 +25,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customFetch } from '../../../mutators/custom-fetch'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/swr/mutator/endpoints.ts b/tests/__snapshots__/swr/mutator/endpoints.ts index fe4e9991f9..fd6cd64283 100644 --- a/tests/__snapshots__/swr/mutator/endpoints.ts +++ b/tests/__snapshots__/swr/mutator/endpoints.ts @@ -11,13 +11,9 @@ import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -29,6 +25,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customInstance } from '../../../mutators/multi-arguments'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/swr/petstore/endpoints.ts b/tests/__snapshots__/swr/petstore/endpoints.ts index 50401a8b35..bdb369c778 100644 --- a/tests/__snapshots__/swr/petstore/endpoints.ts +++ b/tests/__snapshots__/swr/petstore/endpoints.ts @@ -11,13 +11,9 @@ import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -29,6 +25,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/swr/zod-schema-response/endpoints.ts b/tests/__snapshots__/swr/zod-schema-response/endpoints.ts index ccf15fffe5..f28398d0bb 100644 --- a/tests/__snapshots__/swr/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/swr/zod-schema-response/endpoints.ts @@ -11,13 +11,9 @@ import useSWRMutation from 'swr/mutation'; import type { SWRMutationConfiguration } from 'swr/mutation'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -29,6 +25,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/vue-query/all-params-optional/endpoints.ts b/tests/__snapshots__/vue-query/all-params-optional/endpoints.ts index 9fdc2846b8..2989fa6da7 100644 --- a/tests/__snapshots__/vue-query/all-params-optional/endpoints.ts +++ b/tests/__snapshots__/vue-query/all-params-optional/endpoints.ts @@ -21,13 +21,9 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -39,6 +35,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/vue-query/combination-used-by-maxim-mazurok/endpoints.ts b/tests/__snapshots__/vue-query/combination-used-by-maxim-mazurok/endpoints.ts index 6035b4fb98..9e225fd025 100644 --- a/tests/__snapshots__/vue-query/combination-used-by-maxim-mazurok/endpoints.ts +++ b/tests/__snapshots__/vue-query/combination-used-by-maxim-mazurok/endpoints.ts @@ -21,13 +21,9 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -39,6 +35,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/vue-query/http-client-fetch-with-custom-fetch/endpoints.ts b/tests/__snapshots__/vue-query/http-client-fetch-with-custom-fetch/endpoints.ts index ef5f70fd1e..a0ab810f8f 100644 --- a/tests/__snapshots__/vue-query/http-client-fetch-with-custom-fetch/endpoints.ts +++ b/tests/__snapshots__/vue-query/http-client-fetch-with-custom-fetch/endpoints.ts @@ -21,13 +21,9 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -39,6 +35,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customFetch } from '../../../mutators/custom-fetch'; type SecondParameter unknown> = Parameters[1]; diff --git a/tests/__snapshots__/vue-query/mutator/endpoints.ts b/tests/__snapshots__/vue-query/mutator/endpoints.ts index 76a1636dbd..949c797a64 100644 --- a/tests/__snapshots__/vue-query/mutator/endpoints.ts +++ b/tests/__snapshots__/vue-query/mutator/endpoints.ts @@ -21,13 +21,9 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -39,6 +35,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + import { customInstance } from '../../../mutators/custom-instance'; /** * @summary List all pets diff --git a/tests/__snapshots__/vue-query/petstore/endpoints.ts b/tests/__snapshots__/vue-query/petstore/endpoints.ts index 95a68fc982..0ffb9c06cc 100644 --- a/tests/__snapshots__/vue-query/petstore/endpoints.ts +++ b/tests/__snapshots__/vue-query/petstore/endpoints.ts @@ -24,13 +24,9 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -42,6 +38,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + /** * @summary List all pets */ diff --git a/tests/__snapshots__/vue-query/url-encode-parameters/endpoints.ts b/tests/__snapshots__/vue-query/url-encode-parameters/endpoints.ts index e77ee904b3..84f96519ae 100644 --- a/tests/__snapshots__/vue-query/url-encode-parameters/endpoints.ts +++ b/tests/__snapshots__/vue-query/url-encode-parameters/endpoints.ts @@ -21,13 +21,9 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -39,6 +35,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + export type HTTPStatusCode1xx = 100 | 101 | 102 | 103; export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207; export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308; diff --git a/tests/__snapshots__/vue-query/zod-schema-response/endpoints.ts b/tests/__snapshots__/vue-query/zod-schema-response/endpoints.ts index ef055bdeac..2c9e050b54 100644 --- a/tests/__snapshots__/vue-query/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/vue-query/zod-schema-response/endpoints.ts @@ -24,13 +24,9 @@ import { computed, unref } from 'vue'; import type { MaybeRef } from 'vue'; import type { - Cat, CreatePetsBody, CreatePetsParams, - Dachshund, - Dog, Error, - Labradoodle, ListPetsParams, Pet, PetWithTag, @@ -42,6 +38,8 @@ import { faker } from '@faker-js/faker'; import { HttpResponse, http } from 'msw'; import type { RequestHandlerOptions } from 'msw'; +import type { Cat, Dachshund, Dog, Labradoodle } from './model'; + /** * @summary List all pets */ diff --git a/tests/__snapshots__/zod/petstore/endpoints.ts b/tests/__snapshots__/zod/petstore/endpoints.ts index b2e1504791..6d23dfcedf 100644 --- a/tests/__snapshots__/zod/petstore/endpoints.ts +++ b/tests/__snapshots__/zod/petstore/endpoints.ts @@ -6,6 +6,11 @@ */ import * as zod from 'zod'; +import { faker } from '@faker-js/faker'; + +import { HttpResponse, http } from 'msw'; +import type { RequestHandlerOptions } from 'msw'; + import type { Cat, Dachshund, @@ -16,11 +21,6 @@ import type { Pets, } from './model'; -import { faker } from '@faker-js/faker'; - -import { HttpResponse, http } from 'msw'; -import type { RequestHandlerOptions } from 'msw'; - /** * @summary List all pets */ diff --git a/tests/specifications/faker-array-items.yaml b/tests/specifications/faker-array-items.yaml index 78a4c0d8e5..f16a48afcb 100644 --- a/tests/specifications/faker-array-items.yaml +++ b/tests/specifications/faker-array-items.yaml @@ -46,6 +46,30 @@ paths: application/json: schema: $ref: '#/components/schemas/TenantListResponse' + /tenants-a: + get: + operationId: getTenantsA + tags: + - tenants + responses: + '200': + description: List tenants (shared ref A) + content: + application/json: + schema: + $ref: '#/components/schemas/TenantListResponse' + /tenants-b: + get: + operationId: getTenantsB + tags: + - tenants + responses: + '200': + description: List tenants (shared ref B) + content: + application/json: + schema: + $ref: '#/components/schemas/TenantListResponse' components: schemas: TenantResponseModelDto: From 65e3a3cce6635da37b8dccf3d5c342da4e1eba63 Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Tue, 2 Jun 2026 06:36:50 +0200 Subject: [PATCH 08/11] style(mock): use nullish coalescing for array-item factory set Fixes @typescript-eslint/prefer-nullish-coalescing in array-item-factory.ts. Co-authored-by: Cursor --- packages/mock/src/faker/getters/array-item-factory.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/mock/src/faker/getters/array-item-factory.ts b/packages/mock/src/faker/getters/array-item-factory.ts index a6d0e40966..022f24fb13 100644 --- a/packages/mock/src/faker/getters/array-item-factory.ts +++ b/packages/mock/src/faker/getters/array-item-factory.ts @@ -14,9 +14,7 @@ import { overrideVarName } from './object'; import { extractItemsRef } from './scalar'; function getFileLevelExtractedFactories(context: ContextSpec): Set { - if (!context.arrayItemMockFactories) { - context.arrayItemMockFactories = new Set(); - } + context.arrayItemMockFactories ??= new Set(); return context.arrayItemMockFactories; } From b9a14cd031b5562fe01146e6d50c7f8a10b3ee6e Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Tue, 2 Jun 2026 11:21:26 +0200 Subject: [PATCH 09/11] fix(mock): scope array-item factory dedup per output file Dedup by tag bucket in tags/tags-split modes so each tag file defines its own shared factories. Co-authored-by: Cursor --- packages/core/src/types.ts | 9 +- .../faker/getters/array-item-factory.test.ts | 89 ++++++++++++++++--- .../src/faker/getters/array-item-factory.ts | 43 ++++++++- packages/mock/src/faker/getters/scalar.ts | 1 + .../alpha/alpha.faker.ts | 33 +++++++ .../alpha/alpha.ts | 20 +++++ .../beta/beta.faker.ts | 33 +++++++ .../faker-array-items-tags-split/beta/beta.ts | 20 +++++ .../model/index.ts | 9 ++ .../model/tenantListResponse.ts | 12 +++ .../model/tenantResponseModelDto.ts | 11 +++ tests/configs/mock.config.ts | 16 ++++ .../faker-array-items-tags-split.yaml | 51 +++++++++++ 13 files changed, 326 insertions(+), 21 deletions(-) create mode 100644 tests/__snapshots__/mock/faker-array-items-tags-split/alpha/alpha.faker.ts create mode 100644 tests/__snapshots__/mock/faker-array-items-tags-split/alpha/alpha.ts create mode 100644 tests/__snapshots__/mock/faker-array-items-tags-split/beta/beta.faker.ts create mode 100644 tests/__snapshots__/mock/faker-array-items-tags-split/beta/beta.ts create mode 100644 tests/__snapshots__/mock/faker-array-items-tags-split/model/index.ts create mode 100644 tests/__snapshots__/mock/faker-array-items-tags-split/model/tenantListResponse.ts create mode 100644 tests/__snapshots__/mock/faker-array-items-tags-split/model/tenantResponseModelDto.ts create mode 100644 tests/specifications/faker-array-items-tags-split.yaml diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index a95087c3b2..f5fdf67d26 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -1118,11 +1118,12 @@ export interface ContextSpec { */ dynamicScope?: Partial>; /** - * Tracks array-item mock factory names already emitted in the current output - * file. Populated by `@orval/mock` when `arrayItems: true` so shared `$ref` - * item factories are not re-declared per operation. + * Tracks array-item mock factory names already emitted per output file scope. + * Populated by `@orval/mock` when `arrayItems: true` so shared `$ref` item + * factories are not re-declared within the same file (single/split) or tag + * bucket (tags/tags-split). */ - arrayItemMockFactories?: Set; + arrayItemMockFactories?: Map>; } /** diff --git a/packages/mock/src/faker/getters/array-item-factory.test.ts b/packages/mock/src/faker/getters/array-item-factory.test.ts index acfdf8a78c..a33a531f49 100644 --- a/packages/mock/src/faker/getters/array-item-factory.test.ts +++ b/packages/mock/src/faker/getters/array-item-factory.test.ts @@ -1,14 +1,16 @@ -import type { ContextSpec } from '@orval/core'; +import { type ContextSpec, OutputMode } from '@orval/core'; import { describe, expect, it } from 'vitest'; import { extractArrayItemMock, + getArrayItemMockFileScope, shouldExtractArrayItemFactories, } from './array-item-factory'; -const createContextWithArrayItems = (): ContextSpec => +const createContextWithArrayItems = (mode = OutputMode.SINGLE): ContextSpec => ({ output: { + mode, mock: { generators: [{ type: 'faker', arrayItems: true }], }, @@ -29,6 +31,22 @@ const contextWithoutArrayItems = { }, } as unknown as ContextSpec; +const mapValue = + '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}'; + +describe('getArrayItemMockFileScope', () => { + it('uses a single scope for single mode', () => { + const context = createContextWithArrayItems(); + expect(getArrayItemMockFileScope(context, ['pets'])).toBe('single'); + }); + + it('uses per-tag scope for tags-split mode', () => { + const context = createContextWithArrayItems(OutputMode.TAGS_SPLIT); + expect(getArrayItemMockFileScope(context, ['alpha'])).toBe('tag:alpha'); + expect(getArrayItemMockFileScope(context, ['beta'])).toBe('tag:beta'); + }); +}); + describe('shouldExtractArrayItemFactories', () => { it('returns true when arrayItems is enabled', () => { expect(shouldExtractArrayItemFactories(createContextWithArrayItems())).toBe( @@ -52,8 +70,8 @@ describe('extractArrayItemMock', () => { items: { $ref: '#/components/schemas/TenantResponseModelDto' }, propertyName: 'value', operationId: 'getTenantsByRef', - mapValue: - '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}', + tags: [], + mapValue, context: createContextWithArrayItems(), splitMockImplementations, imports, @@ -84,8 +102,8 @@ describe('extractArrayItemMock', () => { propertyName: 'value', parentName: 'GetTenants200', operationId: 'getTenants', - mapValue: - '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}', + tags: [], + mapValue, context: createContextWithArrayItems(), splitMockImplementations, imports: [], @@ -103,13 +121,12 @@ describe('extractArrayItemMock', () => { it('deduplicates factories with the same name within one operation', () => { const context = createContextWithArrayItems(); const splitMockImplementations: string[] = []; - const mapValue = - '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}'; extractArrayItemMock({ items: { $ref: '#/components/schemas/TenantResponseModelDto' }, propertyName: 'value', operationId: 'getTenantsByRef', + tags: [], mapValue, context, splitMockImplementations, @@ -119,6 +136,7 @@ describe('extractArrayItemMock', () => { items: { $ref: '#/components/schemas/TenantResponseModelDto' }, propertyName: 'items', operationId: 'getTenantsByRef', + tags: [], mapValue, context, splitMockImplementations, @@ -130,8 +148,6 @@ describe('extractArrayItemMock', () => { it('deduplicates $ref factories across operations in the same output file', () => { const context = createContextWithArrayItems(); - const mapValue = - '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}'; const splitMockImplementationsA: string[] = []; const splitMockImplementationsB: string[] = []; @@ -139,6 +155,7 @@ describe('extractArrayItemMock', () => { items: { $ref: '#/components/schemas/TenantResponseModelDto' }, propertyName: 'value', operationId: 'getTenantsA', + tags: [], mapValue, context, splitMockImplementations: splitMockImplementationsA, @@ -148,6 +165,7 @@ describe('extractArrayItemMock', () => { items: { $ref: '#/components/schemas/TenantResponseModelDto' }, propertyName: 'value', operationId: 'getTenantsB', + tags: [], mapValue, context, splitMockImplementations: splitMockImplementationsB, @@ -157,7 +175,49 @@ describe('extractArrayItemMock', () => { expect(splitMockImplementationsA).toHaveLength(1); expect(splitMockImplementationsB).toHaveLength(0); expect( - context.arrayItemMockFactories?.has('getTenantResponseModelDtoMock'), + context.arrayItemMockFactories + ?.get('single') + ?.has('getTenantResponseModelDtoMock'), + ).toBe(true); + }); + + it('emits $ref factories separately per tag in tags-split mode', () => { + const context = createContextWithArrayItems(OutputMode.TAGS_SPLIT); + const splitMockImplementationsAlpha: string[] = []; + const splitMockImplementationsBeta: string[] = []; + + extractArrayItemMock({ + items: { $ref: '#/components/schemas/TenantResponseModelDto' }, + propertyName: 'value', + operationId: 'getA', + tags: ['alpha'], + mapValue, + context, + splitMockImplementations: splitMockImplementationsAlpha, + imports: [], + }); + extractArrayItemMock({ + items: { $ref: '#/components/schemas/TenantResponseModelDto' }, + propertyName: 'value', + operationId: 'getB', + tags: ['beta'], + mapValue, + context, + splitMockImplementations: splitMockImplementationsBeta, + imports: [], + }); + + expect(splitMockImplementationsAlpha).toHaveLength(1); + expect(splitMockImplementationsBeta).toHaveLength(1); + expect( + context.arrayItemMockFactories + ?.get('tag:alpha') + ?.has('getTenantResponseModelDtoMock'), + ).toBe(true); + expect( + context.arrayItemMockFactories + ?.get('tag:beta') + ?.has('getTenantResponseModelDtoMock'), ).toBe(true); }); @@ -168,6 +228,7 @@ describe('extractArrayItemMock', () => { items: { type: 'string' }, propertyName: 'tags', operationId: 'getTenants', + tags: [], mapValue: 'faker.string.alpha({length: {min: 10, max: 20}})', context: createContextWithArrayItems(), splitMockImplementations, @@ -185,6 +246,7 @@ describe('extractArrayItemMock', () => { items: { $ref: '#/components/schemas/TenantResponseModelDto' }, propertyName: 'value', operationId: 'getTenantsByRef', + tags: [], mapValue: '{...getTenantResponseModelDtoMock()}', context: createContextWithArrayItems(), splitMockImplementations, @@ -209,6 +271,7 @@ describe('extractArrayItemMock', () => { propertyName: 'value', parentName: 'GetTenants200', operationId: 'getTenants', + tags: [], mapValue: '{id: faker.string.uuid(), pet: {...getPetMock()}, name: faker.string.alpha({length: {min: 10, max: 20}})}', context: createContextWithArrayItems(), @@ -238,8 +301,8 @@ describe('extractArrayItemMock', () => { items: { $ref: '#/components/schemas/TenantResponseModelDto' }, propertyName: 'value', operationId: 'getTenantsByRef', - mapValue: - '{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 10, max: 20}})}', + tags: [], + mapValue, context: contextWithSchemas, splitMockImplementations, imports: [], diff --git a/packages/mock/src/faker/getters/array-item-factory.ts b/packages/mock/src/faker/getters/array-item-factory.ts index 022f24fb13..f3589c1421 100644 --- a/packages/mock/src/faker/getters/array-item-factory.ts +++ b/packages/mock/src/faker/getters/array-item-factory.ts @@ -1,11 +1,14 @@ import { type ContextSpec, + DefaultTag, type GeneratorImport, getRefInfo, isFunction, isReference, + kebab, type OpenApiSchemaObject, OutputMockType, + OutputMode, pascal, } from '@orval/core'; @@ -13,9 +16,38 @@ import type { MockSchema } from '../../types'; import { overrideVarName } from './object'; import { extractItemsRef } from './scalar'; -function getFileLevelExtractedFactories(context: ContextSpec): Set { - context.arrayItemMockFactories ??= new Set(); - return context.arrayItemMockFactories; +/** + * Scope key for file-level array-item factory dedup. Must match how writers + * group mock output: one bucket per tag file in tags modes, otherwise one + * bucket for the whole target. + */ +export function getArrayItemMockFileScope( + context: ContextSpec, + tags: string[], +): string { + const mode = context.output.mode; + if (mode === OutputMode.TAGS || mode === OutputMode.TAGS_SPLIT) { + const tag = tags.length > 0 ? tags[0] : DefaultTag; + return `tag:${kebab(tag)}`; + } + if (mode === OutputMode.SPLIT) { + return 'split'; + } + return 'single'; +} + +function getFileLevelExtractedFactories( + context: ContextSpec, + scope: string, +): Set { + context.arrayItemMockFactories ??= new Map(); + const existing = context.arrayItemMockFactories.get(scope); + if (existing) { + return existing; + } + const factories = new Set(); + context.arrayItemMockFactories.set(scope, factories); + return factories; } /** @@ -145,6 +177,7 @@ interface ExtractArrayItemMockOptions { propertyName: string; parentName?: string; operationId: string; + tags: string[]; mapValue: string; context: ContextSpec; splitMockImplementations: string[]; @@ -160,6 +193,7 @@ export function extractArrayItemMock({ propertyName, parentName, operationId, + tags, mapValue, context, splitMockImplementations, @@ -190,7 +224,8 @@ export function extractArrayItemMock({ } const { factoryName, typeName } = names; - const fileLevelFactories = getFileLevelExtractedFactories(context); + const scope = getArrayItemMockFileScope(context, tags); + const fileLevelFactories = getFileLevelExtractedFactories(context, scope); const alreadyExtracted = fileLevelFactories.has(factoryName) || splitMockImplementations.some((f) => diff --git a/packages/mock/src/faker/getters/scalar.ts b/packages/mock/src/faker/getters/scalar.ts index 83cf79b5ba..5467fceeda 100644 --- a/packages/mock/src/faker/getters/scalar.ts +++ b/packages/mock/src/faker/getters/scalar.ts @@ -343,6 +343,7 @@ export function getMockScalar({ propertyName: item.name, parentName: item.parentName, operationId, + tags, mapValue, context, splitMockImplementations, diff --git a/tests/__snapshots__/mock/faker-array-items-tags-split/alpha/alpha.faker.ts b/tests/__snapshots__/mock/faker-array-items-tags-split/alpha/alpha.faker.ts new file mode 100644 index 0000000000..f7ea340de6 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items-tags-split/alpha/alpha.faker.ts @@ -0,0 +1,33 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories (tags-split) + * OpenAPI spec version: 1.0.0 + */ +import { faker } from '@faker-js/faker'; + +import type { TenantListResponse, TenantResponseModelDto } from '../model'; + +export const getTenantResponseModelDtoMock = ( + overrideResponse: Partial = {}, +): TenantResponseModelDto => ({ + ...{ + id: faker.string.uuid(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}); + +export const getGetAResponseMock = ( + overrideResponse: Partial> = {}, +): TenantListResponse => ({ + value: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ ...getTenantResponseModelDtoMock() })), + undefined, + ]), + count: faker.helpers.arrayElement([faker.number.int(), undefined]), + ...overrideResponse, +}); diff --git a/tests/__snapshots__/mock/faker-array-items-tags-split/alpha/alpha.ts b/tests/__snapshots__/mock/faker-array-items-tags-split/alpha/alpha.ts new file mode 100644 index 0000000000..d200fa3d08 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items-tags-split/alpha/alpha.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories (tags-split) + * OpenAPI spec version: 1.0.0 + */ +import axios from 'axios'; +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; + +import type { TenantListResponse } from '../model'; + +export const getAlpha = (axiosInstance: AxiosInstance = axios) => { + const getA = ( + options?: AxiosRequestConfig, + ): Promise> => { + return axiosInstance.get(`/a`, options); + }; + return { getA }; +}; +export type GetAResult = AxiosResponse; diff --git a/tests/__snapshots__/mock/faker-array-items-tags-split/beta/beta.faker.ts b/tests/__snapshots__/mock/faker-array-items-tags-split/beta/beta.faker.ts new file mode 100644 index 0000000000..0a91fd4365 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items-tags-split/beta/beta.faker.ts @@ -0,0 +1,33 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories (tags-split) + * OpenAPI spec version: 1.0.0 + */ +import { faker } from '@faker-js/faker'; + +import type { TenantListResponse, TenantResponseModelDto } from '../model'; + +export const getTenantResponseModelDtoMock = ( + overrideResponse: Partial = {}, +): TenantResponseModelDto => ({ + ...{ + id: faker.string.uuid(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}); + +export const getGetBResponseMock = ( + overrideResponse: Partial> = {}, +): TenantListResponse => ({ + value: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ ...getTenantResponseModelDtoMock() })), + undefined, + ]), + count: faker.helpers.arrayElement([faker.number.int(), undefined]), + ...overrideResponse, +}); diff --git a/tests/__snapshots__/mock/faker-array-items-tags-split/beta/beta.ts b/tests/__snapshots__/mock/faker-array-items-tags-split/beta/beta.ts new file mode 100644 index 0000000000..0ab760843d --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items-tags-split/beta/beta.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories (tags-split) + * OpenAPI spec version: 1.0.0 + */ +import axios from 'axios'; +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; + +import type { TenantListResponse } from '../model'; + +export const getBeta = (axiosInstance: AxiosInstance = axios) => { + const getB = ( + options?: AxiosRequestConfig, + ): Promise> => { + return axiosInstance.get(`/b`, options); + }; + return { getB }; +}; +export type GetBResult = AxiosResponse; diff --git a/tests/__snapshots__/mock/faker-array-items-tags-split/model/index.ts b/tests/__snapshots__/mock/faker-array-items-tags-split/model/index.ts new file mode 100644 index 0000000000..ab70dff4bd --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items-tags-split/model/index.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories (tags-split) + * OpenAPI spec version: 1.0.0 + */ + +export * from './tenantListResponse'; +export * from './tenantResponseModelDto'; diff --git a/tests/__snapshots__/mock/faker-array-items-tags-split/model/tenantListResponse.ts b/tests/__snapshots__/mock/faker-array-items-tags-split/model/tenantListResponse.ts new file mode 100644 index 0000000000..0063cbba48 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items-tags-split/model/tenantListResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories (tags-split) + * OpenAPI spec version: 1.0.0 + */ +import type { TenantResponseModelDto } from './tenantResponseModelDto'; + +export interface TenantListResponse { + value?: TenantResponseModelDto[]; + count?: number; +} diff --git a/tests/__snapshots__/mock/faker-array-items-tags-split/model/tenantResponseModelDto.ts b/tests/__snapshots__/mock/faker-array-items-tags-split/model/tenantResponseModelDto.ts new file mode 100644 index 0000000000..70b1e1b995 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items-tags-split/model/tenantResponseModelDto.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories (tags-split) + * OpenAPI spec version: 1.0.0 + */ + +export interface TenantResponseModelDto { + id: string; + name: string; +} diff --git a/tests/configs/mock.config.ts b/tests/configs/mock.config.ts index e26e1a6c20..b63e76bf13 100644 --- a/tests/configs/mock.config.ts +++ b/tests/configs/mock.config.ts @@ -531,4 +531,20 @@ export default defineConfig({ target: '../specifications/faker-array-items.yaml', }, }, + fakerArrayItemsTagsSplit: { + output: { + target: '../generated/mock/faker-array-items-tags-split/endpoints.ts', + schemas: '../generated/mock/faker-array-items-tags-split/model', + mode: 'tags-split', + client: 'axios', + mock: { + generators: [{ type: 'faker', arrayItems: true }], + }, + clean: true, + formatter: 'prettier', + }, + input: { + target: '../specifications/faker-array-items-tags-split.yaml', + }, + }, }); diff --git a/tests/specifications/faker-array-items-tags-split.yaml b/tests/specifications/faker-array-items-tags-split.yaml new file mode 100644 index 0000000000..e2f524b915 --- /dev/null +++ b/tests/specifications/faker-array-items-tags-split.yaml @@ -0,0 +1,51 @@ +openapi: 3.0.3 +info: + title: Faker array item factories (tags-split) + version: 1.0.0 +paths: + /a: + get: + operationId: getA + tags: + - alpha + responses: + '200': + description: ok + content: + application/json: + schema: + $ref: '#/components/schemas/TenantListResponse' + /b: + get: + operationId: getB + tags: + - beta + responses: + '200': + description: ok + content: + application/json: + schema: + $ref: '#/components/schemas/TenantListResponse' +components: + schemas: + TenantResponseModelDto: + type: object + required: + - id + - name + properties: + id: + type: string + format: uuid + name: + type: string + TenantListResponse: + type: object + properties: + value: + type: array + items: + $ref: '#/components/schemas/TenantResponseModelDto' + count: + type: integer From 9816c590349688464eb0f58b764a246140781de8 Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Tue, 2 Jun 2026 11:37:07 +0200 Subject: [PATCH 10/11] fix(mock): widen test helper mode param to OutputMode Co-authored-by: Cursor --- packages/mock/src/faker/getters/array-item-factory.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/mock/src/faker/getters/array-item-factory.test.ts b/packages/mock/src/faker/getters/array-item-factory.test.ts index a33a531f49..df97a92f07 100644 --- a/packages/mock/src/faker/getters/array-item-factory.test.ts +++ b/packages/mock/src/faker/getters/array-item-factory.test.ts @@ -7,7 +7,9 @@ import { shouldExtractArrayItemFactories, } from './array-item-factory'; -const createContextWithArrayItems = (mode = OutputMode.SINGLE): ContextSpec => +const createContextWithArrayItems = ( + mode: OutputMode = OutputMode.SINGLE, +): ContextSpec => ({ output: { mode, From 64954f8d039311b7a8b6797751735ff5f33959c3 Mon Sep 17 00:00:00 2001 From: Ben Beckers Date: Tue, 2 Jun 2026 11:37:07 +0200 Subject: [PATCH 11/11] fix(mock): guard arrayItems extraction for edge-case item shapes --- docs/content/docs/guides/faker.mdx | 4 +- .../faker/getters/array-item-factory.test.ts | 139 ++++++++++++++- .../src/faker/getters/array-item-factory.ts | 85 ++++++++- .../mock/faker-array-items/endpoints.ts | 167 +++++++++++++++++- .../mock/faker-array-items/model/cat.ts | 10 ++ .../mock/faker-array-items/model/dog.ts | 10 ++ .../faker-array-items/model/getCollide200.ts | 13 ++ .../model/getCollide200Inner.ts | 11 ++ .../model/getCollide200InnerItemsItem.ts | 10 ++ .../model/getCollide200Outer.ts | 11 ++ .../model/getCollide200OuterItemsItem.ts | 10 ++ .../faker-array-items/model/getNames200.ts | 11 ++ .../faker-array-items/model/getNullable200.ts | 11 ++ .../model/getNullable200RowsItem.ts | 13 ++ .../faker-array-items/model/getThings200.ts | 12 ++ .../mock/faker-array-items/model/index.ts | 12 ++ .../mock/faker-array-items/model/name.ts | 8 + tests/specifications/faker-array-items.yaml | 103 +++++++++++ 18 files changed, 626 insertions(+), 14 deletions(-) create mode 100644 tests/__snapshots__/mock/faker-array-items/model/cat.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/dog.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getCollide200.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getCollide200Inner.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getCollide200InnerItemsItem.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getCollide200Outer.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getCollide200OuterItemsItem.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getNames200.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getNullable200.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getNullable200RowsItem.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/getThings200.ts create mode 100644 tests/__snapshots__/mock/faker-array-items/model/name.ts diff --git a/docs/content/docs/guides/faker.mdx b/docs/content/docs/guides/faker.mdx index 76a83bf368..d5450137b3 100644 --- a/docs/content/docs/guides/faker.mdx +++ b/docs/content/docs/guides/faker.mdx @@ -137,9 +137,11 @@ export const getGetTenantsByRefResponseMock = ( }); ``` -- **`$ref` array items** → `getMock` (shared across operations referencing the same schema). +- **`$ref` array items** → `getMock` (shared across operations referencing the same schema) when the referenced schema is object-like. - **Inline object array items** → `getResponseItemMock` typed as `Item` (matching Orval's generated item type aliases). +Orval only extracts factories for shapes it can name and mock reliably. The following fall back to inline `.map()` bodies (same as `arrayItems: false`): `$ref` to scalar schemas, `oneOf` / `anyOf` item compositions, nullable object items, and nested arrays whose parent context is not the generated response wrapper (e.g. two `items` properties under `outer` and `inner` in the same operation). Plain object items, `$ref`-to-object items, and inline `allOf` items are supported. + When `schemas: true` is also enabled, `$ref` items delegate to the consolidated schema factory instead (same as today). `arrayItems` is useful when item types only appear inside response wrappers or when you want item factories without emitting every `components/schemas` entry. With both options enabled, `$ref` items are not re-exported from the operation mock file — import `getMock` from `/index.faker.ts` instead. ## Options diff --git a/packages/mock/src/faker/getters/array-item-factory.test.ts b/packages/mock/src/faker/getters/array-item-factory.test.ts index a33a531f49..67497f0c0e 100644 --- a/packages/mock/src/faker/getters/array-item-factory.test.ts +++ b/packages/mock/src/faker/getters/array-item-factory.test.ts @@ -7,7 +7,9 @@ import { shouldExtractArrayItemFactories, } from './array-item-factory'; -const createContextWithArrayItems = (mode = OutputMode.SINGLE): ContextSpec => +const createContextWithArrayItems = ( + mode: OutputMode = OutputMode.SINGLE, +): ContextSpec => ({ output: { mode, @@ -18,6 +20,20 @@ const createContextWithArrayItems = (mode = OutputMode.SINGLE): ContextSpec => components: { schemas: { suffix: '', itemSuffix: 'Item' } }, }, }, + spec: { + openapi: '3.0.3', + components: { + schemas: { + TenantResponseModelDto: { + type: 'object', + properties: { + id: { type: 'string' }, + name: { type: 'string' }, + }, + }, + }, + }, + }, }) as unknown as ContextSpec; const contextWithoutArrayItems = { @@ -283,6 +299,127 @@ describe('extractArrayItemMock', () => { expect(splitMockImplementations).toHaveLength(1); }); + it('skips $ref array items that resolve to scalar schemas', () => { + const splitMockImplementations: string[] = []; + const context = { + ...createContextWithArrayItems(), + spec: { + components: { + schemas: { + Name: { type: 'string', format: 'email' }, + }, + }, + }, + } as unknown as ContextSpec; + + const call = extractArrayItemMock({ + items: { $ref: '#/components/schemas/Name' }, + propertyName: 'names', + operationId: 'getNames', + tags: [], + mapValue: 'faker.internet.email()', + context, + splitMockImplementations, + imports: [], + }); + + expect(call).toBeUndefined(); + expect(splitMockImplementations).toHaveLength(0); + }); + + it('skips oneOf array items', () => { + const splitMockImplementations: string[] = []; + + const call = extractArrayItemMock({ + items: { + oneOf: [ + { $ref: '#/components/schemas/Cat' }, + { $ref: '#/components/schemas/Dog' }, + ], + }, + propertyName: 'things', + operationId: 'getThings', + tags: [], + mapValue: '{meow: faker.datatype.boolean()}', + context: createContextWithArrayItems(), + splitMockImplementations, + imports: [], + }); + + expect(call).toBeUndefined(); + expect(splitMockImplementations).toHaveLength(0); + }); + + it('skips nullable object array items', () => { + const splitMockImplementations: string[] = []; + + const call = extractArrayItemMock({ + items: { + type: 'object', + nullable: true, + properties: { id: { type: 'string' } }, + }, + propertyName: 'rows', + operationId: 'getNullable', + tags: [], + mapValue: '{id: faker.string.uuid()}', + context: createContextWithArrayItems(), + splitMockImplementations, + imports: [], + }); + + expect(call).toBeUndefined(); + expect(splitMockImplementations).toHaveLength(0); + }); + + it('skips nested inline array items when parentName is not the response wrapper', () => { + const splitMockImplementations: string[] = []; + + const call = extractArrayItemMock({ + items: { + type: 'object', + properties: { a: { type: 'string' } }, + }, + propertyName: 'items', + parentName: 'outer', + operationId: 'getCollide', + tags: [], + mapValue: '{a: faker.string.alpha({length: {min: 10, max: 20}})}', + context: createContextWithArrayItems(), + splitMockImplementations, + imports: [], + }); + + expect(call).toBeUndefined(); + expect(splitMockImplementations).toHaveLength(0); + }); + + it('still extracts inline allOf object array items', () => { + const splitMockImplementations: string[] = []; + + const call = extractArrayItemMock({ + items: { + allOf: [ + { + type: 'object', + properties: { id: { type: 'string' } }, + }, + ], + }, + propertyName: 'value', + parentName: 'GetTenants200', + operationId: 'getTenants', + tags: [], + mapValue: '{id: faker.string.uuid()}', + context: createContextWithArrayItems(), + splitMockImplementations, + imports: [], + }); + + expect(call).toBe('{...getGetTenantsResponseValueItemMock()}'); + expect(splitMockImplementations).toHaveLength(1); + }); + it('skips $ref components/schemas items when schemas: true emits consolidated factories', () => { const splitMockImplementations: string[] = []; const contextWithSchemas = { diff --git a/packages/mock/src/faker/getters/array-item-factory.ts b/packages/mock/src/faker/getters/array-item-factory.ts index f3589c1421..ad79fa4974 100644 --- a/packages/mock/src/faker/getters/array-item-factory.ts +++ b/packages/mock/src/faker/getters/array-item-factory.ts @@ -10,6 +10,7 @@ import { OutputMockType, OutputMode, pascal, + resolveRef, } from '@orval/core'; import type { MockSchema } from '../../types'; @@ -99,25 +100,91 @@ function hasConsolidatedSchemaFactory( } /** - * True when array `items` resolve to an object-like schema worth extracting. + * True when `parentName` looks like a nested property key rather than the + * generated response wrapper type (e.g. `outer` vs `GetTenants200`). Inlining + * avoids factory/type-name collisions and mismatched `Item` aliases. */ -function isObjectLikeArrayItem(items: MockSchema): boolean { - if (isReference(items)) { +function isAmbiguousInlineItemContext( + operationId: string, + parentName?: string, +): boolean { + if (!parentName) { + return false; + } + + return !parentName.toLowerCase().includes(operationId.toLowerCase()); +} + +function isNullableArrayItem(schema: OpenApiSchemaObject): boolean { + if (schema.nullable === true) { return true; } - const schema = items as OpenApiSchemaObject; + return Array.isArray(schema.type) && schema.type.includes('null'); +} + +function isResolvedSchemaObjectLike(schema: OpenApiSchemaObject): boolean { if (schema.type === 'object' || schema.properties) { return true; } - if (schema.allOf || schema.oneOf || schema.anyOf) { + if (schema.allOf) { return true; } return false; } +/** + * True when array `items` resolve to an object-like schema worth extracting. + * Conservative: skips scalar refs, oneOf/anyOf, nullable items, and nested + * contexts where generated item type names cannot be inferred reliably. + */ +function shouldExtractArrayItem( + items: MockSchema, + context: ContextSpec, + operationId: string, + parentName?: string, +): boolean { + const itemsRef = extractItemsRef(items); + + if (itemsRef) { + try { + const { schema } = resolveRef( + { $ref: itemsRef }, + context, + ); + return isResolvedSchemaObjectLike(schema); + } catch { + return false; + } + } + + if (isReference(items)) { + return false; + } + + const schema = items as OpenApiSchemaObject; + + if (isNullableArrayItem(schema)) { + return false; + } + + if (schema.oneOf || schema.anyOf) { + return false; + } + + if (schema.allOf) { + return true; + } + + if (schema.type === 'object' || schema.properties) { + return !isAmbiguousInlineItemContext(operationId, parentName); + } + + return false; +} + /** * True when `mapValue` is already a bare factory call or a single spread of one. */ @@ -148,6 +215,10 @@ function getArrayItemFactoryNames({ operationId: string; context: ContextSpec; }): ArrayItemFactoryNames | undefined { + if (!shouldExtractArrayItem(items, context, operationId, parentName)) { + return undefined; + } + const itemsRef = extractItemsRef(items); if (itemsRef) { const { name } = getRefInfo(itemsRef, context); @@ -158,10 +229,6 @@ function getArrayItemFactoryNames({ }; } - if (!isObjectLikeArrayItem(items)) { - return undefined; - } - const itemSuffix = context.output.override.components.schemas.itemSuffix; const typeName = parentName ? `${pascal(parentName)}${pascal(propertyName)}${itemSuffix}` diff --git a/tests/__snapshots__/mock/faker-array-items/endpoints.ts b/tests/__snapshots__/mock/faker-array-items/endpoints.ts index 50cbc60bec..75990d7627 100644 --- a/tests/__snapshots__/mock/faker-array-items/endpoints.ts +++ b/tests/__snapshots__/mock/faker-array-items/endpoints.ts @@ -7,11 +7,23 @@ import axios from 'axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { GetTenants200, TenantListResponse } from './model'; +import type { + GetCollide200, + GetNames200, + GetNullable200, + GetTenants200, + GetThings200, + TenantListResponse, +} from './model'; import { faker } from '@faker-js/faker'; -import type { GetTenants200ValueItem, TenantResponseModelDto } from './model'; +import type { + Cat, + Dog, + GetTenants200ValueItem, + TenantResponseModelDto, +} from './model'; export const getFakerArrayItemFactories = ( axiosInstance: AxiosInstance = axios, @@ -40,12 +52,49 @@ export const getFakerArrayItemFactories = ( return axiosInstance.get(`/tenants-b`, options); }; - return { getTenants, getTenantsByRef, getTenantsA, getTenantsB }; + const getNames = ( + options?: AxiosRequestConfig, + ): Promise> => { + return axiosInstance.get(`/names`, options); + }; + + const getThings = ( + options?: AxiosRequestConfig, + ): Promise> => { + return axiosInstance.get(`/things`, options); + }; + + const getNullable = ( + options?: AxiosRequestConfig, + ): Promise> => { + return axiosInstance.get(`/nullable-rows`, options); + }; + + const getCollide = ( + options?: AxiosRequestConfig, + ): Promise> => { + return axiosInstance.get(`/collide`, options); + }; + + return { + getTenants, + getTenantsByRef, + getTenantsA, + getTenantsB, + getNames, + getThings, + getNullable, + getCollide, + }; }; export type GetTenantsResult = AxiosResponse; export type GetTenantsByRefResult = AxiosResponse; export type GetTenantsAResult = AxiosResponse; export type GetTenantsBResult = AxiosResponse; +export type GetNamesResult = AxiosResponse; +export type GetThingsResult = AxiosResponse; +export type GetNullableResult = AxiosResponse; +export type GetCollideResult = AxiosResponse; export const getGetTenantsResponseValueItemMock = ( overrideResponse: Partial = {}, @@ -110,3 +159,115 @@ export const getGetTenantsBResponseMock = ( count: faker.number.int(), ...overrideResponse, }); + +export const getGetNamesResponseMock = ( + overrideResponse: Partial> = {}, +): GetNames200 => ({ + names: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => faker.internet.email()), + undefined, + ]), + ...overrideResponse, +}); + +export const getGetThingsResponseCatMock = ( + overrideResponse: Partial = {}, +): Cat => ({ + ...{ + meow: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}); + +export const getGetThingsResponseDogMock = ( + overrideResponse: Partial = {}, +): Dog => ({ + ...{ + bark: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}); + +export const getGetThingsResponseMock = ( + overrideResponse: Partial> = {}, +): GetThings200 => ({ + things: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => + faker.helpers.arrayElement([ + { ...getGetThingsResponseCatMock() }, + { ...getGetThingsResponseDogMock() }, + ]), + ), + undefined, + ]), + ...overrideResponse, +}); + +export const getGetNullableResponseMock = ( + overrideResponse: Partial> = {}, +): GetNullable200 => ({ + rows: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => + faker.helpers.arrayElement([ + { + id: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + null, + ]), + ), + undefined, + ]), + ...overrideResponse, +}); + +export const getGetCollideResponseMock = ( + overrideResponse: Partial> = {}, +): GetCollide200 => ({ + outer: faker.helpers.arrayElement([ + { + items: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ + a: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + inner: faker.helpers.arrayElement([ + { + items: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ + b: faker.helpers.arrayElement([ + faker.number.float({ fractionDigits: 2 }), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + ...overrideResponse, +}); diff --git a/tests/__snapshots__/mock/faker-array-items/model/cat.ts b/tests/__snapshots__/mock/faker-array-items/model/cat.ts new file mode 100644 index 0000000000..de03a2dd05 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/cat.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ + +export interface Cat { + meow?: boolean; +} diff --git a/tests/__snapshots__/mock/faker-array-items/model/dog.ts b/tests/__snapshots__/mock/faker-array-items/model/dog.ts new file mode 100644 index 0000000000..9cbc10dadb --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/dog.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ + +export interface Dog { + bark?: boolean; +} diff --git a/tests/__snapshots__/mock/faker-array-items/model/getCollide200.ts b/tests/__snapshots__/mock/faker-array-items/model/getCollide200.ts new file mode 100644 index 0000000000..ea2b9a9c71 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getCollide200.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ +import type { GetCollide200Inner } from './getCollide200Inner'; +import type { GetCollide200Outer } from './getCollide200Outer'; + +export type GetCollide200 = { + outer?: GetCollide200Outer; + inner?: GetCollide200Inner; +}; diff --git a/tests/__snapshots__/mock/faker-array-items/model/getCollide200Inner.ts b/tests/__snapshots__/mock/faker-array-items/model/getCollide200Inner.ts new file mode 100644 index 0000000000..160c12763a --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getCollide200Inner.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ +import type { GetCollide200InnerItemsItem } from './getCollide200InnerItemsItem'; + +export type GetCollide200Inner = { + items?: GetCollide200InnerItemsItem[]; +}; diff --git a/tests/__snapshots__/mock/faker-array-items/model/getCollide200InnerItemsItem.ts b/tests/__snapshots__/mock/faker-array-items/model/getCollide200InnerItemsItem.ts new file mode 100644 index 0000000000..a9c81477ca --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getCollide200InnerItemsItem.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ + +export type GetCollide200InnerItemsItem = { + b?: number; +}; diff --git a/tests/__snapshots__/mock/faker-array-items/model/getCollide200Outer.ts b/tests/__snapshots__/mock/faker-array-items/model/getCollide200Outer.ts new file mode 100644 index 0000000000..a5cdae4227 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getCollide200Outer.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ +import type { GetCollide200OuterItemsItem } from './getCollide200OuterItemsItem'; + +export type GetCollide200Outer = { + items?: GetCollide200OuterItemsItem[]; +}; diff --git a/tests/__snapshots__/mock/faker-array-items/model/getCollide200OuterItemsItem.ts b/tests/__snapshots__/mock/faker-array-items/model/getCollide200OuterItemsItem.ts new file mode 100644 index 0000000000..3a5e4cd6ba --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getCollide200OuterItemsItem.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ + +export type GetCollide200OuterItemsItem = { + a?: string; +}; diff --git a/tests/__snapshots__/mock/faker-array-items/model/getNames200.ts b/tests/__snapshots__/mock/faker-array-items/model/getNames200.ts new file mode 100644 index 0000000000..0614b82299 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getNames200.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ +import type { Name } from './name'; + +export type GetNames200 = { + names?: Name[]; +}; diff --git a/tests/__snapshots__/mock/faker-array-items/model/getNullable200.ts b/tests/__snapshots__/mock/faker-array-items/model/getNullable200.ts new file mode 100644 index 0000000000..ed4f2b651a --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getNullable200.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ +import type { GetNullable200RowsItem } from './getNullable200RowsItem'; + +export type GetNullable200 = { + rows?: GetNullable200RowsItem[]; +}; diff --git a/tests/__snapshots__/mock/faker-array-items/model/getNullable200RowsItem.ts b/tests/__snapshots__/mock/faker-array-items/model/getNullable200RowsItem.ts new file mode 100644 index 0000000000..99880dcab2 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getNullable200RowsItem.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ + +/** + * @nullable + */ +export type GetNullable200RowsItem = { + id?: string; +} | null; diff --git a/tests/__snapshots__/mock/faker-array-items/model/getThings200.ts b/tests/__snapshots__/mock/faker-array-items/model/getThings200.ts new file mode 100644 index 0000000000..0d1a248b07 --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/getThings200.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ +import type { Cat } from './cat'; +import type { Dog } from './dog'; + +export type GetThings200 = { + things?: (Cat | Dog)[]; +}; diff --git a/tests/__snapshots__/mock/faker-array-items/model/index.ts b/tests/__snapshots__/mock/faker-array-items/model/index.ts index a8a61bbc06..24fe19dba5 100644 --- a/tests/__snapshots__/mock/faker-array-items/model/index.ts +++ b/tests/__snapshots__/mock/faker-array-items/model/index.ts @@ -5,7 +5,19 @@ * OpenAPI spec version: 1.0.0 */ +export * from './cat'; +export * from './dog'; +export * from './getCollide200'; +export * from './getCollide200Inner'; +export * from './getCollide200InnerItemsItem'; +export * from './getCollide200Outer'; +export * from './getCollide200OuterItemsItem'; +export * from './getNames200'; +export * from './getNullable200'; +export * from './getNullable200RowsItem'; export * from './getTenants200'; export * from './getTenants200ValueItem'; +export * from './getThings200'; +export * from './name'; export * from './tenantListResponse'; export * from './tenantResponseModelDto'; diff --git a/tests/__snapshots__/mock/faker-array-items/model/name.ts b/tests/__snapshots__/mock/faker-array-items/model/name.ts new file mode 100644 index 0000000000..4aa71d112d --- /dev/null +++ b/tests/__snapshots__/mock/faker-array-items/model/name.ts @@ -0,0 +1,8 @@ +/** + * Generated by orval v8.14.0 🍺 + * Do not edit manually. + * Faker array item factories + * OpenAPI spec version: 1.0.0 + */ + +export type Name = string; diff --git a/tests/specifications/faker-array-items.yaml b/tests/specifications/faker-array-items.yaml index f16a48afcb..70a057042a 100644 --- a/tests/specifications/faker-array-items.yaml +++ b/tests/specifications/faker-array-items.yaml @@ -70,8 +70,111 @@ paths: application/json: schema: $ref: '#/components/schemas/TenantListResponse' + /names: + get: + operationId: getNames + tags: + - edge-cases + responses: + '200': + description: Scalar ref array items + content: + application/json: + schema: + type: object + properties: + names: + type: array + items: + $ref: '#/components/schemas/Name' + /things: + get: + operationId: getThings + tags: + - edge-cases + responses: + '200': + description: oneOf array items + content: + application/json: + schema: + type: object + properties: + things: + type: array + items: + oneOf: + - $ref: '#/components/schemas/Cat' + - $ref: '#/components/schemas/Dog' + /nullable-rows: + get: + operationId: getNullable + tags: + - edge-cases + responses: + '200': + description: Nullable object array items + content: + application/json: + schema: + type: object + properties: + rows: + type: array + items: + type: object + nullable: true + properties: + id: + type: string + /collide: + get: + operationId: getCollide + tags: + - edge-cases + responses: + '200': + description: Same property name under nested parents + content: + application/json: + schema: + type: object + properties: + outer: + type: object + properties: + items: + type: array + items: + type: object + properties: + a: + type: string + inner: + type: object + properties: + items: + type: array + items: + type: object + properties: + b: + type: number components: schemas: + Name: + type: string + format: email + Cat: + type: object + properties: + meow: + type: boolean + Dog: + type: object + properties: + bark: + type: boolean TenantResponseModelDto: type: object required: