From 61dec0203a8016a5d984e7369168855578f6407d Mon Sep 17 00:00:00 2001 From: The Ult Date: Fri, 15 May 2026 15:38:35 +0200 Subject: [PATCH 01/18] fix(angular): emit filterParams helper for untagged ops in tags-split default file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When tags-split mode is used and an operation has no tags, orval assigns it to the 'default' file. The generateAngularHeader and getRelevantVerbOptions helpers filtered verbOptions using v.tags.some(...), which always returns false for verbs with an empty tags array. This caused hasQueryParams to be false even though the operation had query params, so the filterParams helper was never emitted — while the method body still called it, resulting in a compile error. Fix by also matching verbs with empty tags when the current tag is 'default', mirroring the addDefaultTagIfEmpty logic in the writer layer. Fixes #3103 Co-Authored-By: Claude Sonnet 4.6 --- packages/angular/src/http-client.test.ts | 27 ++++++++++++++++++++++++ packages/angular/src/http-client.ts | 6 ++++-- packages/angular/src/http-resource.ts | 8 +++++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/packages/angular/src/http-client.test.ts b/packages/angular/src/http-client.test.ts index d338583587..bc0eb5e29d 100644 --- a/packages/angular/src/http-client.test.ts +++ b/packages/angular/src/http-client.test.ts @@ -408,6 +408,33 @@ describe('angular HttpClient generator', () => { expect(header).not.toContain('type ThirdParameter'); }); + + it('emits filterParams helper for untagged operations in tags-split default file (#3103)', () => { + const queryParams = { + schema: { name: 'GetApiProductParams', imports: [], ...({} as never) }, + deps: [], + imports: [], + originalSchema: {} as never, + requiredNullableKeys: [], + }; + const verbOptionWithQueryParams = createVerbOption({ + tags: [], + queryParams, + }); + + const header = generateAngularHeader({ + title: 'DefaultService', + isRequestOptions: true, + isMutator: false, + isGlobalMutator: false, + provideIn: 'root', + hasAwaitedType: false, + verbOptions: { getApiProduct: verbOptionWithQueryParams }, + tag: 'default', + } as never); + + expect(header).toContain('function filterParams('); + }); }); // ── Footer ──────────────────────────────────────────────────────────── diff --git a/packages/angular/src/http-client.ts b/packages/angular/src/http-client.ts index 4685782a1f..9d5d839535 100644 --- a/packages/angular/src/http-client.ts +++ b/packages/angular/src/http-client.ts @@ -231,8 +231,10 @@ export const generateAngularHeader: ClientHeaderBuilder = ({ returnTypesRegistry.reset(); const relevantVerbs = tag - ? Object.values(verbOptions).filter((v) => - v.tags.some((t) => camel(t) === camel(tag)), + ? Object.values(verbOptions).filter( + (v) => + v.tags.some((t) => camel(t) === camel(tag)) || + (camel(tag) === 'default' && v.tags.length === 0), ) : Object.values(verbOptions); const hasQueryParams = relevantVerbs.some((v) => v.queryParams); diff --git a/packages/angular/src/http-resource.ts b/packages/angular/src/http-resource.ts index 54e9f661f4..a02e392894 100644 --- a/packages/angular/src/http-resource.ts +++ b/packages/angular/src/http-resource.ts @@ -167,8 +167,12 @@ const getRelevantVerbOptions = ( tag?: string, ): GeneratorVerbOptions[] => tag - ? Object.values(verbOptions).filter((verbOption) => - verbOption.tags.some((currentTag) => camel(currentTag) === camel(tag)), + ? Object.values(verbOptions).filter( + (verbOption) => + verbOption.tags.some( + (currentTag) => camel(currentTag) === camel(tag), + ) || + (camel(tag) === 'default' && verbOption.tags.length === 0), ) : Object.values(verbOptions); From df27c8f97a6d7596f77bdeee6529fe0f7675b08b Mon Sep 17 00:00:00 2001 From: The Ult Date: Fri, 15 May 2026 20:38:56 +0200 Subject: [PATCH 02/18] refactor(angular): eliminate redundant camel(tag) calls in verb filter Extract camel(tag) into a local variable before the filter loop in both generateAngularHeader (http-client.ts) and getRelevantVerbOptions (http-resource.ts). The previous code recomputed camel(tag) on every iteration, including the default-branch guard added for untagged ops. Also adds a missing regression test for the http-resource path: untagged operations with query params passed to tag='default' should produce a header that contains the filterParams helper (mirrors the existing test in http-client.test.ts). Co-Authored-By: Claude Sonnet 4.6 --- packages/angular/src/http-client.ts | 7 +++-- packages/angular/src/http-resource.test.ts | 33 ++++++++++++++++++++++ packages/angular/src/http-resource.ts | 19 ++++++------- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/packages/angular/src/http-client.ts b/packages/angular/src/http-client.ts index 9d5d839535..ac57b46a7a 100644 --- a/packages/angular/src/http-client.ts +++ b/packages/angular/src/http-client.ts @@ -230,11 +230,12 @@ export const generateAngularHeader: ClientHeaderBuilder = ({ }) => { returnTypesRegistry.reset(); - const relevantVerbs = tag + const camelTag = tag ? camel(tag) : undefined; + const relevantVerbs = camelTag ? Object.values(verbOptions).filter( (v) => - v.tags.some((t) => camel(t) === camel(tag)) || - (camel(tag) === 'default' && v.tags.length === 0), + v.tags.some((t) => camel(t) === camelTag) || + (camelTag === 'default' && v.tags.length === 0), ) : Object.values(verbOptions); const hasQueryParams = relevantVerbs.some((v) => v.queryParams); diff --git a/packages/angular/src/http-resource.test.ts b/packages/angular/src/http-resource.test.ts index d4fa9a3aa6..7e7c3c6023 100644 --- a/packages/angular/src/http-resource.test.ts +++ b/packages/angular/src/http-resource.test.ts @@ -1075,6 +1075,39 @@ describe('angular httpResource generator', () => { expect(header).toContain('getPetByIdResource'); expect(header).toContain('healthCheckResource'); }); + + it('emits filterParams helper for untagged operations in tags-split default file (#3103)', () => { + const verbOptionWithQueryParams = createVerbOption({ + tags: [], + queryParams: { + schema: { name: 'GetApiProductParams', model: '', imports: [] }, + deps: [], + isOptional: true, + name: 'params', + definition: 'params: GetApiProductParams', + implementation: 'params: GetApiProductParams', + default: false, + required: false, + type: GetterPropType.QUERY_PARAM, + } as never, + }); + routeRegistry.set('getPetById', '/api/pets/${petId}'); + + const header = generateHttpResourceHeader({ + title: 'DefaultService', + isRequestOptions: true, + isMutator: false, + isGlobalMutator: false, + provideIn: 'root', + hasAwaitedType: false, + output: createOutput(), + verbOptions: { getPetById: verbOptionWithQueryParams }, + tag: 'default', + clientImplementation: '', + } as never); + + expect(header).toContain('function filterParams('); + }); }); // ─── Response type factories ────────────────────────────────────── diff --git a/packages/angular/src/http-resource.ts b/packages/angular/src/http-resource.ts index a02e392894..4f445db347 100644 --- a/packages/angular/src/http-resource.ts +++ b/packages/angular/src/http-resource.ts @@ -165,16 +165,15 @@ export const routeRegistry = createRouteRegistry(); const getRelevantVerbOptions = ( verbOptions: Record, tag?: string, -): GeneratorVerbOptions[] => - tag - ? Object.values(verbOptions).filter( - (verbOption) => - verbOption.tags.some( - (currentTag) => camel(currentTag) === camel(tag), - ) || - (camel(tag) === 'default' && verbOption.tags.length === 0), - ) - : Object.values(verbOptions); +): GeneratorVerbOptions[] => { + if (!tag) return Object.values(verbOptions); + const camelTag = camel(tag); + return Object.values(verbOptions).filter( + (verbOption) => + verbOption.tags.some((currentTag) => camel(currentTag) === camelTag) || + (camelTag === 'default' && verbOption.tags.length === 0), + ); +}; const getVerbOptionsRecord = ( verbOptions: readonly GeneratorVerbOptions[], From fea40a87cdfa3d0b585c357967f0b20943ef4a62 Mon Sep 17 00:00:00 2001 From: The Ult Date: Fri, 15 May 2026 21:24:17 +0200 Subject: [PATCH 03/18] fix(angular): add regression coverage for untagged default services Align the Angular header regression test with the real getter query param shape so package typecheck and lint cover the #3103 scenario again. Add a shared tags-split fixture and snapshot assertion for untagged operations so the generated default service keeps emitting filterParams. Fixes #3103 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/angular/src/http-client.test.ts | 15 +- .../issue-3103/default/default.service.ts | 159 ++++++++++++++++++ .../issue-3103/model/getApiProductParams.ts | 10 ++ .../angular/issue-3103/model/index.ts | 9 + .../angular/issue-3103/model/product.ts | 10 ++ tests/api-generation.spec.ts | 17 ++ tests/configs/angular.config.ts | 13 ++ tests/specifications/issue-3103.yaml | 29 ++++ 8 files changed, 254 insertions(+), 8 deletions(-) create mode 100644 tests/__snapshots__/angular/issue-3103/default/default.service.ts create mode 100644 tests/__snapshots__/angular/issue-3103/model/getApiProductParams.ts create mode 100644 tests/__snapshots__/angular/issue-3103/model/index.ts create mode 100644 tests/__snapshots__/angular/issue-3103/model/product.ts create mode 100644 tests/specifications/issue-3103.yaml diff --git a/packages/angular/src/http-client.test.ts b/packages/angular/src/http-client.test.ts index bc0eb5e29d..c79fb06aaf 100644 --- a/packages/angular/src/http-client.test.ts +++ b/packages/angular/src/http-client.test.ts @@ -410,16 +410,15 @@ describe('angular HttpClient generator', () => { }); it('emits filterParams helper for untagged operations in tags-split default file (#3103)', () => { - const queryParams = { - schema: { name: 'GetApiProductParams', imports: [], ...({} as never) }, - deps: [], - imports: [], - originalSchema: {} as never, - requiredNullableKeys: [], - }; const verbOptionWithQueryParams = createVerbOption({ tags: [], - queryParams, + queryParams: { + schema: { name: 'GetApiProductParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: {} as never, + requiredNullableKeys: [], + }, }); const header = generateAngularHeader({ diff --git a/tests/__snapshots__/angular/issue-3103/default/default.service.ts b/tests/__snapshots__/angular/issue-3103/default/default.service.ts new file mode 100644 index 0000000000..e70e7df995 --- /dev/null +++ b/tests/__snapshots__/angular/issue-3103/default/default.service.ts @@ -0,0 +1,159 @@ +/** + * Generated by orval v8.10.0 🍺 + * Do not edit manually. + * Issue 3103 - Angular tags-split default service query params + * OpenAPI spec version: 1.0.0 + */ +import { + HttpClient, + HttpHeaders, + HttpResponse as AngularHttpResponse, +} from '@angular/common/http'; +import type { HttpContext, HttpEvent, HttpParams } from '@angular/common/http'; + +import { Injectable, inject } from '@angular/core'; + +import { Observable } from 'rxjs'; + +import type { GetApiProductParams, Product } from '../model'; + +interface HttpClientOptions { + readonly headers?: HttpHeaders | Record; + readonly context?: HttpContext; + readonly params?: + | HttpParams + | Record< + string, + string | number | boolean | Array + >; + readonly reportProgress?: boolean; + readonly withCredentials?: boolean; + readonly credentials?: RequestCredentials; + readonly keepalive?: boolean; + readonly priority?: RequestPriority; + readonly cache?: RequestCache; + readonly mode?: RequestMode; + readonly redirect?: RequestRedirect; + readonly referrer?: string; + readonly integrity?: string; + readonly referrerPolicy?: ReferrerPolicy; + readonly transferCache?: { includeHeaders?: string[] } | boolean; + readonly timeout?: number; +} + +type HttpClientBodyOptions = HttpClientOptions & { + readonly observe?: 'body'; +}; + +type HttpClientEventOptions = HttpClientOptions & { + readonly observe: 'events'; +}; + +type HttpClientResponseOptions = HttpClientOptions & { + readonly observe: 'response'; +}; + +type HttpClientObserveOptions = HttpClientOptions & { + readonly observe?: 'body' | 'events' | 'response'; +}; + +type AngularHttpParamValue = + | string + | number + | boolean + | Array; +type AngularHttpParamValueWithNullable = AngularHttpParamValue | null; + +function filterParams( + params: Record, + requiredNullableKeys?: ReadonlySet, + preserveRequiredNullables?: false, +): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: true, +): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet = new Set(), + preserveRequiredNullables = false, +): Record { + const filteredParams: Record = {}; + for (const [key, value] of Object.entries(params)) { + if (Array.isArray(value)) { + const filtered = value.filter( + (item) => + item != null && + (typeof item === 'string' || + typeof item === 'number' || + typeof item === 'boolean'), + ) as Array; + if (filtered.length) { + filteredParams[key] = filtered; + } + } else if ( + preserveRequiredNullables && + value === null && + requiredNullableKeys.has(key) + ) { + filteredParams[key] = null; + } else if ( + value != null && + (typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean') + ) { + filteredParams[key] = value; + } + } + return filteredParams; +} + +@Injectable({ providedIn: 'root' }) +export class DefaultService { + private readonly http = inject(HttpClient); + getApiProduct( + params?: GetApiProductParams, + options?: HttpClientBodyOptions, + ): Observable; + getApiProduct( + params?: GetApiProductParams, + options?: HttpClientEventOptions, + ): Observable>; + getApiProduct( + params?: GetApiProductParams, + options?: HttpClientResponseOptions, + ): Observable>; + getApiProduct( + params?: GetApiProductParams, + options?: HttpClientObserveOptions, + ): Observable | AngularHttpResponse> { + const filteredParams = filterParams( + { ...params, ...options?.params }, + new Set([]), + ); + + if (options?.observe === 'events') { + return this.http.get(`/api/Product`, { + ...(options as Omit, 'observe'>), + observe: 'events', + params: filteredParams, + }); + } + + if (options?.observe === 'response') { + return this.http.get(`/api/Product`, { + ...(options as Omit, 'observe'>), + observe: 'response', + params: filteredParams, + }); + } + + return this.http.get(`/api/Product`, { + ...(options as Omit, 'observe'>), + observe: 'body', + params: filteredParams, + }); + } +} diff --git a/tests/__snapshots__/angular/issue-3103/model/getApiProductParams.ts b/tests/__snapshots__/angular/issue-3103/model/getApiProductParams.ts new file mode 100644 index 0000000000..69d0338127 --- /dev/null +++ b/tests/__snapshots__/angular/issue-3103/model/getApiProductParams.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.10.0 🍺 + * Do not edit manually. + * Issue 3103 - Angular tags-split default service query params + * OpenAPI spec version: 1.0.0 + */ + +export type GetApiProductParams = { + q?: string; +}; diff --git a/tests/__snapshots__/angular/issue-3103/model/index.ts b/tests/__snapshots__/angular/issue-3103/model/index.ts new file mode 100644 index 0000000000..c6f4d2e4e3 --- /dev/null +++ b/tests/__snapshots__/angular/issue-3103/model/index.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v8.10.0 🍺 + * Do not edit manually. + * Issue 3103 - Angular tags-split default service query params + * OpenAPI spec version: 1.0.0 + */ + +export * from './getApiProductParams'; +export * from './product'; diff --git a/tests/__snapshots__/angular/issue-3103/model/product.ts b/tests/__snapshots__/angular/issue-3103/model/product.ts new file mode 100644 index 0000000000..ba795fff22 --- /dev/null +++ b/tests/__snapshots__/angular/issue-3103/model/product.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.10.0 🍺 + * Do not edit manually. + * Issue 3103 - Angular tags-split default service query params + * OpenAPI spec version: 1.0.0 + */ + +export interface Product { + id?: number; +} diff --git a/tests/api-generation.spec.ts b/tests/api-generation.spec.ts index 776f70f7d9..78c14455db 100644 --- a/tests/api-generation.spec.ts +++ b/tests/api-generation.spec.ts @@ -1,5 +1,8 @@ +import { readFile } from 'node:fs/promises'; import path from 'node:path'; +import { expect, test } from 'vitest'; + import { describeApiGenerationSnapshots } from '../test-utils/snapshot-testing'; const generated = (...segments: string[]) => @@ -26,3 +29,17 @@ await describeApiGenerationSnapshots({ snapshotsDir: path.resolve(import.meta.dirname, '__snapshots__'), rootDir: path.resolve(import.meta.dirname, '..'), }); + +test('angular issue-3103 emits filterParams in tags-split default service', async () => { + const defaultServiceFile = generated( + 'angular', + 'issue-3103', + 'default', + 'default.service.ts', + ); + const content = await readFile(defaultServiceFile, 'utf8'); + + expect(content).toContain('export class DefaultService'); + expect(content).toContain('function filterParams('); + expect(content).toContain('const filteredParams = filterParams('); +}); diff --git a/tests/configs/angular.config.ts b/tests/configs/angular.config.ts index 16c54cccb1..a719439dc0 100644 --- a/tests/configs/angular.config.ts +++ b/tests/configs/angular.config.ts @@ -210,4 +210,17 @@ export default defineConfig({ target: '../specifications/angular-multi-content-query-params.yaml', }, }, + issue3103: { + output: { + target: '../generated/angular/issue-3103/endpoints.ts', + schemas: '../generated/angular/issue-3103/model', + client: 'angular', + mode: 'tags-split', + clean: true, + formatter: 'prettier', + }, + input: { + target: '../specifications/issue-3103.yaml', + }, + }, }); diff --git a/tests/specifications/issue-3103.yaml b/tests/specifications/issue-3103.yaml new file mode 100644 index 0000000000..4f19fa5606 --- /dev/null +++ b/tests/specifications/issue-3103.yaml @@ -0,0 +1,29 @@ +openapi: 3.0.4 +info: + title: Issue 3103 - Angular tags-split default service query params + version: 1.0.0 +paths: + /api/Product: + get: + operationId: getApiProduct + parameters: + - name: q + in: query + required: false + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Product' +components: + schemas: + Product: + type: object + properties: + id: + type: integer + format: int32 From b8747da82af9eec24c1a38d8d8d15b5d4b4faae7 Mon Sep 17 00:00:00 2001 From: The Ult Date: Fri, 15 May 2026 22:13:02 +0200 Subject: [PATCH 04/18] fix(angular): address PR review comments Separate the implicit default tag bucket from a literal user-defined default tag so Angular tag filtering only includes untagged operations when the writer explicitly requests it. Extract the shared tag filter helper so http-client and http-resource stay aligned, and document why the focused #3103 regression test exists alongside snapshots. Refs #3103 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/angular/src/http-client.test.ts | 206 +++++++++++++++++++++ packages/angular/src/http-client.ts | 66 +++---- packages/angular/src/http-resource.test.ts | 46 ++++- packages/angular/src/http-resource.ts | 68 +++---- packages/angular/src/utils.ts | 18 ++ packages/core/src/types.ts | 18 ++ packages/core/src/writers/target-tags.ts | 9 + packages/orval/src/client.ts | 2 + tests/api-generation.spec.ts | 2 + 9 files changed, 370 insertions(+), 65 deletions(-) diff --git a/packages/angular/src/http-client.test.ts b/packages/angular/src/http-client.test.ts index c79fb06aaf..1c2b872d78 100644 --- a/packages/angular/src/http-client.test.ts +++ b/packages/angular/src/http-client.test.ts @@ -430,6 +430,124 @@ describe('angular HttpClient generator', () => { hasAwaitedType: false, verbOptions: { getApiProduct: verbOptionWithQueryParams }, tag: 'default', + isDefaultTagBucket: true, + } as never); + + expect(header).toContain('function filterParams('); + }); + + it('does not treat a literal default tag as the untagged bucket', () => { + const untaggedVerb = createVerbOption({ + operationId: 'getUntaggedProduct', + tags: [], + queryParams: { + schema: { name: 'GetApiProductParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: {} as never, + requiredNullableKeys: [], + }, + }); + const explicitDefaultVerb = createVerbOption({ + operationId: 'getTaggedDefaultProduct', + tags: ['default'], + }); + + const header = generateAngularHeader({ + title: 'DefaultService', + isRequestOptions: true, + isMutator: false, + isGlobalMutator: false, + provideIn: 'root', + hasAwaitedType: false, + verbOptions: { + getUntaggedProduct: untaggedVerb, + getTaggedDefaultProduct: explicitDefaultVerb, + }, + tag: 'default', + isDefaultTagBucket: false, + } as never); + + expect(header).not.toContain('function filterParams('); + }); + + // Issue #3326: a user-supplied `paramsFilter` mutator owns the filter + // logic entirely, so the shared built-in helper would be dead code if + // every operation overrides it. + it('suppresses the shared filterParams helper when every operation has paramsFilter', () => { + const verbOptionWithCustomFilter = createVerbOption({ + queryParams: { + schema: { name: 'GetPetByIdParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: {} as never, + requiredNullableKeys: [], + }, + paramsFilter: { + name: 'myFilter', + path: './my-filter', + default: false, + hasErrorType: false, + errorTypeName: '', + hasSecondArg: false, + hasThirdArg: false, + isHook: false, + }, + }); + + const header = generateAngularHeader({ + title: 'PetService', + isRequestOptions: true, + isMutator: false, + isGlobalMutator: false, + provideIn: 'root', + hasAwaitedType: false, + verbOptions: { getPetById: verbOptionWithCustomFilter }, + } as never); + + expect(header).not.toContain('function filterParams('); + }); + + it('still emits the shared helper when at least one operation lacks paramsFilter', () => { + const verbWithFilter = createVerbOption({ + operationName: 'a', + queryParams: { + schema: { name: 'AParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: {} as never, + requiredNullableKeys: [], + }, + paramsFilter: { + name: 'myFilter', + path: './my-filter', + default: false, + hasErrorType: false, + errorTypeName: '', + hasSecondArg: false, + hasThirdArg: false, + isHook: false, + }, + }); + const verbWithoutFilter = createVerbOption({ + operationName: 'b', + queryParams: { + schema: { name: 'BParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: {} as never, + requiredNullableKeys: [], + }, + }); + + const header = generateAngularHeader({ + title: 'PetService', + isRequestOptions: true, + isMutator: false, + isGlobalMutator: false, + provideIn: 'root', + hasAwaitedType: false, + verbOptions: { a: verbWithFilter, b: verbWithoutFilter }, } as never); expect(header).toContain('function filterParams('); @@ -486,6 +604,94 @@ describe('angular HttpClient generator', () => { // ── Implementation — GET ────────────────────────────────────────────── + // ── paramsFilter + nonPrimitiveKeys (issue #3326) ───────────────────── + + describe('query parameter filtering (#3326)', () => { + const customFilter = { + name: 'myFilter', + path: './my-filter', + default: false, + hasErrorType: false, + errorTypeName: '', + hasSecondArg: false, + hasThirdArg: false, + isHook: false, + }; + + it('preserves nonPrimitiveKeys through the built-in filter', () => { + const verbOption = createVerbOption({ + queryParams: { + schema: { name: 'GetPetByIdParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: {} as never, + requiredNullableKeys: [], + nonPrimitiveKeys: ['filters'], + }, + }); + const options = createGeneratorOptions(); + + const impl = generateHttpClientImplementation(verbOption, options); + + // The shared `filterParams` is invoked with the passthrough set so + // `filters` survives. + expect(impl).toContain('new Set(["filters"])'); + }); + + it('replaces the built-in filter with the user-supplied paramsFilter', () => { + const verbOption = createVerbOption({ + queryParams: { + schema: { name: 'GetPetByIdParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: {} as never, + requiredNullableKeys: [], + }, + paramsFilter: customFilter, + }); + const options = createGeneratorOptions(); + + const impl = generateHttpClientImplementation(verbOption, options); + + // Filtered params come from `myFilter(...)`; the built-in helper is + // not called for this operation. + expect(impl).toContain( + 'const filteredParams = myFilter({...params, ...options?.params})', + ); + expect(impl).not.toContain('filterParams({...params'); + }); + + it('wraps a configured paramsSerializer around the custom paramsFilter', () => { + const verbOption = createVerbOption({ + queryParams: { + schema: { name: 'GetPetByIdParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: {} as never, + requiredNullableKeys: [], + }, + paramsFilter: customFilter, + paramsSerializer: { + name: 'mySerializer', + path: './my-serializer', + default: false, + hasErrorType: false, + errorTypeName: '', + hasSecondArg: false, + hasThirdArg: false, + isHook: false, + }, + }); + const options = createGeneratorOptions(); + + const impl = generateHttpClientImplementation(verbOption, options); + + expect(impl).toContain( + 'const filteredParams = mySerializer(myFilter({...params, ...options?.params}))', + ); + }); + }); + describe('generateHttpClientImplementation', () => { it('generates a GET method with typed return', () => { const verbOption = createVerbOption(); diff --git a/packages/angular/src/http-client.ts b/packages/angular/src/http-client.ts index ac57b46a7a..e440f312eb 100644 --- a/packages/angular/src/http-client.ts +++ b/packages/angular/src/http-client.ts @@ -1,5 +1,5 @@ import { - camel, + buildAngularParamsFilterExpression, type ClientBuilder, type ClientDependenciesBuilder, type ClientFooterBuilder, @@ -12,8 +12,6 @@ import { generateOptions, generateVerbImports, type GeneratorVerbOptions, - getAngularFilteredParamsCallExpression, - getAngularFilteredParamsExpression, getAngularFilteredParamsHelperBody, getDefaultContentType, getEnumImplementation, @@ -33,6 +31,7 @@ import { } from './types'; import { createReturnTypesRegistry, + getRelevantVerbOptionsForTag, getSchemaOutputTypeRef, isPrimitiveType, isZodSchemaOutput, @@ -226,19 +225,22 @@ export const generateAngularHeader: ClientHeaderBuilder = ({ provideIn, verbOptions, tag, + isDefaultTagBucket, output, }) => { returnTypesRegistry.reset(); - const camelTag = tag ? camel(tag) : undefined; - const relevantVerbs = camelTag - ? Object.values(verbOptions).filter( - (v) => - v.tags.some((t) => camel(t) === camelTag) || - (camelTag === 'default' && v.tags.length === 0), - ) - : Object.values(verbOptions); - const hasQueryParams = relevantVerbs.some((v) => v.queryParams); + const relevantVerbs = getRelevantVerbOptionsForTag( + verbOptions, + tag, + isDefaultTagBucket, + ); + // Only emit the shared `filterParams` helper when at least one operation in + // this file will actually call it. If every operation with queryParams has + // its own `paramsFilter` mutator, the helper would be dead code. + const hasBuiltInFilteredQueryParams = relevantVerbs.some( + (v) => v.queryParams && !v.paramsFilter, + ); const acceptHelpers = buildAcceptHelpers(relevantVerbs, output); return ` @@ -248,7 +250,7 @@ ${ ${HTTP_CLIENT_OBSERVE_OPTIONS_TEMPLATE} -${hasQueryParams ? getAngularFilteredParamsHelperBody() : ''}` +${hasBuiltInFilteredQueryParams ? getAngularFilteredParamsHelperBody() : ''}` : '' } @@ -317,6 +319,7 @@ export const generateHttpClientImplementation = ( formData, formUrlEncoded, paramsSerializer, + paramsFilter, }: GeneratorVerbOptions, { route, context }: HttpClientGeneratorContext, ) => { @@ -412,6 +415,7 @@ export const generateHttpClientImplementation = ( hasSignal: false, isExactOptionalPropertyTypes, isAngular: true, + paramsFilter, }); const requestOptions = isRequestOptions @@ -454,6 +458,7 @@ export const generateHttpClientImplementation = ( isFormUrlEncoded, paramsSerializer, paramsSerializerOptions: override.paramsSerializerOptions, + paramsFilter, isAngular: true, isExactOptionalPropertyTypes, hasSignal: false, @@ -473,26 +478,21 @@ export const generateHttpClientImplementation = ( let paramsDeclaration = ''; if (angularParamsRef && queryParams) { - if (isRequestOptions) { - // Uses the shared filterParams helper emitted in the file header - const callExpr = getAngularFilteredParamsCallExpression( - '{...params, ...options?.params}', - queryParams.requiredNullableKeys ?? [], - ); - paramsDeclaration = paramsSerializer - ? `const ${angularParamsRef} = ${paramsSerializer.name}(${callExpr});\n\n ` - : `const ${angularParamsRef} = ${callExpr};\n\n `; - } else { - // No shared helper available; use inline IIFE filtering - const iifeExpr = getAngularFilteredParamsExpression( - 'params ?? {}', - queryParams.requiredNullableKeys ?? [], - !!paramsSerializer, - ); - paramsDeclaration = paramsSerializer - ? `const ${angularParamsRef} = ${paramsSerializer.name}(${iifeExpr});\n\n ` - : `const ${angularParamsRef} = ${iifeExpr};\n\n `; - } + const filterExpr = buildAngularParamsFilterExpression({ + paramsExpression: isRequestOptions + ? '{...params, ...options?.params}' + : 'params ?? {}', + requiredNullableParamKeys: queryParams.requiredNullableKeys ?? [], + preserveRequiredNullables: !isRequestOptions && !!paramsSerializer, + nonPrimitiveKeys: queryParams.nonPrimitiveKeys ?? [], + paramsFilter, + // Request-options path uses the shared `filterParams` helper emitted in + // the file header; the non-request-options path inlines an IIFE. + useSharedHelper: isRequestOptions, + }); + paramsDeclaration = paramsSerializer + ? `const ${angularParamsRef} = ${paramsSerializer.name}(${filterExpr});\n\n ` + : `const ${angularParamsRef} = ${filterExpr};\n\n `; } const optionsInput = { diff --git a/packages/angular/src/http-resource.test.ts b/packages/angular/src/http-resource.test.ts index 7e7c3c6023..d4411f9339 100644 --- a/packages/angular/src/http-resource.test.ts +++ b/packages/angular/src/http-resource.test.ts @@ -875,7 +875,9 @@ describe('angular httpResource generator', () => { } as never); expect(header.match(/type AngularHttpParamValue =/g)).toHaveLength(1); - expect(header.match(/function filterParams\(/g)).toHaveLength(3); + expect(header.match(/preserveRequiredNullables = false,/g)).toHaveLength( + 1, + ); }); }); @@ -1103,11 +1105,53 @@ describe('angular httpResource generator', () => { output: createOutput(), verbOptions: { getPetById: verbOptionWithQueryParams }, tag: 'default', + isDefaultTagBucket: true, clientImplementation: '', } as never); expect(header).toContain('function filterParams('); }); + + it('does not treat a literal default tag as the untagged bucket', () => { + const untaggedVerb = createVerbOption({ + operationId: 'getUntaggedProduct', + tags: [], + queryParams: { + schema: { name: 'GetApiProductParams', model: '', imports: [] }, + deps: [], + isOptional: true, + name: 'params', + definition: 'params: GetApiProductParams', + implementation: 'params: GetApiProductParams', + default: false, + required: false, + type: GetterPropType.QUERY_PARAM, + } as never, + }); + const explicitDefaultVerb = createVerbOption({ + operationId: 'getTaggedDefaultProduct', + tags: ['default'], + }); + + const header = generateHttpResourceHeader({ + title: 'DefaultService', + isRequestOptions: true, + isMutator: false, + isGlobalMutator: false, + provideIn: 'root', + hasAwaitedType: false, + output: createOutput(), + verbOptions: { + getUntaggedProduct: untaggedVerb, + getTaggedDefaultProduct: explicitDefaultVerb, + }, + tag: 'default', + isDefaultTagBucket: false, + clientImplementation: '', + } as never); + + expect(header).not.toContain('function filterParams('); + }); }); // ─── Response type factories ────────────────────────────────────── diff --git a/packages/angular/src/http-resource.ts b/packages/angular/src/http-resource.ts index 4f445db347..d70f7eb5d9 100644 --- a/packages/angular/src/http-resource.ts +++ b/packages/angular/src/http-resource.ts @@ -1,5 +1,5 @@ import { - camel, + buildAngularParamsFilterExpression, type ClientBuilder, type ClientDependenciesBuilder, type ClientExtraFilesBuilder, @@ -14,7 +14,6 @@ import { type GeneratorDependency, type GeneratorImport, type GeneratorVerbOptions, - getAngularFilteredParamsCallExpression, getAngularFilteredParamsHelperBody, getFileInfo, getFullRoute, @@ -51,6 +50,7 @@ import { createReturnTypesRegistry, createRouteRegistry, getDefaultSuccessType, + getRelevantVerbOptionsForTag, getSchemaOutputTypeRef, isMutationVerb, isPrimitiveType, @@ -162,19 +162,6 @@ const resourceReturnTypesRegistry = createReturnTypesRegistry(); /** @internal Exported for testing only */ export const routeRegistry = createRouteRegistry(); -const getRelevantVerbOptions = ( - verbOptions: Record, - tag?: string, -): GeneratorVerbOptions[] => { - if (!tag) return Object.values(verbOptions); - const camelTag = camel(tag); - return Object.values(verbOptions).filter( - (verbOption) => - verbOption.tags.some((currentTag) => camel(currentTag) === camelTag) || - (camelTag === 'default' && verbOption.tags.length === 0), - ); -}; - const getVerbOptionsRecord = ( verbOptions: readonly GeneratorVerbOptions[], ): Record => @@ -460,6 +447,7 @@ const buildResourceRequest = ( headers, queryParams, paramsSerializer, + paramsFilter, override, formData, formUrlEncoded, @@ -494,11 +482,14 @@ const buildResourceRequest = ( const paramsAccess = queryParams ? 'params?.()' : undefined; const headersAccess = headers ? 'headers?.()' : undefined; const filteredParamsValue = paramsAccess - ? getAngularFilteredParamsCallExpression( - `${paramsAccess} ?? {}`, - queryParams?.requiredNullableKeys ?? [], - !!paramsSerializer, - ) + ? buildAngularParamsFilterExpression({ + paramsExpression: `${paramsAccess} ?? {}`, + requiredNullableParamKeys: queryParams?.requiredNullableKeys ?? [], + preserveRequiredNullables: !!paramsSerializer, + nonPrimitiveKeys: queryParams?.nonPrimitiveKeys ?? [], + paramsFilter, + useSharedHelper: true, + }) : undefined; const paramsValue = paramsAccess ? paramsSerializer @@ -1221,6 +1212,7 @@ export const generateHttpResourceHeader: ClientHeaderBuilder = ({ output, verbOptions, tag, + isDefaultTagBucket, }) => { resetHttpClientReturnTypes(); resourceReturnTypesRegistry.reset(); @@ -1230,7 +1222,11 @@ export const generateHttpResourceHeader: ClientHeaderBuilder = ({ // the shared header duplicates helpers across every tag file and pulls in // type names the file-local `imports` filter never sees, producing missing // schema imports in the generated output. - const relevantVerbOptions = getRelevantVerbOptions(verbOptions, tag); + const relevantVerbOptions = getRelevantVerbOptionsForTag( + verbOptions, + tag, + isDefaultTagBucket, + ); const retrievals = relevantVerbOptions.filter((verbOption) => isRetrievalVerb( @@ -1239,10 +1235,13 @@ export const generateHttpResourceHeader: ClientHeaderBuilder = ({ getClientOverride(verbOption), ), ); - const hasResourceQueryParams = retrievals.some( - (verbOption) => !!verbOption.queryParams, + // Emit the shared `filterParams` helper only when at least one retrieval + // with query params lacks its own `paramsFilter` mutator — otherwise the + // helper would be dead code. + const hasBuiltInFilteredQueryParams = retrievals.some( + (verbOption) => !!verbOption.queryParams && !verbOption.paramsFilter, ); - const filterParamsHelper = hasResourceQueryParams + const filterParamsHelper = hasBuiltInFilteredQueryParams ? `\n${getAngularFilteredParamsHelperBody()}\n` : ''; const resources = retrievals @@ -1269,8 +1268,11 @@ export const generateHttpResourceHeader: ClientHeaderBuilder = ({ [...retrievals, ...mutations], output, ); - const hasMutationQueryParams = mutations.some( - (verbOption) => !!verbOption.queryParams, + // Mutations need the built-in helper only when at least one mutation lacks + // its own `paramsFilter`. If the resource section already emits the helper + // for retrievals, we suppress the mutation-side emission to avoid duplication. + const hasMutationBuiltInFilteredQueryParams = mutations.some( + (verbOption) => !!verbOption.queryParams && !verbOption.paramsFilter, ); const mutationImplementation = mutations @@ -1296,7 +1298,8 @@ ${buildServiceClassOpen({ isMutator, isGlobalMutator, provideIn, - hasQueryParams: hasMutationQueryParams && !hasResourceQueryParams, + hasQueryParams: + hasMutationBuiltInFilteredQueryParams && !hasBuiltInFilteredQueryParams, })} ${mutationImplementation} }; @@ -1361,10 +1364,13 @@ const buildHttpResourceFile = ( ), ); - const hasResourceQueryParams = retrievals.some( - (verbOption) => !!verbOption.queryParams, + // Emit the shared `filterParams` helper only when at least one retrieval + // with query params lacks its own `paramsFilter` mutator — otherwise the + // helper would be dead code. + const hasBuiltInFilteredQueryParams = retrievals.some( + (verbOption) => !!verbOption.queryParams && !verbOption.paramsFilter, ); - const filterParamsHelper = hasResourceQueryParams + const filterParamsHelper = hasBuiltInFilteredQueryParams ? `\n${getAngularFilteredParamsHelperBody()}\n` : ''; @@ -1619,7 +1625,7 @@ export const generateHttpResourceExtraFiles: ClientExtraFilesBuilder = ( return Promise.resolve([ buildHttpResourceExtraFile( - getVerbOptionsRecord(getRelevantVerbOptions(verbOptions)), + getVerbOptionsRecord(getRelevantVerbOptionsForTag(verbOptions)), getHttpResourceExtraFilePath(output), output, context, diff --git a/packages/angular/src/utils.ts b/packages/angular/src/utils.ts index 7bb5e44695..d0cfb63697 100644 --- a/packages/angular/src/utils.ts +++ b/packages/angular/src/utils.ts @@ -1,4 +1,6 @@ import { + camel, + type GeneratorVerbOptions, getAngularFilteredParamsHelperBody, getDefaultContentType, isBoolean, @@ -125,6 +127,22 @@ export const createRouteRegistry = () => { }; }; +export const getRelevantVerbOptionsForTag = ( + verbOptions: Record, + tag?: string, + isDefaultTagBucket = false, +): GeneratorVerbOptions[] => { + if (!tag) return Object.values(verbOptions); + + const camelTag = camel(tag); + + return Object.values(verbOptions).filter( + (verbOption) => + verbOption.tags.some((currentTag) => camel(currentTag) === camelTag) || + (isDefaultTagBucket && verbOption.tags.length === 0), + ); +}; + export const createReturnTypesRegistry = () => { const returnTypesToWrite = new Map(); diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index bf707acc6f..74d0a2f3ab 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -97,6 +97,7 @@ export interface NormalizedOverrideOutput { formUrlEncoded: boolean | NormalizedMutator; paramsSerializer?: NormalizedMutator; paramsSerializerOptions?: NormalizedParamsSerializerOptions; + paramsFilter?: NormalizedMutator; namingConvention: { enum?: NamingConvention; }; @@ -200,6 +201,7 @@ export interface NormalizedOperationOptions { formData?: NormalizedFormDataType; formUrlEncoded?: boolean | NormalizedMutator; paramsSerializer?: NormalizedMutator; + paramsFilter?: NormalizedMutator; requestOptions?: object | boolean; } @@ -526,6 +528,7 @@ export interface OverrideOutput { formUrlEncoded?: boolean | Mutator; paramsSerializer?: Mutator; paramsSerializerOptions?: ParamsSerializerOptions; + paramsFilter?: Mutator; namingConvention?: { enum?: NamingConvention; }; @@ -909,6 +912,7 @@ export interface OperationOptions { formData?: boolean | Mutator | FormDataType; formUrlEncoded?: boolean | Mutator; paramsSerializer?: Mutator; + paramsFilter?: Mutator; requestOptions?: object | boolean; } @@ -1062,6 +1066,7 @@ export interface GeneratorTarget { formData?: GeneratorMutator[]; formUrlEncoded?: GeneratorMutator[]; paramsSerializer?: GeneratorMutator[]; + paramsFilter?: GeneratorMutator[]; fetchReviver?: GeneratorMutator[]; } @@ -1079,6 +1084,7 @@ export interface GeneratorTargetFull { formData?: GeneratorMutator[]; formUrlEncoded?: GeneratorMutator[]; paramsSerializer?: GeneratorMutator[]; + paramsFilter?: GeneratorMutator[]; fetchReviver?: GeneratorMutator[]; } @@ -1097,6 +1103,7 @@ export interface GeneratorOperation { formData?: GeneratorMutator; formUrlEncoded?: GeneratorMutator; paramsSerializer?: GeneratorMutator; + paramsFilter?: GeneratorMutator; fetchReviver?: GeneratorMutator; operationName: string; types?: { @@ -1123,6 +1130,7 @@ export interface GeneratorVerbOptions { formData?: GeneratorMutator; formUrlEncoded?: GeneratorMutator; paramsSerializer?: GeneratorMutator; + paramsFilter?: GeneratorMutator; fetchReviver?: GeneratorMutator; override: NormalizedOverrideOutput; deprecated?: boolean; @@ -1192,6 +1200,7 @@ export type ClientHeaderBuilder = (params: { output: NormalizedOutputOptions; verbOptions: Record; tag?: string; + isDefaultTagBucket?: boolean; clientImplementation: string; }) => string; @@ -1292,6 +1301,14 @@ export interface GetterQueryParam { isOptional: boolean; originalSchema?: OpenApiSchemaObject; requiredNullableKeys?: string[]; + /** + * Names of query parameters whose declared schema is non-primitive + * (object, array of objects, or untyped). Used by Angular generators to + * preserve these values through the default `filterParams` helper instead + * of silently dropping them — the user's `paramsSerializer`, `mutator`, or + * `paramsFilter` is then responsible for handling them. + */ + nonPrimitiveKeys?: string[]; } export type GetterPropType = @@ -1430,6 +1447,7 @@ export type GeneratorClientHeader = (data: { output: NormalizedOutputOptions; verbOptions: Record; tag?: string; + isDefaultTagBucket?: boolean; clientImplementation: string; }) => GeneratorClientExtra; diff --git a/packages/core/src/writers/target-tags.ts b/packages/core/src/writers/target-tags.ts index 63402bb466..798e507e80 100644 --- a/packages/core/src/writers/target-tags.ts +++ b/packages/core/src/writers/target-tags.ts @@ -34,6 +34,7 @@ function generateTargetTags( paramsSerializer: operation.paramsSerializer ? [operation.paramsSerializer] : [], + paramsFilter: operation.paramsFilter ? [operation.paramsFilter] : [], fetchReviver: operation.fetchReviver ? [operation.fetchReviver] : [], implementation: operation.implementation, implementationMock: { @@ -85,6 +86,9 @@ function generateTargetTags( operation.paramsSerializer, ] : currentOperation.paramsSerializer, + paramsFilter: operation.paramsFilter + ? [...(currentOperation.paramsFilter ?? []), operation.paramsFilter] + : currentOperation.paramsFilter, fetchReviver: operation.fetchReviver ? [...(currentOperation.fetchReviver ?? []), operation.fetchReviver] : currentOperation.fetchReviver, @@ -155,6 +159,11 @@ export function generateTargetForTags( output: options, verbOptions: builder.verbOptions, tag, + isDefaultTagBucket: + tag === 'default' && + Object.values(builder.operations).some( + (operation) => operation.tags.length === 0, + ), clientImplementation: target.implementation, }); diff --git a/packages/orval/src/client.ts b/packages/orval/src/client.ts index 4addbfb37b..5890831398 100644 --- a/packages/orval/src/client.ts +++ b/packages/orval/src/client.ts @@ -123,6 +123,7 @@ export const generateClientHeader: GeneratorClientHeader = ({ output, verbOptions, tag, + isDefaultTagBucket, clientImplementation, }) => { const { header } = getGeneratorClient(outputClient, output); @@ -138,6 +139,7 @@ export const generateClientHeader: GeneratorClientHeader = ({ output, verbOptions, tag, + isDefaultTagBucket, clientImplementation, }) : '', diff --git a/tests/api-generation.spec.ts b/tests/api-generation.spec.ts index 78c14455db..88dd309b98 100644 --- a/tests/api-generation.spec.ts +++ b/tests/api-generation.spec.ts @@ -31,6 +31,8 @@ await describeApiGenerationSnapshots({ }); test('angular issue-3103 emits filterParams in tags-split default service', async () => { + // Keep this focused assertion alongside the snapshot so #3103 fails with a + // targeted message instead of a full-file snapshot diff. const defaultServiceFile = generated( 'angular', 'issue-3103', From 688b04671af84481126c0fa566248e2dc0993e37 Mon Sep 17 00:00:00 2001 From: The Ult Date: Fri, 15 May 2026 22:18:17 +0200 Subject: [PATCH 05/18] fix(core): include paramsFilter in generated targets Keep the single-target writer in sync with the other target builders by initializing and collecting paramsFilter mutators in GeneratorTargetFull. This fixes the package typecheck failure on the PR branch. Refs #3103 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/core/src/writers/target.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/src/writers/target.ts b/packages/core/src/writers/target.ts index 410333ba89..f62bae9a02 100644 --- a/packages/core/src/writers/target.ts +++ b/packages/core/src/writers/target.ts @@ -37,6 +37,7 @@ export function generateTarget( formData: [], formUrlEncoded: [], paramsSerializer: [], + paramsFilter: [], fetchReviver: [], }; const operations = Object.values(builder.operations); @@ -65,6 +66,9 @@ export function generateTarget( if (operation.paramsSerializer) { target.paramsSerializer.push(operation.paramsSerializer); } + if (operation.paramsFilter) { + target.paramsFilter.push(operation.paramsFilter); + } if (operation.clientMutators) { target.clientMutators.push(...operation.clientMutators); From baab3d719bce340ed697f061e307fce5d67ea07a Mon Sep 17 00:00:00 2001 From: The Ult Date: Fri, 15 May 2026 22:22:45 +0200 Subject: [PATCH 06/18] fix(core): export angular params filter plumbing Bring the core options generator changes onto the PR branch so Angular can import buildAngularParamsFilterExpression and pass paramsFilter through the mutator config path on a clean checkout. Refs #3103 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/core/src/generators/options.ts | 150 +++++++++++++++++++++--- 1 file changed, 131 insertions(+), 19 deletions(-) diff --git a/packages/core/src/generators/options.ts b/packages/core/src/generators/options.ts index d0f7552352..e9fa7997b5 100644 --- a/packages/core/src/generators/options.ts +++ b/packages/core/src/generators/options.ts @@ -27,8 +27,21 @@ export const getAngularFilteredParamsExpression = ( paramsExpression: string, requiredNullableParamKeys: string[] = [], preserveRequiredNullables = false, + nonPrimitiveKeys: string[] = [], ): string => { - const filteredParamValueType = `string | number | boolean${preserveRequiredNullables ? ' | null' : ''} | Array`; + const hasPassthrough = nonPrimitiveKeys.length > 0; + const filteredParamValueType = hasPassthrough + ? 'unknown' + : `string | number | boolean${preserveRequiredNullables ? ' | null' : ''} | Array`; + const passthroughBranch = hasPassthrough + ? ` if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } +` + : ''; const preserveNullableBranch = preserveRequiredNullables ? ` } else if (value === null && requiredNullableParamKeys.has(key)) { filteredParams[key] = null; @@ -43,12 +56,15 @@ export const getAngularFilteredParamsExpression = ( filteredParams[key] = value; } `; + const passthroughDecl = hasPassthrough + ? ` const passthroughKeys = new Set(${JSON.stringify(nonPrimitiveKeys)});\n` + : ''; return `(() => { - const requiredNullableParamKeys = new Set(${JSON.stringify(requiredNullableParamKeys)}); +${passthroughDecl} const requiredNullableParamKeys = new Set(${JSON.stringify(requiredNullableParamKeys)}); const filteredParams: Record = {}; for (const [key, value] of Object.entries(${paramsExpression})) { - if (Array.isArray(value)) { +${passthroughBranch} if (Array.isArray(value)) { const filtered = value.filter( (item) => item != null && @@ -77,19 +93,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => @@ -126,8 +157,57 @@ export const getAngularFilteredParamsCallExpression = ( paramsExpression: string, requiredNullableParamKeys: string[] = [], preserveRequiredNullables = false, -): string => - `filterParams(${paramsExpression}, new Set(${JSON.stringify(requiredNullableParamKeys)})${preserveRequiredNullables ? ', true' : ''})`; + nonPrimitiveKeys: string[] = [], +): string => { + const baseArgs = `${paramsExpression}, new Set(${JSON.stringify(requiredNullableParamKeys)})`; + if (nonPrimitiveKeys.length > 0) { + return `filterParams(${baseArgs}, ${preserveRequiredNullables}, new Set(${JSON.stringify(nonPrimitiveKeys)}))`; + } + return `filterParams(${baseArgs}${preserveRequiredNullables ? ', true' : ''})`; +}; + +/** + * Returns the filter call/IIFE used to massage query params before passing + * them to Angular's HttpParams. When the user supplied a `paramsFilter` + * mutator, the built-in `filterParams` is bypassed entirely and the user's + * function is called with the raw params — they own nullish-stripping and + * any object/array handling. Otherwise the built-in filter is used (either + * the shared helper or an inline IIFE), and `nonPrimitiveKeys` keeps schema- + * declared object/array-of-object params from being silently dropped. + */ +export const buildAngularParamsFilterExpression = ({ + paramsExpression, + requiredNullableParamKeys = [], + preserveRequiredNullables = false, + nonPrimitiveKeys = [], + paramsFilter, + useSharedHelper, +}: { + paramsExpression: string; + requiredNullableParamKeys?: string[]; + preserveRequiredNullables?: boolean; + nonPrimitiveKeys?: string[]; + paramsFilter?: GeneratorMutator; + useSharedHelper: boolean; +}): string => { + if (paramsFilter) { + return `${paramsFilter.name}(${paramsExpression})`; + } + if (useSharedHelper) { + return getAngularFilteredParamsCallExpression( + paramsExpression, + requiredNullableParamKeys, + preserveRequiredNullables, + nonPrimitiveKeys, + ); + } + return getAngularFilteredParamsExpression( + paramsExpression, + requiredNullableParamKeys, + preserveRequiredNullables, + nonPrimitiveKeys, + ); +}; interface GenerateFormDataAndUrlEncodedFunctionOptions { body: GetterBody; @@ -163,6 +243,7 @@ interface GenerateAxiosOptions { angularObserve?: 'body' | 'events' | 'response'; angularParamsRef?: string; requiredNullableQueryParamKeys?: string[]; + nonPrimitiveQueryParamKeys?: string[]; queryParams?: GeneratorSchema; headers?: GeneratorSchema; requestOptions?: object | boolean; @@ -172,6 +253,7 @@ interface GenerateAxiosOptions { isAngular: boolean; paramsSerializer?: GeneratorMutator; paramsSerializerOptions?: ParamsSerializerOptions; + paramsFilter?: GeneratorMutator; } export function generateAxiosOptions({ @@ -180,6 +262,7 @@ export function generateAxiosOptions({ angularObserve, angularParamsRef, requiredNullableQueryParamKeys, + nonPrimitiveQueryParamKeys, queryParams, headers, requestOptions, @@ -189,6 +272,7 @@ export function generateAxiosOptions({ isAngular, paramsSerializer, paramsSerializerOptions, + paramsFilter, }: GenerateAxiosOptions) { const isRequestOptions = requestOptions !== false; // Use querySignal if API has a param named "signal" to avoid conflict @@ -224,11 +308,14 @@ export function generateAxiosOptions({ if (!isRequestOptions) { if (queryParams) { if (isAngular) { - const iifeExpr = getAngularFilteredParamsExpression( - 'params ?? {}', - requiredNullableQueryParamKeys, - !!paramsSerializer, - ); + const iifeExpr = buildAngularParamsFilterExpression({ + paramsExpression: 'params ?? {}', + requiredNullableParamKeys: requiredNullableQueryParamKeys, + preserveRequiredNullables: !!paramsSerializer, + nonPrimitiveKeys: nonPrimitiveQueryParamKeys, + paramsFilter, + useSharedHelper: false, + }); value += paramsSerializer ? `\n params: ${paramsSerializer.name}(${iifeExpr}),` : `\n params: ${iifeExpr},`; @@ -277,14 +364,24 @@ export function generateAxiosOptions({ } else if (isAngular && angularParamsRef) { value += `\n params: ${angularParamsRef},`; } else if (isAngular && paramsSerializer) { - const callExpr = getAngularFilteredParamsCallExpression( - '{...params, ...options?.params}', - requiredNullableQueryParamKeys, - true, - ); + const callExpr = buildAngularParamsFilterExpression({ + paramsExpression: '{...params, ...options?.params}', + requiredNullableParamKeys: requiredNullableQueryParamKeys, + preserveRequiredNullables: true, + nonPrimitiveKeys: nonPrimitiveQueryParamKeys, + paramsFilter, + useSharedHelper: true, + }); value += `\n params: ${paramsSerializer.name}(${callExpr}),`; } else if (isAngular) { - value += `\n params: ${getAngularFilteredParamsCallExpression('{...params, ...options?.params}', requiredNullableQueryParamKeys)},`; + const callExpr = buildAngularParamsFilterExpression({ + paramsExpression: '{...params, ...options?.params}', + requiredNullableParamKeys: requiredNullableQueryParamKeys, + nonPrimitiveKeys: nonPrimitiveQueryParamKeys, + paramsFilter, + useSharedHelper: true, + }); + value += `\n params: ${callExpr},`; } else { value += '\n params: {...params, ...options?.params},'; } @@ -330,6 +427,7 @@ interface GenerateOptionsOptions { isVue?: boolean; paramsSerializer?: GeneratorMutator; paramsSerializerOptions?: ParamsSerializerOptions; + paramsFilter?: GeneratorMutator; } export function generateOptions({ @@ -351,6 +449,7 @@ export function generateOptions({ isVue, paramsSerializer, paramsSerializerOptions, + paramsFilter, }: GenerateOptionsOptions) { const bodyIdentifier = getIsBodyVerb(verb) ? generateBodyOptions(body, isFormData, isFormUrlEncoded) @@ -361,6 +460,7 @@ export function generateOptions({ angularObserve, angularParamsRef, requiredNullableQueryParamKeys: queryParams?.requiredNullableKeys, + nonPrimitiveQueryParamKeys: queryParams?.nonPrimitiveKeys, queryParams: queryParams?.schema, headers: headers?.schema, requestOptions, @@ -371,6 +471,7 @@ export function generateOptions({ isAngular: isAngular ?? false, paramsSerializer, paramsSerializerOptions, + paramsFilter, }); const trimmedAxiosOptions = axiosOptions.trim(); @@ -433,6 +534,7 @@ export function generateQueryParamsAxiosConfig( isAngular: boolean, requiredNullableQueryParamKeys?: string[], queryParams?: GetterQueryParam, + paramsFilter?: GeneratorMutator, ) { if (!queryParams && !response.isBlob) { return ''; @@ -444,7 +546,14 @@ export function generateQueryParamsAxiosConfig( if (isVue) { value += ',\n params: unref(params)'; } else if (isAngular) { - value += `,\n params: ${getAngularFilteredParamsExpression('params ?? {}', requiredNullableQueryParamKeys)}`; + const paramsExpr = buildAngularParamsFilterExpression({ + paramsExpression: 'params ?? {}', + requiredNullableParamKeys: requiredNullableQueryParamKeys, + nonPrimitiveKeys: queryParams.nonPrimitiveKeys, + paramsFilter, + useSharedHelper: false, + }); + value += `,\n params: ${paramsExpr}`; } else { value += ',\n params'; } @@ -471,6 +580,7 @@ interface GenerateMutatorConfigOptions { isExactOptionalPropertyTypes: boolean; isVue?: boolean; isAngular?: boolean; + paramsFilter?: GeneratorMutator; } export function generateMutatorConfig({ @@ -487,6 +597,7 @@ export function generateMutatorConfig({ isExactOptionalPropertyTypes, isVue, isAngular, + paramsFilter, }: GenerateMutatorConfigOptions) { const bodyOptions = getIsBodyVerb(verb) ? generateBodyMutatorConfig(body, isFormData, isFormUrlEncoded) @@ -498,6 +609,7 @@ export function generateMutatorConfig({ isAngular ?? false, queryParams?.requiredNullableKeys, queryParams, + paramsFilter, ); const ignoreContentTypes = isAngular ? ['multipart/form-data'] : []; From 426afc31171031888d411a355b0344c9965d8881 Mon Sep 17 00:00:00 2001 From: The Ult Date: Fri, 15 May 2026 22:28:03 +0200 Subject: [PATCH 07/18] fix(orval): normalize paramsFilter overrides Normalize paramsFilter in the top-level override and per-operation override paths so the orval package typecheck matches the new core paramsFilter plumbing on a clean checkout. Refs #3103 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/orval/src/utils/options.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/orval/src/utils/options.ts b/packages/orval/src/utils/options.ts index ad0dc5c126..d95aa29534 100644 --- a/packages/orval/src/utils/options.ts +++ b/packages/orval/src/utils/options.ts @@ -293,6 +293,10 @@ export async function normalizeOptions( outputWorkspace, outputOptions.override?.paramsSerializer, ), + paramsFilter: normalizeMutator( + outputWorkspace, + outputOptions.override?.paramsFilter, + ), header: outputOptions.override?.header === false ? false @@ -634,6 +638,7 @@ function normalizeOperationsAndTags( formData, formUrlEncoded, paramsSerializer, + paramsFilter, query, angular, zod, @@ -759,6 +764,11 @@ function normalizeOperationsAndTags( ), } : {}), + ...(paramsFilter + ? { + paramsFilter: normalizeMutator(workspace, paramsFilter), + } + : {}), }, ]; }, From e1a283fbbb6f594977d6a82f7f3c14a224b735c7 Mon Sep 17 00:00:00 2001 From: The Ult Date: Fri, 15 May 2026 22:40:44 +0200 Subject: [PATCH 08/18] test(angular): Refresh sample snapshots for paramsFilter Regenerate the Angular sample outputs after the paramsFilter helper\nsignature changes. Keep the checked-in sample sources and golden\nsnapshots aligned so the PR branch matches the generated Angular\noutput expected by CI.\n\nRefs #3103\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../api/endpoints-zod/pets/pets.service.ts | 19 +++++++++++++++++-- .../api/http-both/pets/pets.resource.ts | 19 +++++++++++++++++-- .../api/http-both/pets/pets.service.ts | 19 +++++++++++++++++-- .../pets/pets.service.ts | 19 +++++++++++++++++-- .../api/http-client/pets/pets.service.ts | 19 +++++++++++++++++-- .../http-resource-zod/pets/pets.service.ts | 19 +++++++++++++++++-- .../api/http-resource/pets/pets.service.ts | 19 +++++++++++++++++-- .../api/endpoints-zod/pets/pets.service.ts | 19 +++++++++++++++++-- .../src/api/http-both/pets/pets.resource.ts | 19 +++++++++++++++++-- .../src/api/http-both/pets/pets.service.ts | 19 +++++++++++++++++-- .../pets/pets.service.ts | 19 +++++++++++++++++-- .../src/api/http-client/pets/pets.service.ts | 19 +++++++++++++++++-- .../http-resource-zod/pets/pets.service.ts | 19 +++++++++++++++++-- .../api/http-resource/pets/pets.service.ts | 19 +++++++++++++++++-- 14 files changed, 238 insertions(+), 28 deletions(-) diff --git a/samples/angular-app/__snapshots__/api/endpoints-zod/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/endpoints-zod/pets/pets.service.ts index b520192112..21ceddaaf3 100644 --- a/samples/angular-app/__snapshots__/api/endpoints-zod/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/endpoints-zod/pets/pets.service.ts @@ -77,19 +77,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-both/pets/pets.resource.ts b/samples/angular-app/__snapshots__/api/http-both/pets/pets.resource.ts index c932a5f32b..162763a014 100644 --- a/samples/angular-app/__snapshots__/api/http-both/pets/pets.resource.ts +++ b/samples/angular-app/__snapshots__/api/http-both/pets/pets.resource.ts @@ -34,19 +34,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-both/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/http-both/pets/pets.service.ts index 0b41491579..ccfe57d32e 100644 --- a/samples/angular-app/__snapshots__/api/http-both/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/http-both/pets/pets.service.ts @@ -74,19 +74,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-client-custom-params/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/http-client-custom-params/pets/pets.service.ts index 3a1efa7faf..719849af7d 100644 --- a/samples/angular-app/__snapshots__/api/http-client-custom-params/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/http-client-custom-params/pets/pets.service.ts @@ -76,19 +76,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-client/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/http-client/pets/pets.service.ts index 1f73892896..e3b20d3c29 100644 --- a/samples/angular-app/__snapshots__/api/http-client/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/http-client/pets/pets.service.ts @@ -76,19 +76,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-resource-zod/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/http-resource-zod/pets/pets.service.ts index 200aaf8a22..5ac225d449 100644 --- a/samples/angular-app/__snapshots__/api/http-resource-zod/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/http-resource-zod/pets/pets.service.ts @@ -54,19 +54,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-resource/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/http-resource/pets/pets.service.ts index b3fadd8567..d3cf9f039a 100644 --- a/samples/angular-app/__snapshots__/api/http-resource/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/http-resource/pets/pets.service.ts @@ -51,19 +51,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/endpoints-zod/pets/pets.service.ts b/samples/angular-app/src/api/endpoints-zod/pets/pets.service.ts index b520192112..21ceddaaf3 100644 --- a/samples/angular-app/src/api/endpoints-zod/pets/pets.service.ts +++ b/samples/angular-app/src/api/endpoints-zod/pets/pets.service.ts @@ -77,19 +77,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-both/pets/pets.resource.ts b/samples/angular-app/src/api/http-both/pets/pets.resource.ts index c932a5f32b..162763a014 100644 --- a/samples/angular-app/src/api/http-both/pets/pets.resource.ts +++ b/samples/angular-app/src/api/http-both/pets/pets.resource.ts @@ -34,19 +34,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-both/pets/pets.service.ts b/samples/angular-app/src/api/http-both/pets/pets.service.ts index 0b41491579..ccfe57d32e 100644 --- a/samples/angular-app/src/api/http-both/pets/pets.service.ts +++ b/samples/angular-app/src/api/http-both/pets/pets.service.ts @@ -74,19 +74,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-client-custom-params/pets/pets.service.ts b/samples/angular-app/src/api/http-client-custom-params/pets/pets.service.ts index 3a1efa7faf..719849af7d 100644 --- a/samples/angular-app/src/api/http-client-custom-params/pets/pets.service.ts +++ b/samples/angular-app/src/api/http-client-custom-params/pets/pets.service.ts @@ -76,19 +76,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-client/pets/pets.service.ts b/samples/angular-app/src/api/http-client/pets/pets.service.ts index 1f73892896..e3b20d3c29 100644 --- a/samples/angular-app/src/api/http-client/pets/pets.service.ts +++ b/samples/angular-app/src/api/http-client/pets/pets.service.ts @@ -76,19 +76,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-resource-zod/pets/pets.service.ts b/samples/angular-app/src/api/http-resource-zod/pets/pets.service.ts index 200aaf8a22..5ac225d449 100644 --- a/samples/angular-app/src/api/http-resource-zod/pets/pets.service.ts +++ b/samples/angular-app/src/api/http-resource-zod/pets/pets.service.ts @@ -54,19 +54,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-resource/pets/pets.service.ts b/samples/angular-app/src/api/http-resource/pets/pets.service.ts index b3fadd8567..d3cf9f039a 100644 --- a/samples/angular-app/src/api/http-resource/pets/pets.service.ts +++ b/samples/angular-app/src/api/http-resource/pets/pets.service.ts @@ -51,19 +51,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => From 180b194a916d26bcb0cdc385ed5e92dc9b19e9ae Mon Sep 17 00:00:00 2001 From: The Ult Date: Fri, 15 May 2026 23:30:50 +0200 Subject: [PATCH 09/18] test(angular-query): Update filterParams snapshots with passthroughKeys overloads Regenerate the 4 angular-query sample snapshot files to include the new passthroughKeys overload signatures in filterParams. This unblocks CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../endpoints-custom-instance/pets/pets.ts | 19 +++++++++++++++++-- .../api/endpoints-no-transformer/pets/pets.ts | 19 +++++++++++++++++-- .../src/api/endpoints-zod/pets/pets.ts | 19 +++++++++++++++++-- .../src/api/endpoints/pets/pets.ts | 19 +++++++++++++++++-- 4 files changed, 68 insertions(+), 8 deletions(-) diff --git a/samples/angular-query/src/api/endpoints-custom-instance/pets/pets.ts b/samples/angular-query/src/api/endpoints-custom-instance/pets/pets.ts index 69cff46e90..56f2a97af7 100644 --- a/samples/angular-query/src/api/endpoints-custom-instance/pets/pets.ts +++ b/samples/angular-query/src/api/endpoints-custom-instance/pets/pets.ts @@ -48,19 +48,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/src/api/endpoints-no-transformer/pets/pets.ts b/samples/angular-query/src/api/endpoints-no-transformer/pets/pets.ts index 9588e1bf50..a3c1590854 100644 --- a/samples/angular-query/src/api/endpoints-no-transformer/pets/pets.ts +++ b/samples/angular-query/src/api/endpoints-no-transformer/pets/pets.ts @@ -47,19 +47,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/src/api/endpoints-zod/pets/pets.ts b/samples/angular-query/src/api/endpoints-zod/pets/pets.ts index 9fb6e495f5..c16ad8e19f 100644 --- a/samples/angular-query/src/api/endpoints-zod/pets/pets.ts +++ b/samples/angular-query/src/api/endpoints-zod/pets/pets.ts @@ -44,19 +44,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/src/api/endpoints/pets/pets.ts b/samples/angular-query/src/api/endpoints/pets/pets.ts index e52335901c..8d44fbff7e 100644 --- a/samples/angular-query/src/api/endpoints/pets/pets.ts +++ b/samples/angular-query/src/api/endpoints/pets/pets.ts @@ -50,19 +50,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => From 9e79d5e247e36e4226b420bcb2d76321fbfbbf19 Mon Sep 17 00:00:00 2001 From: The Ult Date: Fri, 15 May 2026 23:53:11 +0200 Subject: [PATCH 10/18] fix(angular): preserve params filter passthrough in generated params Route generated Angular params through user-defined paramsFilter helpers and only emit the shared filterParams helper when generated code still needs it. Refresh the affected Angular sample and snapshot outputs, and extend regression coverage for default-tag generation and non-primitive query-param passthrough. Refs #3103 Refs #3326 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/core/src/generators/options.test.ts | 79 ++++++++++ packages/core/src/generators/verbs-options.ts | 12 ++ .../core/src/getters/query-params.test.ts | 140 +++++++++++++++++- packages/core/src/getters/query-params.ts | 72 +++++++++ packages/core/src/writers/single-mode.ts | 5 + packages/core/src/writers/split-mode.ts | 7 + packages/core/src/writers/split-tags-mode.ts | 7 + packages/core/src/writers/tags-mode.ts | 5 + .../endpoints-custom-instance/pets/pets.ts | 19 ++- .../api/endpoints-no-transformer/pets/pets.ts | 19 ++- .../api/endpoints-zod/pets/pets.ts | 19 ++- .../__snapshots__/api/endpoints/pets/pets.ts | 19 ++- .../angular-query/basic/endpoints.ts | 19 ++- .../angular-query/split/endpoints.ts | 19 ++- .../angular-query/tags-split/pets/pets.ts | 19 ++- .../angular-query/use-prefetch/endpoints.ts | 19 ++- .../angular/http-resource-tags/pets.ts | 19 ++- .../http-resource-zod-disabled/endpoints.ts | 19 ++- .../angular/http-resource-zod/endpoints.ts | 19 ++- .../issue-3103/default/default.service.ts | 19 ++- .../multi-content-query-params/endpoints.ts | 19 ++- .../angular/named-parameters/endpoints.ts | 19 ++- .../angular/petstore/endpoints.ts | 19 ++- .../angular/split/endpoints.service.ts | 19 ++- .../angular/tags-split/pets/pets.service.ts | 19 ++- tests/__snapshots__/angular/tags/pets.ts | 19 ++- .../angular/zod-schema-response/endpoints.ts | 19 ++- .../issue-2998/requests/requests.service.ts | 19 ++- tests/mutators/params-filter.ts | 32 ++++ tests/specifications/issue-3326.yaml | 38 +++++ 30 files changed, 736 insertions(+), 41 deletions(-) create mode 100644 tests/mutators/params-filter.ts create mode 100644 tests/specifications/issue-3326.yaml diff --git a/packages/core/src/generators/options.test.ts b/packages/core/src/generators/options.test.ts index e66c6c8463..ad32337455 100644 --- a/packages/core/src/generators/options.test.ts +++ b/packages/core/src/generators/options.test.ts @@ -50,6 +50,17 @@ const minimalParamsSerializer: GeneratorMutator = { isHook: false, }; +const minimalParamsFilter: GeneratorMutator = { + name: 'paramsFilterMutator', + path: './paramsFilterMutator', + default: false, + hasErrorType: false, + errorTypeName: '', + hasSecondArg: false, + hasThirdArg: false, + isHook: false, +}; + const buildScalarValue = ( overrides: Partial, ): ResReqTypesValue => ({ @@ -403,6 +414,74 @@ describe('generateAxiosOptions', () => { ); expect(result).not.toContain('false &&'); }); + + // Issue #3326: schema-declared object/array-of-object query params used to + // be silently dropped by `filterParams`. With nonPrimitiveQueryParamKeys + // they are passed through so a downstream paramsSerializer/mutator/ + // paramsFilter can handle them. + it('passes nonPrimitiveKeys through the shared filter helper', () => { + const result = generateAxiosOptions({ + response: minimalResponse, + isExactOptionalPropertyTypes: false, + queryParams: minimalSchema, + nonPrimitiveQueryParamKeys: ['filters'], + headers: undefined, + requestOptions: true, + hasSignal: false, + isVue: false, + isAngular: true, + paramsSerializer: undefined, + paramsSerializerOptions: undefined, + }); + + // The shared helper is invoked with the passthrough set as the fourth + // argument so `filters` survives filtering. + expect(result).toContain('new Set(["filters"])'); + }); + + it('replaces the built-in filter when paramsFilter is configured', () => { + const result = generateAxiosOptions({ + response: minimalResponse, + isExactOptionalPropertyTypes: false, + queryParams: minimalSchema, + headers: undefined, + requestOptions: true, + hasSignal: false, + isVue: false, + isAngular: true, + paramsSerializer: undefined, + paramsSerializerOptions: undefined, + paramsFilter: minimalParamsFilter, + }); + + // The user's paramsFilter is the sole filter — `filterParams(...)` is + // not emitted alongside it. + expect(result).toContain( + 'params: paramsFilterMutator({...params, ...options?.params})', + ); + expect(result).not.toContain('filterParams('); + }); + + it('composes paramsSerializer around paramsFilter when both are set', () => { + const result = generateAxiosOptions({ + response: minimalResponse, + isExactOptionalPropertyTypes: false, + queryParams: minimalSchema, + headers: undefined, + requestOptions: true, + hasSignal: false, + isVue: false, + isAngular: true, + paramsSerializer: minimalParamsSerializer, + paramsSerializerOptions: undefined, + paramsFilter: minimalParamsFilter, + }); + + expect(result).toContain( + 'params: paramsSerializerMutator(paramsFilterMutator({...params, ...options?.params}))', + ); + expect(result).not.toContain('filterParams('); + }); }); }); diff --git a/packages/core/src/generators/verbs-options.ts b/packages/core/src/generators/verbs-options.ts index ffbee91ce1..a4aa9b08ea 100644 --- a/packages/core/src/generators/verbs-options.ts +++ b/packages/core/src/generators/verbs-options.ts @@ -167,6 +167,17 @@ async function buildVerbOption({ }) : undefined; + const paramsFilter = + isString(override.paramsFilter) || isObject(override.paramsFilter) + ? await generateMutator({ + output: output.target, + name: 'paramsFilter', + mutator: override.paramsFilter as NormalizedMutator, + workspace: context.workspace, + tsconfig: context.output.tsconfig, + }) + : undefined; + const fetchReviver = isString(override.fetch.jsonReviver) || isObject(override.fetch.jsonReviver) ? await generateMutator({ @@ -197,6 +208,7 @@ async function buildVerbOption({ formData, formUrlEncoded, paramsSerializer, + paramsFilter, fetchReviver, override, doc, diff --git a/packages/core/src/getters/query-params.test.ts b/packages/core/src/getters/query-params.test.ts index 0bf35a5f46..f9375213c3 100644 --- a/packages/core/src/getters/query-params.test.ts +++ b/packages/core/src/getters/query-params.test.ts @@ -7,9 +7,25 @@ import { getQueryParams } from './query-params'; const context: ContextSpec = { spec: {}, output: { - // @ts-expect-error -- partial mock: only override.useDates needed for test + // @ts-expect-error -- partial mock: query-param resolution only needs a + // small subset of normalized override output for these tests. override: { useDates: true, + components: { + schemas: { + suffix: 'Dto', + itemSuffix: 'Item', + }, + responses: { + suffix: 'Response', + }, + parameters: { + suffix: 'Params', + }, + requestBodies: { + suffix: 'Body', + }, + }, }, }, }; @@ -247,4 +263,126 @@ describe('getQueryParams getter', () => { 'requiredOneOfNullableParam', ]); }); + + // Tracking non-primitive keys lets Angular generators preserve schema- + // declared object/array-of-object params through the default filterParams + // helper instead of silently dropping them. See issue #3326. + describe('nonPrimitiveKeys (Angular passthrough)', () => { + it('flags object-typed query params', () => { + const result = getQueryParams({ + queryParams: [ + { + parameter: { + name: 'filters', + in: 'query', + required: false, + schema: { type: 'object' }, + }, + imports: [], + }, + { + parameter: { + name: 'limit', + in: 'query', + required: false, + schema: { type: 'integer' }, + }, + imports: [], + }, + ], + operationName: '', + context, + }); + + expect(result?.nonPrimitiveKeys).toEqual(['filters']); + }); + + it('flags arrays of objects', () => { + const result = getQueryParams({ + queryParams: [ + { + parameter: { + name: 'items', + in: 'query', + required: false, + schema: { + type: 'array', + items: { type: 'object' }, + }, + }, + imports: [], + }, + ], + operationName: '', + context, + }); + + expect(result?.nonPrimitiveKeys).toEqual(['items']); + }); + + it('flags object via oneOf composition', () => { + const result = getQueryParams({ + queryParams: [ + { + parameter: { + name: 'either', + in: 'query', + required: false, + schema: { + oneOf: [{ type: 'string' }, { type: 'object' }], + }, + }, + imports: [], + }, + ], + operationName: '', + context, + }); + + expect(result?.nonPrimitiveKeys).toEqual(['either']); + }); + + it('omits the field when all params are primitive', () => { + const result = getQueryParams({ + queryParams: [ + { + parameter: { + name: 'id', + in: 'query', + required: true, + schema: { type: 'string' }, + }, + imports: [], + }, + ], + operationName: '', + context, + }); + + expect(result?.nonPrimitiveKeys).toBeUndefined(); + }); + + it('does not flag arrays of primitives', () => { + const result = getQueryParams({ + queryParams: [ + { + parameter: { + name: 'tags', + in: 'query', + required: false, + schema: { + type: 'array', + items: { type: 'string' }, + }, + }, + imports: [], + }, + ], + operationName: '', + context, + }); + + expect(result?.nonPrimitiveKeys).toBeUndefined(); + }); + }); }); diff --git a/packages/core/src/getters/query-params.ts b/packages/core/src/getters/query-params.ts index 2610ba7523..26d857d262 100644 --- a/packages/core/src/getters/query-params.ts +++ b/packages/core/src/getters/query-params.ts @@ -31,6 +31,74 @@ const isOpenApiSchemaObject = ( return !('$ref' in value); }; +const getSchemaType = ( + schema: OpenApiSchemaObject, +): string | string[] | undefined => { + const type = (schema as { type?: unknown }).type; + + if (typeof type === 'string') { + return type; + } + + if ( + Array.isArray(type) && + type.every((variant): variant is string => typeof variant === 'string') + ) { + return type; + } + + return undefined; +}; + +/** + * Detects whether a query parameter's resolved schema is non-primitive — i.e. + * an object, an array of objects, or a composition (oneOf/anyOf/allOf) that + * resolves to a non-primitive shape. + * + * Used by Angular generators so the default `filterParams` helper preserves + * such values instead of silently dropping them. Angular's `HttpParams` only + * accepts primitives, but a user-provided `paramsSerializer`, `mutator`, or + * `paramsFilter` may need the raw object to flatten or stringify it. + */ +const isSchemaNonPrimitive = (schema: OpenApiSchemaObject): boolean => { + const schemaType = getSchemaType(schema); + const type = Array.isArray(schemaType) + ? schemaType.filter((variant) => variant !== 'null') + : schemaType; + + if (type === 'object') { + return true; + } + if (type === 'array') { + const items = (schema as { items?: unknown }).items; + if (isOpenApiSchemaObject(items)) { + return isSchemaNonPrimitive(items); + } + return false; + } + if (Array.isArray(type) && type.includes('object')) { + return true; + } + + const compositions = [ + ...(Array.isArray(schema.oneOf) ? (schema.oneOf as unknown[]) : []), + ...(Array.isArray(schema.anyOf) ? (schema.anyOf as unknown[]) : []), + ...(Array.isArray(schema.allOf) ? (schema.allOf as unknown[]) : []), + ]; + if (compositions.length > 0) { + return compositions.some( + (variant) => + isOpenApiSchemaObject(variant) && isSchemaNonPrimitive(variant), + ); + } + + if (!type && (schema as { properties?: unknown }).properties !== undefined) { + return true; + } + + return false; +}; + const isSchemaNullable = (schema: OpenApiSchemaObject): boolean => { if (schema.nullable === true) { return true; @@ -210,6 +278,9 @@ export function getQueryParams({ required && isSchemaNullable(originalSchema), ) .map(({ name }) => name); + const nonPrimitiveKeys = types + .filter(({ originalSchema }) => isSchemaNonPrimitive(originalSchema)) + .map(({ name }) => name); const schema = { name, @@ -222,5 +293,6 @@ export function getQueryParams({ deps: schemas, isOptional: allOptional, requiredNullableKeys, + ...(nonPrimitiveKeys.length > 0 ? { nonPrimitiveKeys } : {}), }; } diff --git a/packages/core/src/writers/single-mode.ts b/packages/core/src/writers/single-mode.ts index 1da5987969..8f996ba5bd 100644 --- a/packages/core/src/writers/single-mode.ts +++ b/packages/core/src/writers/single-mode.ts @@ -41,6 +41,7 @@ export async function writeSingleMode({ formData, formUrlEncoded, paramsSerializer, + paramsFilter, fetchReviver, } = generateTarget(builder, output); @@ -169,6 +170,10 @@ export async function writeSingleMode({ data += generateMutatorImports({ mutators: paramsSerializer }); } + if (paramsFilter) { + data += generateMutatorImports({ mutators: paramsFilter }); + } + if (fetchReviver) { data += generateMutatorImports({ mutators: fetchReviver }); } diff --git a/packages/core/src/writers/split-mode.ts b/packages/core/src/writers/split-mode.ts index 4c657d8e25..fb688702f3 100644 --- a/packages/core/src/writers/split-mode.ts +++ b/packages/core/src/writers/split-mode.ts @@ -48,6 +48,7 @@ export async function writeSplitMode({ formData, formUrlEncoded, paramsSerializer, + paramsFilter, fetchReviver, } = generateTarget(builder, output); @@ -147,6 +148,12 @@ export async function writeSplitMode({ }); } + if (paramsFilter) { + implementationData += generateMutatorImports({ + mutators: paramsFilter, + }); + } + if (fetchReviver) { implementationData += generateMutatorImports({ mutators: fetchReviver, diff --git a/packages/core/src/writers/split-tags-mode.ts b/packages/core/src/writers/split-tags-mode.ts index be9aca93d9..8d9f176cde 100644 --- a/packages/core/src/writers/split-tags-mode.ts +++ b/packages/core/src/writers/split-tags-mode.ts @@ -69,6 +69,7 @@ export async function writeSplitTagsMode({ fetchReviver, formUrlEncoded, paramsSerializer, + paramsFilter, } = target; let implementationData = header; @@ -206,6 +207,12 @@ export async function writeSplitTagsMode({ oneMore: true, }); } + if (paramsFilter) { + implementationData += generateMutatorImports({ + mutators: paramsFilter, + oneMore: true, + }); + } if (fetchReviver) { implementationData += generateMutatorImports({ diff --git a/packages/core/src/writers/tags-mode.ts b/packages/core/src/writers/tags-mode.ts index b2c81149a1..27cbab4907 100644 --- a/packages/core/src/writers/tags-mode.ts +++ b/packages/core/src/writers/tags-mode.ts @@ -58,6 +58,7 @@ export async function writeTagsMode({ formUrlEncoded, fetchReviver, paramsSerializer, + paramsFilter, } = target; let data = header; @@ -189,6 +190,10 @@ export async function writeTagsMode({ data += generateMutatorImports({ mutators: paramsSerializer }); } + if (paramsFilter) { + data += generateMutatorImports({ mutators: paramsFilter }); + } + if (fetchReviver) { data += generateMutatorImports({ mutators: fetchReviver }); } diff --git a/samples/angular-query/__snapshots__/api/endpoints-custom-instance/pets/pets.ts b/samples/angular-query/__snapshots__/api/endpoints-custom-instance/pets/pets.ts index 69cff46e90..56f2a97af7 100644 --- a/samples/angular-query/__snapshots__/api/endpoints-custom-instance/pets/pets.ts +++ b/samples/angular-query/__snapshots__/api/endpoints-custom-instance/pets/pets.ts @@ -48,19 +48,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/__snapshots__/api/endpoints-no-transformer/pets/pets.ts b/samples/angular-query/__snapshots__/api/endpoints-no-transformer/pets/pets.ts index 9588e1bf50..a3c1590854 100644 --- a/samples/angular-query/__snapshots__/api/endpoints-no-transformer/pets/pets.ts +++ b/samples/angular-query/__snapshots__/api/endpoints-no-transformer/pets/pets.ts @@ -47,19 +47,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/__snapshots__/api/endpoints-zod/pets/pets.ts b/samples/angular-query/__snapshots__/api/endpoints-zod/pets/pets.ts index 9fb6e495f5..c16ad8e19f 100644 --- a/samples/angular-query/__snapshots__/api/endpoints-zod/pets/pets.ts +++ b/samples/angular-query/__snapshots__/api/endpoints-zod/pets/pets.ts @@ -44,19 +44,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/__snapshots__/api/endpoints/pets/pets.ts b/samples/angular-query/__snapshots__/api/endpoints/pets/pets.ts index e52335901c..8d44fbff7e 100644 --- a/samples/angular-query/__snapshots__/api/endpoints/pets/pets.ts +++ b/samples/angular-query/__snapshots__/api/endpoints/pets/pets.ts @@ -50,19 +50,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular-query/basic/endpoints.ts b/tests/__snapshots__/angular-query/basic/endpoints.ts index b8abba796c..15647fa659 100644 --- a/tests/__snapshots__/angular-query/basic/endpoints.ts +++ b/tests/__snapshots__/angular-query/basic/endpoints.ts @@ -46,19 +46,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular-query/split/endpoints.ts b/tests/__snapshots__/angular-query/split/endpoints.ts index b8abba796c..15647fa659 100644 --- a/tests/__snapshots__/angular-query/split/endpoints.ts +++ b/tests/__snapshots__/angular-query/split/endpoints.ts @@ -46,19 +46,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular-query/tags-split/pets/pets.ts b/tests/__snapshots__/angular-query/tags-split/pets/pets.ts index 15426cd0bf..5c41cf8bef 100644 --- a/tests/__snapshots__/angular-query/tags-split/pets/pets.ts +++ b/tests/__snapshots__/angular-query/tags-split/pets/pets.ts @@ -46,19 +46,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular-query/use-prefetch/endpoints.ts b/tests/__snapshots__/angular-query/use-prefetch/endpoints.ts index f1c903f3e4..9d8b7b8254 100644 --- a/tests/__snapshots__/angular-query/use-prefetch/endpoints.ts +++ b/tests/__snapshots__/angular-query/use-prefetch/endpoints.ts @@ -47,19 +47,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/http-resource-tags/pets.ts b/tests/__snapshots__/angular/http-resource-tags/pets.ts index 4822003fc5..f6f82b35ef 100644 --- a/tests/__snapshots__/angular/http-resource-tags/pets.ts +++ b/tests/__snapshots__/angular/http-resource-tags/pets.ts @@ -51,19 +51,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts b/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts index 63bc0e4b16..3c575587b8 100644 --- a/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts +++ b/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts @@ -72,19 +72,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/http-resource-zod/endpoints.ts b/tests/__snapshots__/angular/http-resource-zod/endpoints.ts index 63bc0e4b16..3c575587b8 100644 --- a/tests/__snapshots__/angular/http-resource-zod/endpoints.ts +++ b/tests/__snapshots__/angular/http-resource-zod/endpoints.ts @@ -72,19 +72,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/issue-3103/default/default.service.ts b/tests/__snapshots__/angular/issue-3103/default/default.service.ts index e70e7df995..a9c0cc2526 100644 --- a/tests/__snapshots__/angular/issue-3103/default/default.service.ts +++ b/tests/__snapshots__/angular/issue-3103/default/default.service.ts @@ -68,19 +68,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/multi-content-query-params/endpoints.ts b/tests/__snapshots__/angular/multi-content-query-params/endpoints.ts index 0bba4cf138..d67b8d4da4 100644 --- a/tests/__snapshots__/angular/multi-content-query-params/endpoints.ts +++ b/tests/__snapshots__/angular/multi-content-query-params/endpoints.ts @@ -70,19 +70,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/named-parameters/endpoints.ts b/tests/__snapshots__/angular/named-parameters/endpoints.ts index 81d84826d8..636573abb1 100644 --- a/tests/__snapshots__/angular/named-parameters/endpoints.ts +++ b/tests/__snapshots__/angular/named-parameters/endpoints.ts @@ -81,19 +81,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/petstore/endpoints.ts b/tests/__snapshots__/angular/petstore/endpoints.ts index 2462ba2187..8cdd3b782d 100644 --- a/tests/__snapshots__/angular/petstore/endpoints.ts +++ b/tests/__snapshots__/angular/petstore/endpoints.ts @@ -82,19 +82,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/split/endpoints.service.ts b/tests/__snapshots__/angular/split/endpoints.service.ts index 9aa072eb09..32b60c39e5 100644 --- a/tests/__snapshots__/angular/split/endpoints.service.ts +++ b/tests/__snapshots__/angular/split/endpoints.service.ts @@ -75,19 +75,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/tags-split/pets/pets.service.ts b/tests/__snapshots__/angular/tags-split/pets/pets.service.ts index 168df99c7e..d00b70dcce 100644 --- a/tests/__snapshots__/angular/tags-split/pets/pets.service.ts +++ b/tests/__snapshots__/angular/tags-split/pets/pets.service.ts @@ -75,19 +75,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/tags/pets.ts b/tests/__snapshots__/angular/tags/pets.ts index 8754710438..2dfd78dc0a 100644 --- a/tests/__snapshots__/angular/tags/pets.ts +++ b/tests/__snapshots__/angular/tags/pets.ts @@ -82,19 +82,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/zod-schema-response/endpoints.ts b/tests/__snapshots__/angular/zod-schema-response/endpoints.ts index 4c78f62d0a..6481d78c87 100644 --- a/tests/__snapshots__/angular/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/angular/zod-schema-response/endpoints.ts @@ -82,19 +82,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/default/issue-2998/requests/requests.service.ts b/tests/__snapshots__/default/issue-2998/requests/requests.service.ts index eb1f2a3112..1a238540ab 100644 --- a/tests/__snapshots__/default/issue-2998/requests/requests.service.ts +++ b/tests/__snapshots__/default/issue-2998/requests/requests.service.ts @@ -73,19 +73,34 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, + passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, + passthroughKeys?: undefined, ): Record; +function filterParams( + params: Record, + requiredNullableKeys: ReadonlySet | undefined, + preserveRequiredNullables: boolean | undefined, + passthroughKeys: ReadonlySet, +): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, -): Record { - const filteredParams: Record = {}; + passthroughKeys: ReadonlySet = new Set(), +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { + if (passthroughKeys.has(key)) { + if (value !== undefined) { + filteredParams[key] = value; + } + continue; + } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/mutators/params-filter.ts b/tests/mutators/params-filter.ts new file mode 100644 index 0000000000..ab6b994061 --- /dev/null +++ b/tests/mutators/params-filter.ts @@ -0,0 +1,32 @@ +/** + * Custom query-parameter filter for issue #3326 integration coverage. + * + * Replaces the built-in Angular `filterParams` helper. Flattens object-valued + * params into bracketed keys (`filters[color]=red`) and strips `undefined`, + * while leaving primitives untouched. + */ +export const flattenParamsFilter = ( + params: Record, +): Record => { + const result: Record = {}; + for (const [key, value] of Object.entries(params)) { + if (value === undefined || value === null) { + continue; + } + if (typeof value === 'object' && !Array.isArray(value)) { + for (const [innerKey, innerValue] of Object.entries( + value as Record, + )) { + if (innerValue !== undefined && innerValue !== null) { + result[`${key}[${innerKey}]`] = innerValue as + | string + | number + | boolean; + } + } + continue; + } + result[key] = value as string | number | boolean; + } + return result; +}; diff --git a/tests/specifications/issue-3326.yaml b/tests/specifications/issue-3326.yaml new file mode 100644 index 0000000000..9db208b068 --- /dev/null +++ b/tests/specifications/issue-3326.yaml @@ -0,0 +1,38 @@ +openapi: 3.0.4 +info: + title: Issue 3326 - Angular object query parameter support + version: 1.0.0 +paths: + /api/search: + get: + operationId: search + tags: + - search + parameters: + - name: q + in: query + required: false + schema: + type: string + - name: filters + in: query + required: false + schema: + type: object + additionalProperties: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/SearchResult' +components: + schemas: + SearchResult: + type: object + properties: + id: + type: integer + format: int32 From fd6b0c563ceab4645df0472406597ce8a7efcc0c Mon Sep 17 00:00:00 2001 From: The Ult Date: Sat, 16 May 2026 01:12:25 +0200 Subject: [PATCH 11/18] fix(core): Tighten Angular params passthrough Handle nullable array unions and additionalProperties maps when tracking non-primitive query params so Angular passthrough coverage matches the supported schema shapes. Preserve paramsFilter through tag-target rebuilding, and only pass raw non-primitive query params through Angular filtering when a downstream serializer can legally consume object values. Refs #3103 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/core/src/generators/options.test.ts | 42 ++++++++++++++++- packages/core/src/generators/options.ts | 14 +++--- .../core/src/getters/query-params.test.ts | 45 +++++++++++++++++++ packages/core/src/getters/query-params.ts | 10 ++++- packages/core/src/writers/target-tags.ts | 1 + 5 files changed, 103 insertions(+), 9 deletions(-) diff --git a/packages/core/src/generators/options.test.ts b/packages/core/src/generators/options.test.ts index ad32337455..971ee4e6df 100644 --- a/packages/core/src/generators/options.test.ts +++ b/packages/core/src/generators/options.test.ts @@ -419,7 +419,7 @@ describe('generateAxiosOptions', () => { // be silently dropped by `filterParams`. With nonPrimitiveQueryParamKeys // they are passed through so a downstream paramsSerializer/mutator/ // paramsFilter can handle them. - it('passes nonPrimitiveKeys through the shared filter helper', () => { + it('passes nonPrimitiveKeys through the shared filter helper when a paramsSerializer is configured', () => { const result = generateAxiosOptions({ response: minimalResponse, isExactOptionalPropertyTypes: false, @@ -430,7 +430,7 @@ describe('generateAxiosOptions', () => { hasSignal: false, isVue: false, isAngular: true, - paramsSerializer: undefined, + paramsSerializer: minimalParamsSerializer, paramsSerializerOptions: undefined, }); @@ -439,6 +439,44 @@ describe('generateAxiosOptions', () => { expect(result).toContain('new Set(["filters"])'); }); + it('keeps shared Angular HttpClient params primitive-only without a downstream serializer', () => { + const result = generateAxiosOptions({ + response: minimalResponse, + isExactOptionalPropertyTypes: false, + queryParams: minimalSchema, + nonPrimitiveQueryParamKeys: ['filters'], + headers: undefined, + requestOptions: true, + hasSignal: false, + isVue: false, + isAngular: true, + paramsSerializer: undefined, + paramsSerializerOptions: undefined, + }); + + expect(result).not.toContain('new Set(["filters"])'); + }); + + it('keeps inline Angular HttpClient params primitive-only without a downstream serializer', () => { + const result = generateAxiosOptions({ + response: minimalResponse, + isExactOptionalPropertyTypes: false, + queryParams: minimalSchema, + nonPrimitiveQueryParamKeys: ['filters'], + headers: undefined, + requestOptions: false, + hasSignal: false, + isVue: false, + isAngular: true, + paramsSerializer: undefined, + paramsSerializerOptions: undefined, + }); + + expect(result).not.toContain( + 'const passthroughKeys = new Set(["filters"])', + ); + }); + it('replaces the built-in filter when paramsFilter is configured', () => { const result = generateAxiosOptions({ response: minimalResponse, diff --git a/packages/core/src/generators/options.ts b/packages/core/src/generators/options.ts index e9fa7997b5..e42e95c1ef 100644 --- a/packages/core/src/generators/options.ts +++ b/packages/core/src/generators/options.ts @@ -172,8 +172,9 @@ export const getAngularFilteredParamsCallExpression = ( * mutator, the built-in `filterParams` is bypassed entirely and the user's * function is called with the raw params — they own nullish-stripping and * any object/array handling. Otherwise the built-in filter is used (either - * the shared helper or an inline IIFE), and `nonPrimitiveKeys` keeps schema- - * declared object/array-of-object params from being silently dropped. + * the shared helper or an inline IIFE), and callers should only pass + * `nonPrimitiveKeys` when a downstream serializer or custom consumer can + * legally handle raw object/array values. */ export const buildAngularParamsFilterExpression = ({ paramsExpression, @@ -275,6 +276,9 @@ export function generateAxiosOptions({ paramsFilter, }: GenerateAxiosOptions) { const isRequestOptions = requestOptions !== false; + const angularPassthroughQueryParamKeys = paramsSerializer + ? nonPrimitiveQueryParamKeys + : []; // Use querySignal if API has a param named "signal" to avoid conflict const signalVar = hasSignalParam ? 'querySignal' : 'signal'; const signalProp = hasSignalParam ? `signal: ${signalVar}` : 'signal'; @@ -312,7 +316,7 @@ export function generateAxiosOptions({ paramsExpression: 'params ?? {}', requiredNullableParamKeys: requiredNullableQueryParamKeys, preserveRequiredNullables: !!paramsSerializer, - nonPrimitiveKeys: nonPrimitiveQueryParamKeys, + nonPrimitiveKeys: angularPassthroughQueryParamKeys, paramsFilter, useSharedHelper: false, }); @@ -368,7 +372,7 @@ export function generateAxiosOptions({ paramsExpression: '{...params, ...options?.params}', requiredNullableParamKeys: requiredNullableQueryParamKeys, preserveRequiredNullables: true, - nonPrimitiveKeys: nonPrimitiveQueryParamKeys, + nonPrimitiveKeys: angularPassthroughQueryParamKeys, paramsFilter, useSharedHelper: true, }); @@ -377,7 +381,7 @@ export function generateAxiosOptions({ const callExpr = buildAngularParamsFilterExpression({ paramsExpression: '{...params, ...options?.params}', requiredNullableParamKeys: requiredNullableQueryParamKeys, - nonPrimitiveKeys: nonPrimitiveQueryParamKeys, + nonPrimitiveKeys: angularPassthroughQueryParamKeys, paramsFilter, useSharedHelper: true, }); diff --git a/packages/core/src/getters/query-params.test.ts b/packages/core/src/getters/query-params.test.ts index f9375213c3..34c71c87bc 100644 --- a/packages/core/src/getters/query-params.test.ts +++ b/packages/core/src/getters/query-params.test.ts @@ -320,6 +320,29 @@ describe('getQueryParams getter', () => { expect(result?.nonPrimitiveKeys).toEqual(['items']); }); + it('flags nullable arrays of objects', () => { + const result = getQueryParams({ + queryParams: [ + { + parameter: { + name: 'items', + in: 'query', + required: false, + schema: { + type: ['array', 'null'], + items: { type: 'object' }, + }, + }, + imports: [], + }, + ], + operationName: '', + context, + }); + + expect(result?.nonPrimitiveKeys).toEqual(['items']); + }); + it('flags object via oneOf composition', () => { const result = getQueryParams({ queryParams: [ @@ -342,6 +365,28 @@ describe('getQueryParams getter', () => { expect(result?.nonPrimitiveKeys).toEqual(['either']); }); + it('flags type-less schemas with additionalProperties', () => { + const result = getQueryParams({ + queryParams: [ + { + parameter: { + name: 'filters', + in: 'query', + required: false, + schema: { + additionalProperties: { type: 'string' }, + }, + }, + imports: [], + }, + ], + operationName: '', + context, + }); + + expect(result?.nonPrimitiveKeys).toEqual(['filters']); + }); + it('omits the field when all params are primitive', () => { const result = getQueryParams({ queryParams: [ diff --git a/packages/core/src/getters/query-params.ts b/packages/core/src/getters/query-params.ts index 26d857d262..c61d5510b4 100644 --- a/packages/core/src/getters/query-params.ts +++ b/packages/core/src/getters/query-params.ts @@ -65,11 +65,13 @@ const isSchemaNonPrimitive = (schema: OpenApiSchemaObject): boolean => { const type = Array.isArray(schemaType) ? schemaType.filter((variant) => variant !== 'null') : schemaType; + const additionalProperties = (schema as { additionalProperties?: unknown }) + .additionalProperties; if (type === 'object') { return true; } - if (type === 'array') { + if (type === 'array' || (Array.isArray(type) && type.includes('array'))) { const items = (schema as { items?: unknown }).items; if (isOpenApiSchemaObject(items)) { return isSchemaNonPrimitive(items); @@ -92,7 +94,11 @@ const isSchemaNonPrimitive = (schema: OpenApiSchemaObject): boolean => { ); } - if (!type && (schema as { properties?: unknown }).properties !== undefined) { + if ( + !type && + ((schema as { properties?: unknown }).properties !== undefined || + (additionalProperties !== undefined && additionalProperties !== false)) + ) { return true; } diff --git a/packages/core/src/writers/target-tags.ts b/packages/core/src/writers/target-tags.ts index 798e507e80..e1eb3de6d3 100644 --- a/packages/core/src/writers/target-tags.ts +++ b/packages/core/src/writers/target-tags.ts @@ -188,6 +188,7 @@ export function generateTargetForTags( formData: target.formData, formUrlEncoded: target.formUrlEncoded, paramsSerializer: target.paramsSerializer, + paramsFilter: target.paramsFilter, fetchReviver: target.fetchReviver, }; } From dc0da37d3dc7cdd24846895734b51cfe41d91d9e Mon Sep 17 00:00:00 2001 From: The Ult Date: Sat, 16 May 2026 14:05:00 +0200 Subject: [PATCH 12/18] fix(angular): trim 3326 spillover from 3103 Keep the 3103 default-tag regression fix separate from the later 3326 passthrough work. Restore the Angular generator and tests to the 3103-only shape. Remove the 3326 fixtures, snapshots, and extra core passthrough plumbing. Refs #3103 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/angular/src/http-client.test.ts | 170 ---------------- packages/angular/src/http-client.ts | 48 +++-- packages/angular/src/http-resource.test.ts | 4 +- packages/angular/src/http-resource.ts | 44 ++--- packages/core/src/generators/options.test.ts | 117 ----------- packages/core/src/generators/options.ts | 154 ++------------- packages/core/src/generators/verbs-options.ts | 12 -- .../core/src/getters/query-params.test.ts | 185 +----------------- packages/core/src/getters/query-params.ts | 78 -------- packages/core/src/writers/single-mode.ts | 5 - packages/core/src/writers/split-mode.ts | 7 - packages/core/src/writers/split-tags-mode.ts | 7 - packages/core/src/writers/tags-mode.ts | 5 - packages/core/src/writers/target-tags.ts | 1 - packages/core/src/writers/target.ts | 4 - packages/orval/src/utils/options.ts | 10 - .../api/endpoints-zod/pets/pets.service.ts | 19 +- .../api/http-both/pets/pets.resource.ts | 19 +- .../api/http-both/pets/pets.service.ts | 19 +- .../pets/pets.service.ts | 19 +- .../api/http-client/pets/pets.service.ts | 19 +- .../http-resource-zod/pets/pets.service.ts | 19 +- .../api/http-resource/pets/pets.service.ts | 19 +- .../api/endpoints-zod/pets/pets.service.ts | 19 +- .../src/api/http-both/pets/pets.resource.ts | 19 +- .../src/api/http-both/pets/pets.service.ts | 19 +- .../pets/pets.service.ts | 19 +- .../src/api/http-client/pets/pets.service.ts | 19 +- .../http-resource-zod/pets/pets.service.ts | 19 +- .../api/http-resource/pets/pets.service.ts | 19 +- .../endpoints-custom-instance/pets/pets.ts | 19 +- .../api/endpoints-no-transformer/pets/pets.ts | 19 +- .../api/endpoints-zod/pets/pets.ts | 19 +- .../__snapshots__/api/endpoints/pets/pets.ts | 19 +- .../endpoints-custom-instance/pets/pets.ts | 19 +- .../api/endpoints-no-transformer/pets/pets.ts | 19 +- .../src/api/endpoints-zod/pets/pets.ts | 19 +- .../src/api/endpoints/pets/pets.ts | 19 +- .../angular-query/basic/endpoints.ts | 19 +- .../angular-query/split/endpoints.ts | 19 +- .../angular-query/tags-split/pets/pets.ts | 19 +- .../angular-query/use-prefetch/endpoints.ts | 19 +- .../angular/http-resource-tags/pets.ts | 19 +- .../http-resource-zod-disabled/endpoints.ts | 19 +- .../angular/http-resource-zod/endpoints.ts | 19 +- .../issue-3103/default/default.service.ts | 19 +- .../multi-content-query-params/endpoints.ts | 19 +- .../angular/named-parameters/endpoints.ts | 19 +- .../angular/petstore/endpoints.ts | 19 +- .../angular/split/endpoints.service.ts | 19 +- .../angular/tags-split/pets/pets.service.ts | 19 +- tests/__snapshots__/angular/tags/pets.ts | 19 +- .../angular/zod-schema-response/endpoints.ts | 19 +- .../issue-2998/requests/requests.service.ts | 19 +- tests/mutators/params-filter.ts | 32 --- tests/specifications/issue-3326.yaml | 38 ---- 56 files changed, 134 insertions(+), 1509 deletions(-) delete mode 100644 tests/mutators/params-filter.ts delete mode 100644 tests/specifications/issue-3326.yaml diff --git a/packages/angular/src/http-client.test.ts b/packages/angular/src/http-client.test.ts index 1c2b872d78..1384dbd3b2 100644 --- a/packages/angular/src/http-client.test.ts +++ b/packages/angular/src/http-client.test.ts @@ -470,88 +470,6 @@ describe('angular HttpClient generator', () => { expect(header).not.toContain('function filterParams('); }); - - // Issue #3326: a user-supplied `paramsFilter` mutator owns the filter - // logic entirely, so the shared built-in helper would be dead code if - // every operation overrides it. - it('suppresses the shared filterParams helper when every operation has paramsFilter', () => { - const verbOptionWithCustomFilter = createVerbOption({ - queryParams: { - schema: { name: 'GetPetByIdParams', model: '', imports: [] }, - deps: [], - isOptional: true, - originalSchema: {} as never, - requiredNullableKeys: [], - }, - paramsFilter: { - name: 'myFilter', - path: './my-filter', - default: false, - hasErrorType: false, - errorTypeName: '', - hasSecondArg: false, - hasThirdArg: false, - isHook: false, - }, - }); - - const header = generateAngularHeader({ - title: 'PetService', - isRequestOptions: true, - isMutator: false, - isGlobalMutator: false, - provideIn: 'root', - hasAwaitedType: false, - verbOptions: { getPetById: verbOptionWithCustomFilter }, - } as never); - - expect(header).not.toContain('function filterParams('); - }); - - it('still emits the shared helper when at least one operation lacks paramsFilter', () => { - const verbWithFilter = createVerbOption({ - operationName: 'a', - queryParams: { - schema: { name: 'AParams', model: '', imports: [] }, - deps: [], - isOptional: true, - originalSchema: {} as never, - requiredNullableKeys: [], - }, - paramsFilter: { - name: 'myFilter', - path: './my-filter', - default: false, - hasErrorType: false, - errorTypeName: '', - hasSecondArg: false, - hasThirdArg: false, - isHook: false, - }, - }); - const verbWithoutFilter = createVerbOption({ - operationName: 'b', - queryParams: { - schema: { name: 'BParams', model: '', imports: [] }, - deps: [], - isOptional: true, - originalSchema: {} as never, - requiredNullableKeys: [], - }, - }); - - const header = generateAngularHeader({ - title: 'PetService', - isRequestOptions: true, - isMutator: false, - isGlobalMutator: false, - provideIn: 'root', - hasAwaitedType: false, - verbOptions: { a: verbWithFilter, b: verbWithoutFilter }, - } as never); - - expect(header).toContain('function filterParams('); - }); }); // ── Footer ──────────────────────────────────────────────────────────── @@ -604,94 +522,6 @@ describe('angular HttpClient generator', () => { // ── Implementation — GET ────────────────────────────────────────────── - // ── paramsFilter + nonPrimitiveKeys (issue #3326) ───────────────────── - - describe('query parameter filtering (#3326)', () => { - const customFilter = { - name: 'myFilter', - path: './my-filter', - default: false, - hasErrorType: false, - errorTypeName: '', - hasSecondArg: false, - hasThirdArg: false, - isHook: false, - }; - - it('preserves nonPrimitiveKeys through the built-in filter', () => { - const verbOption = createVerbOption({ - queryParams: { - schema: { name: 'GetPetByIdParams', model: '', imports: [] }, - deps: [], - isOptional: true, - originalSchema: {} as never, - requiredNullableKeys: [], - nonPrimitiveKeys: ['filters'], - }, - }); - const options = createGeneratorOptions(); - - const impl = generateHttpClientImplementation(verbOption, options); - - // The shared `filterParams` is invoked with the passthrough set so - // `filters` survives. - expect(impl).toContain('new Set(["filters"])'); - }); - - it('replaces the built-in filter with the user-supplied paramsFilter', () => { - const verbOption = createVerbOption({ - queryParams: { - schema: { name: 'GetPetByIdParams', model: '', imports: [] }, - deps: [], - isOptional: true, - originalSchema: {} as never, - requiredNullableKeys: [], - }, - paramsFilter: customFilter, - }); - const options = createGeneratorOptions(); - - const impl = generateHttpClientImplementation(verbOption, options); - - // Filtered params come from `myFilter(...)`; the built-in helper is - // not called for this operation. - expect(impl).toContain( - 'const filteredParams = myFilter({...params, ...options?.params})', - ); - expect(impl).not.toContain('filterParams({...params'); - }); - - it('wraps a configured paramsSerializer around the custom paramsFilter', () => { - const verbOption = createVerbOption({ - queryParams: { - schema: { name: 'GetPetByIdParams', model: '', imports: [] }, - deps: [], - isOptional: true, - originalSchema: {} as never, - requiredNullableKeys: [], - }, - paramsFilter: customFilter, - paramsSerializer: { - name: 'mySerializer', - path: './my-serializer', - default: false, - hasErrorType: false, - errorTypeName: '', - hasSecondArg: false, - hasThirdArg: false, - isHook: false, - }, - }); - const options = createGeneratorOptions(); - - const impl = generateHttpClientImplementation(verbOption, options); - - expect(impl).toContain( - 'const filteredParams = mySerializer(myFilter({...params, ...options?.params}))', - ); - }); - }); - describe('generateHttpClientImplementation', () => { it('generates a GET method with typed return', () => { const verbOption = createVerbOption(); diff --git a/packages/angular/src/http-client.ts b/packages/angular/src/http-client.ts index e440f312eb..b86ad44eab 100644 --- a/packages/angular/src/http-client.ts +++ b/packages/angular/src/http-client.ts @@ -1,5 +1,4 @@ import { - buildAngularParamsFilterExpression, type ClientBuilder, type ClientDependenciesBuilder, type ClientFooterBuilder, @@ -12,6 +11,8 @@ import { generateOptions, generateVerbImports, type GeneratorVerbOptions, + getAngularFilteredParamsCallExpression, + getAngularFilteredParamsExpression, getAngularFilteredParamsHelperBody, getDefaultContentType, getEnumImplementation, @@ -235,12 +236,7 @@ export const generateAngularHeader: ClientHeaderBuilder = ({ tag, isDefaultTagBucket, ); - // Only emit the shared `filterParams` helper when at least one operation in - // this file will actually call it. If every operation with queryParams has - // its own `paramsFilter` mutator, the helper would be dead code. - const hasBuiltInFilteredQueryParams = relevantVerbs.some( - (v) => v.queryParams && !v.paramsFilter, - ); + const hasQueryParams = relevantVerbs.some((v) => v.queryParams); const acceptHelpers = buildAcceptHelpers(relevantVerbs, output); return ` @@ -250,7 +246,7 @@ ${ ${HTTP_CLIENT_OBSERVE_OPTIONS_TEMPLATE} -${hasBuiltInFilteredQueryParams ? getAngularFilteredParamsHelperBody() : ''}` +${hasQueryParams ? getAngularFilteredParamsHelperBody() : ''}` : '' } @@ -319,7 +315,6 @@ export const generateHttpClientImplementation = ( formData, formUrlEncoded, paramsSerializer, - paramsFilter, }: GeneratorVerbOptions, { route, context }: HttpClientGeneratorContext, ) => { @@ -415,7 +410,6 @@ export const generateHttpClientImplementation = ( hasSignal: false, isExactOptionalPropertyTypes, isAngular: true, - paramsFilter, }); const requestOptions = isRequestOptions @@ -458,7 +452,6 @@ export const generateHttpClientImplementation = ( isFormUrlEncoded, paramsSerializer, paramsSerializerOptions: override.paramsSerializerOptions, - paramsFilter, isAngular: true, isExactOptionalPropertyTypes, hasSignal: false, @@ -478,21 +471,24 @@ export const generateHttpClientImplementation = ( let paramsDeclaration = ''; if (angularParamsRef && queryParams) { - const filterExpr = buildAngularParamsFilterExpression({ - paramsExpression: isRequestOptions - ? '{...params, ...options?.params}' - : 'params ?? {}', - requiredNullableParamKeys: queryParams.requiredNullableKeys ?? [], - preserveRequiredNullables: !isRequestOptions && !!paramsSerializer, - nonPrimitiveKeys: queryParams.nonPrimitiveKeys ?? [], - paramsFilter, - // Request-options path uses the shared `filterParams` helper emitted in - // the file header; the non-request-options path inlines an IIFE. - useSharedHelper: isRequestOptions, - }); - paramsDeclaration = paramsSerializer - ? `const ${angularParamsRef} = ${paramsSerializer.name}(${filterExpr});\n\n ` - : `const ${angularParamsRef} = ${filterExpr};\n\n `; + if (isRequestOptions) { + const callExpr = getAngularFilteredParamsCallExpression( + '{...params, ...options?.params}', + queryParams.requiredNullableKeys ?? [], + ); + paramsDeclaration = paramsSerializer + ? `const ${angularParamsRef} = ${paramsSerializer.name}(${callExpr});\n\n ` + : `const ${angularParamsRef} = ${callExpr};\n\n `; + } else { + const iifeExpr = getAngularFilteredParamsExpression( + 'params ?? {}', + queryParams.requiredNullableKeys ?? [], + !!paramsSerializer, + ); + paramsDeclaration = paramsSerializer + ? `const ${angularParamsRef} = ${paramsSerializer.name}(${iifeExpr});\n\n ` + : `const ${angularParamsRef} = ${iifeExpr};\n\n `; + } } const optionsInput = { diff --git a/packages/angular/src/http-resource.test.ts b/packages/angular/src/http-resource.test.ts index d4411f9339..f0ceb88613 100644 --- a/packages/angular/src/http-resource.test.ts +++ b/packages/angular/src/http-resource.test.ts @@ -875,9 +875,7 @@ describe('angular httpResource generator', () => { } as never); expect(header.match(/type AngularHttpParamValue =/g)).toHaveLength(1); - expect(header.match(/preserveRequiredNullables = false,/g)).toHaveLength( - 1, - ); + expect(header.match(/function filterParams\(/g)).toHaveLength(3); }); }); diff --git a/packages/angular/src/http-resource.ts b/packages/angular/src/http-resource.ts index d70f7eb5d9..639b32f40b 100644 --- a/packages/angular/src/http-resource.ts +++ b/packages/angular/src/http-resource.ts @@ -1,5 +1,4 @@ import { - buildAngularParamsFilterExpression, type ClientBuilder, type ClientDependenciesBuilder, type ClientExtraFilesBuilder, @@ -14,6 +13,7 @@ import { type GeneratorDependency, type GeneratorImport, type GeneratorVerbOptions, + getAngularFilteredParamsCallExpression, getAngularFilteredParamsHelperBody, getFileInfo, getFullRoute, @@ -447,7 +447,6 @@ const buildResourceRequest = ( headers, queryParams, paramsSerializer, - paramsFilter, override, formData, formUrlEncoded, @@ -482,14 +481,11 @@ const buildResourceRequest = ( const paramsAccess = queryParams ? 'params?.()' : undefined; const headersAccess = headers ? 'headers?.()' : undefined; const filteredParamsValue = paramsAccess - ? buildAngularParamsFilterExpression({ - paramsExpression: `${paramsAccess} ?? {}`, - requiredNullableParamKeys: queryParams?.requiredNullableKeys ?? [], - preserveRequiredNullables: !!paramsSerializer, - nonPrimitiveKeys: queryParams?.nonPrimitiveKeys ?? [], - paramsFilter, - useSharedHelper: true, - }) + ? getAngularFilteredParamsCallExpression( + `${paramsAccess} ?? {}`, + queryParams?.requiredNullableKeys ?? [], + !!paramsSerializer, + ) : undefined; const paramsValue = paramsAccess ? paramsSerializer @@ -1235,13 +1231,10 @@ export const generateHttpResourceHeader: ClientHeaderBuilder = ({ getClientOverride(verbOption), ), ); - // Emit the shared `filterParams` helper only when at least one retrieval - // with query params lacks its own `paramsFilter` mutator — otherwise the - // helper would be dead code. - const hasBuiltInFilteredQueryParams = retrievals.some( - (verbOption) => !!verbOption.queryParams && !verbOption.paramsFilter, + const hasResourceQueryParams = retrievals.some( + (verbOption) => !!verbOption.queryParams, ); - const filterParamsHelper = hasBuiltInFilteredQueryParams + const filterParamsHelper = hasResourceQueryParams ? `\n${getAngularFilteredParamsHelperBody()}\n` : ''; const resources = retrievals @@ -1268,11 +1261,8 @@ export const generateHttpResourceHeader: ClientHeaderBuilder = ({ [...retrievals, ...mutations], output, ); - // Mutations need the built-in helper only when at least one mutation lacks - // its own `paramsFilter`. If the resource section already emits the helper - // for retrievals, we suppress the mutation-side emission to avoid duplication. - const hasMutationBuiltInFilteredQueryParams = mutations.some( - (verbOption) => !!verbOption.queryParams && !verbOption.paramsFilter, + const hasMutationQueryParams = mutations.some( + (verbOption) => !!verbOption.queryParams, ); const mutationImplementation = mutations @@ -1298,8 +1288,7 @@ ${buildServiceClassOpen({ isMutator, isGlobalMutator, provideIn, - hasQueryParams: - hasMutationBuiltInFilteredQueryParams && !hasBuiltInFilteredQueryParams, + hasQueryParams: hasMutationQueryParams && !hasResourceQueryParams, })} ${mutationImplementation} }; @@ -1364,13 +1353,10 @@ const buildHttpResourceFile = ( ), ); - // Emit the shared `filterParams` helper only when at least one retrieval - // with query params lacks its own `paramsFilter` mutator — otherwise the - // helper would be dead code. - const hasBuiltInFilteredQueryParams = retrievals.some( - (verbOption) => !!verbOption.queryParams && !verbOption.paramsFilter, + const hasResourceQueryParams = retrievals.some( + (verbOption) => !!verbOption.queryParams, ); - const filterParamsHelper = hasBuiltInFilteredQueryParams + const filterParamsHelper = hasResourceQueryParams ? `\n${getAngularFilteredParamsHelperBody()}\n` : ''; diff --git a/packages/core/src/generators/options.test.ts b/packages/core/src/generators/options.test.ts index 971ee4e6df..e66c6c8463 100644 --- a/packages/core/src/generators/options.test.ts +++ b/packages/core/src/generators/options.test.ts @@ -50,17 +50,6 @@ const minimalParamsSerializer: GeneratorMutator = { isHook: false, }; -const minimalParamsFilter: GeneratorMutator = { - name: 'paramsFilterMutator', - path: './paramsFilterMutator', - default: false, - hasErrorType: false, - errorTypeName: '', - hasSecondArg: false, - hasThirdArg: false, - isHook: false, -}; - const buildScalarValue = ( overrides: Partial, ): ResReqTypesValue => ({ @@ -414,112 +403,6 @@ describe('generateAxiosOptions', () => { ); expect(result).not.toContain('false &&'); }); - - // Issue #3326: schema-declared object/array-of-object query params used to - // be silently dropped by `filterParams`. With nonPrimitiveQueryParamKeys - // they are passed through so a downstream paramsSerializer/mutator/ - // paramsFilter can handle them. - it('passes nonPrimitiveKeys through the shared filter helper when a paramsSerializer is configured', () => { - const result = generateAxiosOptions({ - response: minimalResponse, - isExactOptionalPropertyTypes: false, - queryParams: minimalSchema, - nonPrimitiveQueryParamKeys: ['filters'], - headers: undefined, - requestOptions: true, - hasSignal: false, - isVue: false, - isAngular: true, - paramsSerializer: minimalParamsSerializer, - paramsSerializerOptions: undefined, - }); - - // The shared helper is invoked with the passthrough set as the fourth - // argument so `filters` survives filtering. - expect(result).toContain('new Set(["filters"])'); - }); - - it('keeps shared Angular HttpClient params primitive-only without a downstream serializer', () => { - const result = generateAxiosOptions({ - response: minimalResponse, - isExactOptionalPropertyTypes: false, - queryParams: minimalSchema, - nonPrimitiveQueryParamKeys: ['filters'], - headers: undefined, - requestOptions: true, - hasSignal: false, - isVue: false, - isAngular: true, - paramsSerializer: undefined, - paramsSerializerOptions: undefined, - }); - - expect(result).not.toContain('new Set(["filters"])'); - }); - - it('keeps inline Angular HttpClient params primitive-only without a downstream serializer', () => { - const result = generateAxiosOptions({ - response: minimalResponse, - isExactOptionalPropertyTypes: false, - queryParams: minimalSchema, - nonPrimitiveQueryParamKeys: ['filters'], - headers: undefined, - requestOptions: false, - hasSignal: false, - isVue: false, - isAngular: true, - paramsSerializer: undefined, - paramsSerializerOptions: undefined, - }); - - expect(result).not.toContain( - 'const passthroughKeys = new Set(["filters"])', - ); - }); - - it('replaces the built-in filter when paramsFilter is configured', () => { - const result = generateAxiosOptions({ - response: minimalResponse, - isExactOptionalPropertyTypes: false, - queryParams: minimalSchema, - headers: undefined, - requestOptions: true, - hasSignal: false, - isVue: false, - isAngular: true, - paramsSerializer: undefined, - paramsSerializerOptions: undefined, - paramsFilter: minimalParamsFilter, - }); - - // The user's paramsFilter is the sole filter — `filterParams(...)` is - // not emitted alongside it. - expect(result).toContain( - 'params: paramsFilterMutator({...params, ...options?.params})', - ); - expect(result).not.toContain('filterParams('); - }); - - it('composes paramsSerializer around paramsFilter when both are set', () => { - const result = generateAxiosOptions({ - response: minimalResponse, - isExactOptionalPropertyTypes: false, - queryParams: minimalSchema, - headers: undefined, - requestOptions: true, - hasSignal: false, - isVue: false, - isAngular: true, - paramsSerializer: minimalParamsSerializer, - paramsSerializerOptions: undefined, - paramsFilter: minimalParamsFilter, - }); - - expect(result).toContain( - 'params: paramsSerializerMutator(paramsFilterMutator({...params, ...options?.params}))', - ); - expect(result).not.toContain('filterParams('); - }); }); }); diff --git a/packages/core/src/generators/options.ts b/packages/core/src/generators/options.ts index e42e95c1ef..d0f7552352 100644 --- a/packages/core/src/generators/options.ts +++ b/packages/core/src/generators/options.ts @@ -27,21 +27,8 @@ export const getAngularFilteredParamsExpression = ( paramsExpression: string, requiredNullableParamKeys: string[] = [], preserveRequiredNullables = false, - nonPrimitiveKeys: string[] = [], ): string => { - const hasPassthrough = nonPrimitiveKeys.length > 0; - const filteredParamValueType = hasPassthrough - ? 'unknown' - : `string | number | boolean${preserveRequiredNullables ? ' | null' : ''} | Array`; - const passthroughBranch = hasPassthrough - ? ` if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } -` - : ''; + const filteredParamValueType = `string | number | boolean${preserveRequiredNullables ? ' | null' : ''} | Array`; const preserveNullableBranch = preserveRequiredNullables ? ` } else if (value === null && requiredNullableParamKeys.has(key)) { filteredParams[key] = null; @@ -56,15 +43,12 @@ export const getAngularFilteredParamsExpression = ( filteredParams[key] = value; } `; - const passthroughDecl = hasPassthrough - ? ` const passthroughKeys = new Set(${JSON.stringify(nonPrimitiveKeys)});\n` - : ''; return `(() => { -${passthroughDecl} const requiredNullableParamKeys = new Set(${JSON.stringify(requiredNullableParamKeys)}); + const requiredNullableParamKeys = new Set(${JSON.stringify(requiredNullableParamKeys)}); const filteredParams: Record = {}; for (const [key, value] of Object.entries(${paramsExpression})) { -${passthroughBranch} if (Array.isArray(value)) { + if (Array.isArray(value)) { const filtered = value.filter( (item) => item != null && @@ -93,34 +77,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => @@ -157,58 +126,8 @@ export const getAngularFilteredParamsCallExpression = ( paramsExpression: string, requiredNullableParamKeys: string[] = [], preserveRequiredNullables = false, - nonPrimitiveKeys: string[] = [], -): string => { - const baseArgs = `${paramsExpression}, new Set(${JSON.stringify(requiredNullableParamKeys)})`; - if (nonPrimitiveKeys.length > 0) { - return `filterParams(${baseArgs}, ${preserveRequiredNullables}, new Set(${JSON.stringify(nonPrimitiveKeys)}))`; - } - return `filterParams(${baseArgs}${preserveRequiredNullables ? ', true' : ''})`; -}; - -/** - * Returns the filter call/IIFE used to massage query params before passing - * them to Angular's HttpParams. When the user supplied a `paramsFilter` - * mutator, the built-in `filterParams` is bypassed entirely and the user's - * function is called with the raw params — they own nullish-stripping and - * any object/array handling. Otherwise the built-in filter is used (either - * the shared helper or an inline IIFE), and callers should only pass - * `nonPrimitiveKeys` when a downstream serializer or custom consumer can - * legally handle raw object/array values. - */ -export const buildAngularParamsFilterExpression = ({ - paramsExpression, - requiredNullableParamKeys = [], - preserveRequiredNullables = false, - nonPrimitiveKeys = [], - paramsFilter, - useSharedHelper, -}: { - paramsExpression: string; - requiredNullableParamKeys?: string[]; - preserveRequiredNullables?: boolean; - nonPrimitiveKeys?: string[]; - paramsFilter?: GeneratorMutator; - useSharedHelper: boolean; -}): string => { - if (paramsFilter) { - return `${paramsFilter.name}(${paramsExpression})`; - } - if (useSharedHelper) { - return getAngularFilteredParamsCallExpression( - paramsExpression, - requiredNullableParamKeys, - preserveRequiredNullables, - nonPrimitiveKeys, - ); - } - return getAngularFilteredParamsExpression( - paramsExpression, - requiredNullableParamKeys, - preserveRequiredNullables, - nonPrimitiveKeys, - ); -}; +): string => + `filterParams(${paramsExpression}, new Set(${JSON.stringify(requiredNullableParamKeys)})${preserveRequiredNullables ? ', true' : ''})`; interface GenerateFormDataAndUrlEncodedFunctionOptions { body: GetterBody; @@ -244,7 +163,6 @@ interface GenerateAxiosOptions { angularObserve?: 'body' | 'events' | 'response'; angularParamsRef?: string; requiredNullableQueryParamKeys?: string[]; - nonPrimitiveQueryParamKeys?: string[]; queryParams?: GeneratorSchema; headers?: GeneratorSchema; requestOptions?: object | boolean; @@ -254,7 +172,6 @@ interface GenerateAxiosOptions { isAngular: boolean; paramsSerializer?: GeneratorMutator; paramsSerializerOptions?: ParamsSerializerOptions; - paramsFilter?: GeneratorMutator; } export function generateAxiosOptions({ @@ -263,7 +180,6 @@ export function generateAxiosOptions({ angularObserve, angularParamsRef, requiredNullableQueryParamKeys, - nonPrimitiveQueryParamKeys, queryParams, headers, requestOptions, @@ -273,12 +189,8 @@ export function generateAxiosOptions({ isAngular, paramsSerializer, paramsSerializerOptions, - paramsFilter, }: GenerateAxiosOptions) { const isRequestOptions = requestOptions !== false; - const angularPassthroughQueryParamKeys = paramsSerializer - ? nonPrimitiveQueryParamKeys - : []; // Use querySignal if API has a param named "signal" to avoid conflict const signalVar = hasSignalParam ? 'querySignal' : 'signal'; const signalProp = hasSignalParam ? `signal: ${signalVar}` : 'signal'; @@ -312,14 +224,11 @@ export function generateAxiosOptions({ if (!isRequestOptions) { if (queryParams) { if (isAngular) { - const iifeExpr = buildAngularParamsFilterExpression({ - paramsExpression: 'params ?? {}', - requiredNullableParamKeys: requiredNullableQueryParamKeys, - preserveRequiredNullables: !!paramsSerializer, - nonPrimitiveKeys: angularPassthroughQueryParamKeys, - paramsFilter, - useSharedHelper: false, - }); + const iifeExpr = getAngularFilteredParamsExpression( + 'params ?? {}', + requiredNullableQueryParamKeys, + !!paramsSerializer, + ); value += paramsSerializer ? `\n params: ${paramsSerializer.name}(${iifeExpr}),` : `\n params: ${iifeExpr},`; @@ -368,24 +277,14 @@ export function generateAxiosOptions({ } else if (isAngular && angularParamsRef) { value += `\n params: ${angularParamsRef},`; } else if (isAngular && paramsSerializer) { - const callExpr = buildAngularParamsFilterExpression({ - paramsExpression: '{...params, ...options?.params}', - requiredNullableParamKeys: requiredNullableQueryParamKeys, - preserveRequiredNullables: true, - nonPrimitiveKeys: angularPassthroughQueryParamKeys, - paramsFilter, - useSharedHelper: true, - }); + const callExpr = getAngularFilteredParamsCallExpression( + '{...params, ...options?.params}', + requiredNullableQueryParamKeys, + true, + ); value += `\n params: ${paramsSerializer.name}(${callExpr}),`; } else if (isAngular) { - const callExpr = buildAngularParamsFilterExpression({ - paramsExpression: '{...params, ...options?.params}', - requiredNullableParamKeys: requiredNullableQueryParamKeys, - nonPrimitiveKeys: angularPassthroughQueryParamKeys, - paramsFilter, - useSharedHelper: true, - }); - value += `\n params: ${callExpr},`; + value += `\n params: ${getAngularFilteredParamsCallExpression('{...params, ...options?.params}', requiredNullableQueryParamKeys)},`; } else { value += '\n params: {...params, ...options?.params},'; } @@ -431,7 +330,6 @@ interface GenerateOptionsOptions { isVue?: boolean; paramsSerializer?: GeneratorMutator; paramsSerializerOptions?: ParamsSerializerOptions; - paramsFilter?: GeneratorMutator; } export function generateOptions({ @@ -453,7 +351,6 @@ export function generateOptions({ isVue, paramsSerializer, paramsSerializerOptions, - paramsFilter, }: GenerateOptionsOptions) { const bodyIdentifier = getIsBodyVerb(verb) ? generateBodyOptions(body, isFormData, isFormUrlEncoded) @@ -464,7 +361,6 @@ export function generateOptions({ angularObserve, angularParamsRef, requiredNullableQueryParamKeys: queryParams?.requiredNullableKeys, - nonPrimitiveQueryParamKeys: queryParams?.nonPrimitiveKeys, queryParams: queryParams?.schema, headers: headers?.schema, requestOptions, @@ -475,7 +371,6 @@ export function generateOptions({ isAngular: isAngular ?? false, paramsSerializer, paramsSerializerOptions, - paramsFilter, }); const trimmedAxiosOptions = axiosOptions.trim(); @@ -538,7 +433,6 @@ export function generateQueryParamsAxiosConfig( isAngular: boolean, requiredNullableQueryParamKeys?: string[], queryParams?: GetterQueryParam, - paramsFilter?: GeneratorMutator, ) { if (!queryParams && !response.isBlob) { return ''; @@ -550,14 +444,7 @@ export function generateQueryParamsAxiosConfig( if (isVue) { value += ',\n params: unref(params)'; } else if (isAngular) { - const paramsExpr = buildAngularParamsFilterExpression({ - paramsExpression: 'params ?? {}', - requiredNullableParamKeys: requiredNullableQueryParamKeys, - nonPrimitiveKeys: queryParams.nonPrimitiveKeys, - paramsFilter, - useSharedHelper: false, - }); - value += `,\n params: ${paramsExpr}`; + value += `,\n params: ${getAngularFilteredParamsExpression('params ?? {}', requiredNullableQueryParamKeys)}`; } else { value += ',\n params'; } @@ -584,7 +471,6 @@ interface GenerateMutatorConfigOptions { isExactOptionalPropertyTypes: boolean; isVue?: boolean; isAngular?: boolean; - paramsFilter?: GeneratorMutator; } export function generateMutatorConfig({ @@ -601,7 +487,6 @@ export function generateMutatorConfig({ isExactOptionalPropertyTypes, isVue, isAngular, - paramsFilter, }: GenerateMutatorConfigOptions) { const bodyOptions = getIsBodyVerb(verb) ? generateBodyMutatorConfig(body, isFormData, isFormUrlEncoded) @@ -613,7 +498,6 @@ export function generateMutatorConfig({ isAngular ?? false, queryParams?.requiredNullableKeys, queryParams, - paramsFilter, ); const ignoreContentTypes = isAngular ? ['multipart/form-data'] : []; diff --git a/packages/core/src/generators/verbs-options.ts b/packages/core/src/generators/verbs-options.ts index a4aa9b08ea..ffbee91ce1 100644 --- a/packages/core/src/generators/verbs-options.ts +++ b/packages/core/src/generators/verbs-options.ts @@ -167,17 +167,6 @@ async function buildVerbOption({ }) : undefined; - const paramsFilter = - isString(override.paramsFilter) || isObject(override.paramsFilter) - ? await generateMutator({ - output: output.target, - name: 'paramsFilter', - mutator: override.paramsFilter as NormalizedMutator, - workspace: context.workspace, - tsconfig: context.output.tsconfig, - }) - : undefined; - const fetchReviver = isString(override.fetch.jsonReviver) || isObject(override.fetch.jsonReviver) ? await generateMutator({ @@ -208,7 +197,6 @@ async function buildVerbOption({ formData, formUrlEncoded, paramsSerializer, - paramsFilter, fetchReviver, override, doc, diff --git a/packages/core/src/getters/query-params.test.ts b/packages/core/src/getters/query-params.test.ts index 34c71c87bc..0bf35a5f46 100644 --- a/packages/core/src/getters/query-params.test.ts +++ b/packages/core/src/getters/query-params.test.ts @@ -7,25 +7,9 @@ import { getQueryParams } from './query-params'; const context: ContextSpec = { spec: {}, output: { - // @ts-expect-error -- partial mock: query-param resolution only needs a - // small subset of normalized override output for these tests. + // @ts-expect-error -- partial mock: only override.useDates needed for test override: { useDates: true, - components: { - schemas: { - suffix: 'Dto', - itemSuffix: 'Item', - }, - responses: { - suffix: 'Response', - }, - parameters: { - suffix: 'Params', - }, - requestBodies: { - suffix: 'Body', - }, - }, }, }, }; @@ -263,171 +247,4 @@ describe('getQueryParams getter', () => { 'requiredOneOfNullableParam', ]); }); - - // Tracking non-primitive keys lets Angular generators preserve schema- - // declared object/array-of-object params through the default filterParams - // helper instead of silently dropping them. See issue #3326. - describe('nonPrimitiveKeys (Angular passthrough)', () => { - it('flags object-typed query params', () => { - const result = getQueryParams({ - queryParams: [ - { - parameter: { - name: 'filters', - in: 'query', - required: false, - schema: { type: 'object' }, - }, - imports: [], - }, - { - parameter: { - name: 'limit', - in: 'query', - required: false, - schema: { type: 'integer' }, - }, - imports: [], - }, - ], - operationName: '', - context, - }); - - expect(result?.nonPrimitiveKeys).toEqual(['filters']); - }); - - it('flags arrays of objects', () => { - const result = getQueryParams({ - queryParams: [ - { - parameter: { - name: 'items', - in: 'query', - required: false, - schema: { - type: 'array', - items: { type: 'object' }, - }, - }, - imports: [], - }, - ], - operationName: '', - context, - }); - - expect(result?.nonPrimitiveKeys).toEqual(['items']); - }); - - it('flags nullable arrays of objects', () => { - const result = getQueryParams({ - queryParams: [ - { - parameter: { - name: 'items', - in: 'query', - required: false, - schema: { - type: ['array', 'null'], - items: { type: 'object' }, - }, - }, - imports: [], - }, - ], - operationName: '', - context, - }); - - expect(result?.nonPrimitiveKeys).toEqual(['items']); - }); - - it('flags object via oneOf composition', () => { - const result = getQueryParams({ - queryParams: [ - { - parameter: { - name: 'either', - in: 'query', - required: false, - schema: { - oneOf: [{ type: 'string' }, { type: 'object' }], - }, - }, - imports: [], - }, - ], - operationName: '', - context, - }); - - expect(result?.nonPrimitiveKeys).toEqual(['either']); - }); - - it('flags type-less schemas with additionalProperties', () => { - const result = getQueryParams({ - queryParams: [ - { - parameter: { - name: 'filters', - in: 'query', - required: false, - schema: { - additionalProperties: { type: 'string' }, - }, - }, - imports: [], - }, - ], - operationName: '', - context, - }); - - expect(result?.nonPrimitiveKeys).toEqual(['filters']); - }); - - it('omits the field when all params are primitive', () => { - const result = getQueryParams({ - queryParams: [ - { - parameter: { - name: 'id', - in: 'query', - required: true, - schema: { type: 'string' }, - }, - imports: [], - }, - ], - operationName: '', - context, - }); - - expect(result?.nonPrimitiveKeys).toBeUndefined(); - }); - - it('does not flag arrays of primitives', () => { - const result = getQueryParams({ - queryParams: [ - { - parameter: { - name: 'tags', - in: 'query', - required: false, - schema: { - type: 'array', - items: { type: 'string' }, - }, - }, - imports: [], - }, - ], - operationName: '', - context, - }); - - expect(result?.nonPrimitiveKeys).toBeUndefined(); - }); - }); }); diff --git a/packages/core/src/getters/query-params.ts b/packages/core/src/getters/query-params.ts index c61d5510b4..2610ba7523 100644 --- a/packages/core/src/getters/query-params.ts +++ b/packages/core/src/getters/query-params.ts @@ -31,80 +31,6 @@ const isOpenApiSchemaObject = ( return !('$ref' in value); }; -const getSchemaType = ( - schema: OpenApiSchemaObject, -): string | string[] | undefined => { - const type = (schema as { type?: unknown }).type; - - if (typeof type === 'string') { - return type; - } - - if ( - Array.isArray(type) && - type.every((variant): variant is string => typeof variant === 'string') - ) { - return type; - } - - return undefined; -}; - -/** - * Detects whether a query parameter's resolved schema is non-primitive — i.e. - * an object, an array of objects, or a composition (oneOf/anyOf/allOf) that - * resolves to a non-primitive shape. - * - * Used by Angular generators so the default `filterParams` helper preserves - * such values instead of silently dropping them. Angular's `HttpParams` only - * accepts primitives, but a user-provided `paramsSerializer`, `mutator`, or - * `paramsFilter` may need the raw object to flatten or stringify it. - */ -const isSchemaNonPrimitive = (schema: OpenApiSchemaObject): boolean => { - const schemaType = getSchemaType(schema); - const type = Array.isArray(schemaType) - ? schemaType.filter((variant) => variant !== 'null') - : schemaType; - const additionalProperties = (schema as { additionalProperties?: unknown }) - .additionalProperties; - - if (type === 'object') { - return true; - } - if (type === 'array' || (Array.isArray(type) && type.includes('array'))) { - const items = (schema as { items?: unknown }).items; - if (isOpenApiSchemaObject(items)) { - return isSchemaNonPrimitive(items); - } - return false; - } - if (Array.isArray(type) && type.includes('object')) { - return true; - } - - const compositions = [ - ...(Array.isArray(schema.oneOf) ? (schema.oneOf as unknown[]) : []), - ...(Array.isArray(schema.anyOf) ? (schema.anyOf as unknown[]) : []), - ...(Array.isArray(schema.allOf) ? (schema.allOf as unknown[]) : []), - ]; - if (compositions.length > 0) { - return compositions.some( - (variant) => - isOpenApiSchemaObject(variant) && isSchemaNonPrimitive(variant), - ); - } - - if ( - !type && - ((schema as { properties?: unknown }).properties !== undefined || - (additionalProperties !== undefined && additionalProperties !== false)) - ) { - return true; - } - - return false; -}; - const isSchemaNullable = (schema: OpenApiSchemaObject): boolean => { if (schema.nullable === true) { return true; @@ -284,9 +210,6 @@ export function getQueryParams({ required && isSchemaNullable(originalSchema), ) .map(({ name }) => name); - const nonPrimitiveKeys = types - .filter(({ originalSchema }) => isSchemaNonPrimitive(originalSchema)) - .map(({ name }) => name); const schema = { name, @@ -299,6 +222,5 @@ export function getQueryParams({ deps: schemas, isOptional: allOptional, requiredNullableKeys, - ...(nonPrimitiveKeys.length > 0 ? { nonPrimitiveKeys } : {}), }; } diff --git a/packages/core/src/writers/single-mode.ts b/packages/core/src/writers/single-mode.ts index 8f996ba5bd..1da5987969 100644 --- a/packages/core/src/writers/single-mode.ts +++ b/packages/core/src/writers/single-mode.ts @@ -41,7 +41,6 @@ export async function writeSingleMode({ formData, formUrlEncoded, paramsSerializer, - paramsFilter, fetchReviver, } = generateTarget(builder, output); @@ -170,10 +169,6 @@ export async function writeSingleMode({ data += generateMutatorImports({ mutators: paramsSerializer }); } - if (paramsFilter) { - data += generateMutatorImports({ mutators: paramsFilter }); - } - if (fetchReviver) { data += generateMutatorImports({ mutators: fetchReviver }); } diff --git a/packages/core/src/writers/split-mode.ts b/packages/core/src/writers/split-mode.ts index fb688702f3..4c657d8e25 100644 --- a/packages/core/src/writers/split-mode.ts +++ b/packages/core/src/writers/split-mode.ts @@ -48,7 +48,6 @@ export async function writeSplitMode({ formData, formUrlEncoded, paramsSerializer, - paramsFilter, fetchReviver, } = generateTarget(builder, output); @@ -148,12 +147,6 @@ export async function writeSplitMode({ }); } - if (paramsFilter) { - implementationData += generateMutatorImports({ - mutators: paramsFilter, - }); - } - if (fetchReviver) { implementationData += generateMutatorImports({ mutators: fetchReviver, diff --git a/packages/core/src/writers/split-tags-mode.ts b/packages/core/src/writers/split-tags-mode.ts index 8d9f176cde..be9aca93d9 100644 --- a/packages/core/src/writers/split-tags-mode.ts +++ b/packages/core/src/writers/split-tags-mode.ts @@ -69,7 +69,6 @@ export async function writeSplitTagsMode({ fetchReviver, formUrlEncoded, paramsSerializer, - paramsFilter, } = target; let implementationData = header; @@ -207,12 +206,6 @@ export async function writeSplitTagsMode({ oneMore: true, }); } - if (paramsFilter) { - implementationData += generateMutatorImports({ - mutators: paramsFilter, - oneMore: true, - }); - } if (fetchReviver) { implementationData += generateMutatorImports({ diff --git a/packages/core/src/writers/tags-mode.ts b/packages/core/src/writers/tags-mode.ts index 27cbab4907..b2c81149a1 100644 --- a/packages/core/src/writers/tags-mode.ts +++ b/packages/core/src/writers/tags-mode.ts @@ -58,7 +58,6 @@ export async function writeTagsMode({ formUrlEncoded, fetchReviver, paramsSerializer, - paramsFilter, } = target; let data = header; @@ -190,10 +189,6 @@ export async function writeTagsMode({ data += generateMutatorImports({ mutators: paramsSerializer }); } - if (paramsFilter) { - data += generateMutatorImports({ mutators: paramsFilter }); - } - if (fetchReviver) { data += generateMutatorImports({ mutators: fetchReviver }); } diff --git a/packages/core/src/writers/target-tags.ts b/packages/core/src/writers/target-tags.ts index e1eb3de6d3..798e507e80 100644 --- a/packages/core/src/writers/target-tags.ts +++ b/packages/core/src/writers/target-tags.ts @@ -188,7 +188,6 @@ export function generateTargetForTags( formData: target.formData, formUrlEncoded: target.formUrlEncoded, paramsSerializer: target.paramsSerializer, - paramsFilter: target.paramsFilter, fetchReviver: target.fetchReviver, }; } diff --git a/packages/core/src/writers/target.ts b/packages/core/src/writers/target.ts index f62bae9a02..410333ba89 100644 --- a/packages/core/src/writers/target.ts +++ b/packages/core/src/writers/target.ts @@ -37,7 +37,6 @@ export function generateTarget( formData: [], formUrlEncoded: [], paramsSerializer: [], - paramsFilter: [], fetchReviver: [], }; const operations = Object.values(builder.operations); @@ -66,9 +65,6 @@ export function generateTarget( if (operation.paramsSerializer) { target.paramsSerializer.push(operation.paramsSerializer); } - if (operation.paramsFilter) { - target.paramsFilter.push(operation.paramsFilter); - } if (operation.clientMutators) { target.clientMutators.push(...operation.clientMutators); diff --git a/packages/orval/src/utils/options.ts b/packages/orval/src/utils/options.ts index d95aa29534..ad0dc5c126 100644 --- a/packages/orval/src/utils/options.ts +++ b/packages/orval/src/utils/options.ts @@ -293,10 +293,6 @@ export async function normalizeOptions( outputWorkspace, outputOptions.override?.paramsSerializer, ), - paramsFilter: normalizeMutator( - outputWorkspace, - outputOptions.override?.paramsFilter, - ), header: outputOptions.override?.header === false ? false @@ -638,7 +634,6 @@ function normalizeOperationsAndTags( formData, formUrlEncoded, paramsSerializer, - paramsFilter, query, angular, zod, @@ -764,11 +759,6 @@ function normalizeOperationsAndTags( ), } : {}), - ...(paramsFilter - ? { - paramsFilter: normalizeMutator(workspace, paramsFilter), - } - : {}), }, ]; }, diff --git a/samples/angular-app/__snapshots__/api/endpoints-zod/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/endpoints-zod/pets/pets.service.ts index 21ceddaaf3..b520192112 100644 --- a/samples/angular-app/__snapshots__/api/endpoints-zod/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/endpoints-zod/pets/pets.service.ts @@ -77,34 +77,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-both/pets/pets.resource.ts b/samples/angular-app/__snapshots__/api/http-both/pets/pets.resource.ts index 162763a014..c932a5f32b 100644 --- a/samples/angular-app/__snapshots__/api/http-both/pets/pets.resource.ts +++ b/samples/angular-app/__snapshots__/api/http-both/pets/pets.resource.ts @@ -34,34 +34,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-both/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/http-both/pets/pets.service.ts index ccfe57d32e..0b41491579 100644 --- a/samples/angular-app/__snapshots__/api/http-both/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/http-both/pets/pets.service.ts @@ -74,34 +74,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-client-custom-params/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/http-client-custom-params/pets/pets.service.ts index 719849af7d..3a1efa7faf 100644 --- a/samples/angular-app/__snapshots__/api/http-client-custom-params/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/http-client-custom-params/pets/pets.service.ts @@ -76,34 +76,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-client/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/http-client/pets/pets.service.ts index e3b20d3c29..1f73892896 100644 --- a/samples/angular-app/__snapshots__/api/http-client/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/http-client/pets/pets.service.ts @@ -76,34 +76,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-resource-zod/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/http-resource-zod/pets/pets.service.ts index 5ac225d449..200aaf8a22 100644 --- a/samples/angular-app/__snapshots__/api/http-resource-zod/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/http-resource-zod/pets/pets.service.ts @@ -54,34 +54,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/__snapshots__/api/http-resource/pets/pets.service.ts b/samples/angular-app/__snapshots__/api/http-resource/pets/pets.service.ts index d3cf9f039a..b3fadd8567 100644 --- a/samples/angular-app/__snapshots__/api/http-resource/pets/pets.service.ts +++ b/samples/angular-app/__snapshots__/api/http-resource/pets/pets.service.ts @@ -51,34 +51,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/endpoints-zod/pets/pets.service.ts b/samples/angular-app/src/api/endpoints-zod/pets/pets.service.ts index 21ceddaaf3..b520192112 100644 --- a/samples/angular-app/src/api/endpoints-zod/pets/pets.service.ts +++ b/samples/angular-app/src/api/endpoints-zod/pets/pets.service.ts @@ -77,34 +77,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-both/pets/pets.resource.ts b/samples/angular-app/src/api/http-both/pets/pets.resource.ts index 162763a014..c932a5f32b 100644 --- a/samples/angular-app/src/api/http-both/pets/pets.resource.ts +++ b/samples/angular-app/src/api/http-both/pets/pets.resource.ts @@ -34,34 +34,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-both/pets/pets.service.ts b/samples/angular-app/src/api/http-both/pets/pets.service.ts index ccfe57d32e..0b41491579 100644 --- a/samples/angular-app/src/api/http-both/pets/pets.service.ts +++ b/samples/angular-app/src/api/http-both/pets/pets.service.ts @@ -74,34 +74,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-client-custom-params/pets/pets.service.ts b/samples/angular-app/src/api/http-client-custom-params/pets/pets.service.ts index 719849af7d..3a1efa7faf 100644 --- a/samples/angular-app/src/api/http-client-custom-params/pets/pets.service.ts +++ b/samples/angular-app/src/api/http-client-custom-params/pets/pets.service.ts @@ -76,34 +76,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-client/pets/pets.service.ts b/samples/angular-app/src/api/http-client/pets/pets.service.ts index e3b20d3c29..1f73892896 100644 --- a/samples/angular-app/src/api/http-client/pets/pets.service.ts +++ b/samples/angular-app/src/api/http-client/pets/pets.service.ts @@ -76,34 +76,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-resource-zod/pets/pets.service.ts b/samples/angular-app/src/api/http-resource-zod/pets/pets.service.ts index 5ac225d449..200aaf8a22 100644 --- a/samples/angular-app/src/api/http-resource-zod/pets/pets.service.ts +++ b/samples/angular-app/src/api/http-resource-zod/pets/pets.service.ts @@ -54,34 +54,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-app/src/api/http-resource/pets/pets.service.ts b/samples/angular-app/src/api/http-resource/pets/pets.service.ts index d3cf9f039a..b3fadd8567 100644 --- a/samples/angular-app/src/api/http-resource/pets/pets.service.ts +++ b/samples/angular-app/src/api/http-resource/pets/pets.service.ts @@ -51,34 +51,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/__snapshots__/api/endpoints-custom-instance/pets/pets.ts b/samples/angular-query/__snapshots__/api/endpoints-custom-instance/pets/pets.ts index 56f2a97af7..69cff46e90 100644 --- a/samples/angular-query/__snapshots__/api/endpoints-custom-instance/pets/pets.ts +++ b/samples/angular-query/__snapshots__/api/endpoints-custom-instance/pets/pets.ts @@ -48,34 +48,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/__snapshots__/api/endpoints-no-transformer/pets/pets.ts b/samples/angular-query/__snapshots__/api/endpoints-no-transformer/pets/pets.ts index a3c1590854..9588e1bf50 100644 --- a/samples/angular-query/__snapshots__/api/endpoints-no-transformer/pets/pets.ts +++ b/samples/angular-query/__snapshots__/api/endpoints-no-transformer/pets/pets.ts @@ -47,34 +47,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/__snapshots__/api/endpoints-zod/pets/pets.ts b/samples/angular-query/__snapshots__/api/endpoints-zod/pets/pets.ts index c16ad8e19f..9fb6e495f5 100644 --- a/samples/angular-query/__snapshots__/api/endpoints-zod/pets/pets.ts +++ b/samples/angular-query/__snapshots__/api/endpoints-zod/pets/pets.ts @@ -44,34 +44,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/__snapshots__/api/endpoints/pets/pets.ts b/samples/angular-query/__snapshots__/api/endpoints/pets/pets.ts index 8d44fbff7e..e52335901c 100644 --- a/samples/angular-query/__snapshots__/api/endpoints/pets/pets.ts +++ b/samples/angular-query/__snapshots__/api/endpoints/pets/pets.ts @@ -50,34 +50,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/src/api/endpoints-custom-instance/pets/pets.ts b/samples/angular-query/src/api/endpoints-custom-instance/pets/pets.ts index 56f2a97af7..69cff46e90 100644 --- a/samples/angular-query/src/api/endpoints-custom-instance/pets/pets.ts +++ b/samples/angular-query/src/api/endpoints-custom-instance/pets/pets.ts @@ -48,34 +48,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/src/api/endpoints-no-transformer/pets/pets.ts b/samples/angular-query/src/api/endpoints-no-transformer/pets/pets.ts index a3c1590854..9588e1bf50 100644 --- a/samples/angular-query/src/api/endpoints-no-transformer/pets/pets.ts +++ b/samples/angular-query/src/api/endpoints-no-transformer/pets/pets.ts @@ -47,34 +47,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/src/api/endpoints-zod/pets/pets.ts b/samples/angular-query/src/api/endpoints-zod/pets/pets.ts index c16ad8e19f..9fb6e495f5 100644 --- a/samples/angular-query/src/api/endpoints-zod/pets/pets.ts +++ b/samples/angular-query/src/api/endpoints-zod/pets/pets.ts @@ -44,34 +44,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/samples/angular-query/src/api/endpoints/pets/pets.ts b/samples/angular-query/src/api/endpoints/pets/pets.ts index 8d44fbff7e..e52335901c 100644 --- a/samples/angular-query/src/api/endpoints/pets/pets.ts +++ b/samples/angular-query/src/api/endpoints/pets/pets.ts @@ -50,34 +50,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular-query/basic/endpoints.ts b/tests/__snapshots__/angular-query/basic/endpoints.ts index 15647fa659..b8abba796c 100644 --- a/tests/__snapshots__/angular-query/basic/endpoints.ts +++ b/tests/__snapshots__/angular-query/basic/endpoints.ts @@ -46,34 +46,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular-query/split/endpoints.ts b/tests/__snapshots__/angular-query/split/endpoints.ts index 15647fa659..b8abba796c 100644 --- a/tests/__snapshots__/angular-query/split/endpoints.ts +++ b/tests/__snapshots__/angular-query/split/endpoints.ts @@ -46,34 +46,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular-query/tags-split/pets/pets.ts b/tests/__snapshots__/angular-query/tags-split/pets/pets.ts index 5c41cf8bef..15426cd0bf 100644 --- a/tests/__snapshots__/angular-query/tags-split/pets/pets.ts +++ b/tests/__snapshots__/angular-query/tags-split/pets/pets.ts @@ -46,34 +46,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular-query/use-prefetch/endpoints.ts b/tests/__snapshots__/angular-query/use-prefetch/endpoints.ts index 9d8b7b8254..f1c903f3e4 100644 --- a/tests/__snapshots__/angular-query/use-prefetch/endpoints.ts +++ b/tests/__snapshots__/angular-query/use-prefetch/endpoints.ts @@ -47,34 +47,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/http-resource-tags/pets.ts b/tests/__snapshots__/angular/http-resource-tags/pets.ts index f6f82b35ef..4822003fc5 100644 --- a/tests/__snapshots__/angular/http-resource-tags/pets.ts +++ b/tests/__snapshots__/angular/http-resource-tags/pets.ts @@ -51,34 +51,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts b/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts index 3c575587b8..63bc0e4b16 100644 --- a/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts +++ b/tests/__snapshots__/angular/http-resource-zod-disabled/endpoints.ts @@ -72,34 +72,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/http-resource-zod/endpoints.ts b/tests/__snapshots__/angular/http-resource-zod/endpoints.ts index 3c575587b8..63bc0e4b16 100644 --- a/tests/__snapshots__/angular/http-resource-zod/endpoints.ts +++ b/tests/__snapshots__/angular/http-resource-zod/endpoints.ts @@ -72,34 +72,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/issue-3103/default/default.service.ts b/tests/__snapshots__/angular/issue-3103/default/default.service.ts index a9c0cc2526..e70e7df995 100644 --- a/tests/__snapshots__/angular/issue-3103/default/default.service.ts +++ b/tests/__snapshots__/angular/issue-3103/default/default.service.ts @@ -68,34 +68,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/multi-content-query-params/endpoints.ts b/tests/__snapshots__/angular/multi-content-query-params/endpoints.ts index d67b8d4da4..0bba4cf138 100644 --- a/tests/__snapshots__/angular/multi-content-query-params/endpoints.ts +++ b/tests/__snapshots__/angular/multi-content-query-params/endpoints.ts @@ -70,34 +70,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/named-parameters/endpoints.ts b/tests/__snapshots__/angular/named-parameters/endpoints.ts index 636573abb1..81d84826d8 100644 --- a/tests/__snapshots__/angular/named-parameters/endpoints.ts +++ b/tests/__snapshots__/angular/named-parameters/endpoints.ts @@ -81,34 +81,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/petstore/endpoints.ts b/tests/__snapshots__/angular/petstore/endpoints.ts index 8cdd3b782d..2462ba2187 100644 --- a/tests/__snapshots__/angular/petstore/endpoints.ts +++ b/tests/__snapshots__/angular/petstore/endpoints.ts @@ -82,34 +82,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/split/endpoints.service.ts b/tests/__snapshots__/angular/split/endpoints.service.ts index 32b60c39e5..9aa072eb09 100644 --- a/tests/__snapshots__/angular/split/endpoints.service.ts +++ b/tests/__snapshots__/angular/split/endpoints.service.ts @@ -75,34 +75,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/tags-split/pets/pets.service.ts b/tests/__snapshots__/angular/tags-split/pets/pets.service.ts index d00b70dcce..168df99c7e 100644 --- a/tests/__snapshots__/angular/tags-split/pets/pets.service.ts +++ b/tests/__snapshots__/angular/tags-split/pets/pets.service.ts @@ -75,34 +75,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/tags/pets.ts b/tests/__snapshots__/angular/tags/pets.ts index 2dfd78dc0a..8754710438 100644 --- a/tests/__snapshots__/angular/tags/pets.ts +++ b/tests/__snapshots__/angular/tags/pets.ts @@ -82,34 +82,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/angular/zod-schema-response/endpoints.ts b/tests/__snapshots__/angular/zod-schema-response/endpoints.ts index 6481d78c87..4c78f62d0a 100644 --- a/tests/__snapshots__/angular/zod-schema-response/endpoints.ts +++ b/tests/__snapshots__/angular/zod-schema-response/endpoints.ts @@ -82,34 +82,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/__snapshots__/default/issue-2998/requests/requests.service.ts b/tests/__snapshots__/default/issue-2998/requests/requests.service.ts index 1a238540ab..eb1f2a3112 100644 --- a/tests/__snapshots__/default/issue-2998/requests/requests.service.ts +++ b/tests/__snapshots__/default/issue-2998/requests/requests.service.ts @@ -73,34 +73,19 @@ function filterParams( params: Record, requiredNullableKeys?: ReadonlySet, preserveRequiredNullables?: false, - passthroughKeys?: undefined, ): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet | undefined, preserveRequiredNullables: true, - passthroughKeys?: undefined, ): Record; -function filterParams( - params: Record, - requiredNullableKeys: ReadonlySet | undefined, - preserveRequiredNullables: boolean | undefined, - passthroughKeys: ReadonlySet, -): Record; function filterParams( params: Record, requiredNullableKeys: ReadonlySet = new Set(), preserveRequiredNullables = false, - passthroughKeys: ReadonlySet = new Set(), -): Record { - const filteredParams: Record = {}; +): Record { + const filteredParams: Record = {}; for (const [key, value] of Object.entries(params)) { - if (passthroughKeys.has(key)) { - if (value !== undefined) { - filteredParams[key] = value; - } - continue; - } if (Array.isArray(value)) { const filtered = value.filter( (item) => diff --git a/tests/mutators/params-filter.ts b/tests/mutators/params-filter.ts deleted file mode 100644 index ab6b994061..0000000000 --- a/tests/mutators/params-filter.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Custom query-parameter filter for issue #3326 integration coverage. - * - * Replaces the built-in Angular `filterParams` helper. Flattens object-valued - * params into bracketed keys (`filters[color]=red`) and strips `undefined`, - * while leaving primitives untouched. - */ -export const flattenParamsFilter = ( - params: Record, -): Record => { - const result: Record = {}; - for (const [key, value] of Object.entries(params)) { - if (value === undefined || value === null) { - continue; - } - if (typeof value === 'object' && !Array.isArray(value)) { - for (const [innerKey, innerValue] of Object.entries( - value as Record, - )) { - if (innerValue !== undefined && innerValue !== null) { - result[`${key}[${innerKey}]`] = innerValue as - | string - | number - | boolean; - } - } - continue; - } - result[key] = value as string | number | boolean; - } - return result; -}; diff --git a/tests/specifications/issue-3326.yaml b/tests/specifications/issue-3326.yaml deleted file mode 100644 index 9db208b068..0000000000 --- a/tests/specifications/issue-3326.yaml +++ /dev/null @@ -1,38 +0,0 @@ -openapi: 3.0.4 -info: - title: Issue 3326 - Angular object query parameter support - version: 1.0.0 -paths: - /api/search: - get: - operationId: search - tags: - - search - parameters: - - name: q - in: query - required: false - schema: - type: string - - name: filters - in: query - required: false - schema: - type: object - additionalProperties: - type: string - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SearchResult' -components: - schemas: - SearchResult: - type: object - properties: - id: - type: integer - format: int32 From e15c3760e9de0828a8528759eedcb00b10aedb4e Mon Sep 17 00:00:00 2001 From: The Ult Date: Sat, 16 May 2026 14:36:54 +0200 Subject: [PATCH 13/18] fix(core): restore 3103 branch validation Restore the paramsFilter defaults needed for type-safe generation on the trimmed 3103 branch. Refresh generated snapshots after the validation run. Refs #3103 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/core/src/writers/target.ts | 4 + packages/orval/src/utils/options.ts | 10 + .../docs-html-plugin/assets/icons.svg | 2 +- samples/react-app/docs-html/assets/icons.svg | 2 +- .../model/index.zod.ts | 20 + .../http-resource-zod/model/index.zod.ts | 20 + .../endpoints.ts | 544 ++++++++++++ .../model/cat.ts | 12 + .../model/catType.ts | 13 + .../model/createPetsBody.ts | 11 + .../model/createPetsParams.ts | 20 + .../model/createPetsSort.ts | 16 + .../model/dachshund.ts | 12 + .../model/dachshundBreed.ts | 13 + .../model/dog.ts | 17 + .../model/dogType.ts | 13 + .../model/error.ts | 11 + .../model/index.ts | 26 + .../model/labradoodle.ts | 12 + .../model/labradoodleBreed.ts | 13 + .../model/listPetsParams.ts | 20 + .../model/listPetsSort.ts | 16 + .../model/pet.ts | 28 + .../model/petCallingCode.ts | 14 + .../model/petCountry.ts | 14 + .../model/petWithTag.ts | 12 + .../model/pets.ts | 9 + .../react-query/hook-mutator/endpoints.ts | 540 ++++++++++++ .../react-query/hook-mutator/model/cat.ts | 12 + .../react-query/hook-mutator/model/catType.ts | 13 + .../hook-mutator/model/createPetsBody.ts | 11 + .../hook-mutator/model/createPetsParams.ts | 20 + .../hook-mutator/model/createPetsSort.ts | 16 + .../hook-mutator/model/dachshund.ts | 12 + .../hook-mutator/model/dachshundBreed.ts | 13 + .../react-query/hook-mutator/model/dog.ts | 17 + .../react-query/hook-mutator/model/dogType.ts | 13 + .../react-query/hook-mutator/model/error.ts | 11 + .../react-query/hook-mutator/model/index.ts | 26 + .../hook-mutator/model/labradoodle.ts | 12 + .../hook-mutator/model/labradoodleBreed.ts | 13 + .../hook-mutator/model/listPetsParams.ts | 20 + .../hook-mutator/model/listPetsSort.ts | 16 + .../react-query/hook-mutator/model/pet.ts | 28 + .../hook-mutator/model/petCallingCode.ts | 14 + .../hook-mutator/model/petCountry.ts | 14 + .../hook-mutator/model/petWithTag.ts | 12 + .../react-query/hook-mutator/model/pets.ts | 9 + .../react-query/tag-hook-mutator/endpoints.ts | 545 ++++++++++++ .../react-query/tag-hook-mutator/model/cat.ts | 12 + .../tag-hook-mutator/model/catType.ts | 13 + .../tag-hook-mutator/model/createPetsBody.ts | 11 + .../model/createPetsParams.ts | 20 + .../tag-hook-mutator/model/createPetsSort.ts | 16 + .../tag-hook-mutator/model/dachshund.ts | 12 + .../tag-hook-mutator/model/dachshundBreed.ts | 13 + .../react-query/tag-hook-mutator/model/dog.ts | 17 + .../tag-hook-mutator/model/dogType.ts | 13 + .../tag-hook-mutator/model/error.ts | 11 + .../tag-hook-mutator/model/index.ts | 26 + .../tag-hook-mutator/model/labradoodle.ts | 12 + .../model/labradoodleBreed.ts | 13 + .../tag-hook-mutator/model/listPetsParams.ts | 20 + .../tag-hook-mutator/model/listPetsSort.ts | 16 + .../react-query/tag-hook-mutator/model/pet.ts | 28 + .../tag-hook-mutator/model/petCallingCode.ts | 14 + .../tag-hook-mutator/model/petCountry.ts | 14 + .../tag-hook-mutator/model/petWithTag.ts | 12 + .../tag-hook-mutator/model/pets.ts | 9 + .../use-prefetch-with-function/endpoints.ts | 797 ++++++++++++++++++ .../use-prefetch-with-function/model/cat.ts | 12 + .../model/catType.ts | 13 + .../model/createPetsBody.ts | 11 + .../model/createPetsParams.ts | 20 + .../model/createPetsSort.ts | 16 + .../model/dachshund.ts | 12 + .../model/dachshundBreed.ts | 13 + .../use-prefetch-with-function/model/dog.ts | 17 + .../model/dogType.ts | 13 + .../use-prefetch-with-function/model/error.ts | 11 + .../use-prefetch-with-function/model/index.ts | 26 + .../model/labradoodle.ts | 12 + .../model/labradoodleBreed.ts | 13 + .../model/listPetsParams.ts | 20 + .../model/listPetsSort.ts | 16 + .../use-prefetch-with-function/model/pet.ts | 28 + .../model/petCallingCode.ts | 14 + .../model/petCountry.ts | 14 + .../model/petWithTag.ts | 12 + .../use-prefetch-with-function/model/pets.ts | 9 + .../endpoints.ts | 590 +++++++++++++ .../model/cat.ts | 12 + .../model/catType.ts | 13 + .../model/createPetsBody.ts | 11 + .../model/createPetsParams.ts | 20 + .../model/createPetsSort.ts | 16 + .../model/dachshund.ts | 12 + .../model/dachshundBreed.ts | 13 + .../model/dog.ts | 17 + .../model/dogType.ts | 13 + .../model/error.ts | 11 + .../model/index.ts | 26 + .../model/labradoodle.ts | 12 + .../model/labradoodleBreed.ts | 13 + .../model/listPetsParams.ts | 20 + .../model/listPetsSort.ts | 16 + .../model/pet.ts | 28 + .../model/petCallingCode.ts | 14 + .../model/petCountry.ts | 14 + .../model/petWithTag.ts | 12 + .../model/pets.ts | 9 + tests/__snapshots__/zod/circularReferences.ts | 48 ++ tests/__snapshots__/zod/coerce.ts | 48 ++ tests/__snapshots__/zod/date-time-options.ts | 27 + tests/__snapshots__/zod/enums.ts | 58 ++ .../zod/import-from-subdirectory.ts | 19 + tests/__snapshots__/zod/multiline-default.ts | 24 + tests/__snapshots__/zod/nestedArrays.ts | 19 + .../__snapshots__/zod/nullable-any-of-refs.ts | 41 + .../__snapshots__/zod/nullable-oneof-enums.ts | 45 + tests/__snapshots__/zod/preprocess.ts | 132 +++ tests/__snapshots__/zod/strict-mode.ts | 48 ++ tests/__snapshots__/zod/time-options.ts | 27 + tests/__snapshots__/zod/translationAPI.ts | 17 + .../zod/typed-arrays-tuples-v3-1.ts | 25 + 125 files changed, 5160 insertions(+), 2 deletions(-) create mode 100644 tests/__snapshots__/angular/http-resource-zod-disabled/model/index.zod.ts create mode 100644 tests/__snapshots__/angular/http-resource-zod/model/index.zod.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/endpoints.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/cat.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/catType.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsBody.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsParams.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsSort.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshund.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshundBreed.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dog.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dogType.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/error.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/index.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodle.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodleBreed.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsParams.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsSort.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pet.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCallingCode.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCountry.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petWithTag.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pets.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/endpoints.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/cat.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/catType.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/createPetsBody.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/createPetsParams.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/createPetsSort.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/dachshund.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/dachshundBreed.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/dog.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/dogType.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/error.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/index.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/labradoodle.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/labradoodleBreed.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/listPetsParams.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/listPetsSort.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/pet.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/petCallingCode.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/petCountry.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/petWithTag.ts create mode 100644 tests/__snapshots__/react-query/hook-mutator/model/pets.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/endpoints.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/cat.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/catType.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsBody.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsParams.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsSort.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/dachshund.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/dachshundBreed.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/dog.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/dogType.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/error.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/index.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodle.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodleBreed.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsParams.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsSort.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/pet.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/petCallingCode.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/petCountry.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/petWithTag.ts create mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/pets.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/endpoints.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/cat.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/catType.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsBody.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsParams.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsSort.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshund.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshundBreed.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/dog.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/dogType.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/error.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/index.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodle.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodleBreed.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsParams.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsSort.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/pet.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/petCallingCode.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/petCountry.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/petWithTag.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/pets.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/endpoints.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/cat.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/catType.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsBody.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsParams.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsSort.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshund.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshundBreed.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dog.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dogType.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/error.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/index.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodle.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodleBreed.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsParams.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsSort.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pet.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCallingCode.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCountry.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petWithTag.ts create mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pets.ts create mode 100644 tests/__snapshots__/zod/circularReferences.ts create mode 100644 tests/__snapshots__/zod/coerce.ts create mode 100644 tests/__snapshots__/zod/date-time-options.ts create mode 100644 tests/__snapshots__/zod/enums.ts create mode 100644 tests/__snapshots__/zod/import-from-subdirectory.ts create mode 100644 tests/__snapshots__/zod/multiline-default.ts create mode 100644 tests/__snapshots__/zod/nestedArrays.ts create mode 100644 tests/__snapshots__/zod/nullable-any-of-refs.ts create mode 100644 tests/__snapshots__/zod/nullable-oneof-enums.ts create mode 100644 tests/__snapshots__/zod/preprocess.ts create mode 100644 tests/__snapshots__/zod/strict-mode.ts create mode 100644 tests/__snapshots__/zod/time-options.ts create mode 100644 tests/__snapshots__/zod/translationAPI.ts create mode 100644 tests/__snapshots__/zod/typed-arrays-tuples-v3-1.ts diff --git a/packages/core/src/writers/target.ts b/packages/core/src/writers/target.ts index 410333ba89..f62bae9a02 100644 --- a/packages/core/src/writers/target.ts +++ b/packages/core/src/writers/target.ts @@ -37,6 +37,7 @@ export function generateTarget( formData: [], formUrlEncoded: [], paramsSerializer: [], + paramsFilter: [], fetchReviver: [], }; const operations = Object.values(builder.operations); @@ -65,6 +66,9 @@ export function generateTarget( if (operation.paramsSerializer) { target.paramsSerializer.push(operation.paramsSerializer); } + if (operation.paramsFilter) { + target.paramsFilter.push(operation.paramsFilter); + } if (operation.clientMutators) { target.clientMutators.push(...operation.clientMutators); diff --git a/packages/orval/src/utils/options.ts b/packages/orval/src/utils/options.ts index ad0dc5c126..d95aa29534 100644 --- a/packages/orval/src/utils/options.ts +++ b/packages/orval/src/utils/options.ts @@ -293,6 +293,10 @@ export async function normalizeOptions( outputWorkspace, outputOptions.override?.paramsSerializer, ), + paramsFilter: normalizeMutator( + outputWorkspace, + outputOptions.override?.paramsFilter, + ), header: outputOptions.override?.header === false ? false @@ -634,6 +638,7 @@ function normalizeOperationsAndTags( formData, formUrlEncoded, paramsSerializer, + paramsFilter, query, angular, zod, @@ -759,6 +764,11 @@ function normalizeOperationsAndTags( ), } : {}), + ...(paramsFilter + ? { + paramsFilter: normalizeMutator(workspace, paramsFilter), + } + : {}), }, ]; }, diff --git a/samples/react-app/docs-html-plugin/assets/icons.svg b/samples/react-app/docs-html-plugin/assets/icons.svg index 10db10be02..be7798fcda 100644 --- a/samples/react-app/docs-html-plugin/assets/icons.svg +++ b/samples/react-app/docs-html-plugin/assets/icons.svg @@ -1 +1 @@ -MMNEPVFCICPMFPCPTTAAATR \ No newline at end of file +MMNEPVFCICPMFPCPTTAAATR \ No newline at end of file diff --git a/samples/react-app/docs-html/assets/icons.svg b/samples/react-app/docs-html/assets/icons.svg index 10db10be02..be7798fcda 100644 --- a/samples/react-app/docs-html/assets/icons.svg +++ b/samples/react-app/docs-html/assets/icons.svg @@ -1 +1 @@ -MMNEPVFCICPMFPCPTTAAATR \ No newline at end of file +MMNEPVFCICPMFPCPTTAAATR \ No newline at end of file diff --git a/tests/__snapshots__/angular/http-resource-zod-disabled/model/index.zod.ts b/tests/__snapshots__/angular/http-resource-zod-disabled/model/index.zod.ts new file mode 100644 index 0000000000..ab1c161fce --- /dev/null +++ b/tests/__snapshots__/angular/http-resource-zod-disabled/model/index.zod.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export * from './cat.zod'; +export * from './createPetsBody.zod'; +export * from './createPetsHeaders.zod'; +export * from './createPetsParams.zod'; +export * from './dachshund.zod'; +export * from './dog.zod'; +export * from './error.zod'; +export * from './labradoodle.zod'; +export * from './listPetsHeaders.zod'; +export * from './listPetsParams.zod'; +export * from './pet.zod'; +export * from './petWithTag.zod'; +export * from './pets.zod'; diff --git a/tests/__snapshots__/angular/http-resource-zod/model/index.zod.ts b/tests/__snapshots__/angular/http-resource-zod/model/index.zod.ts new file mode 100644 index 0000000000..ab1c161fce --- /dev/null +++ b/tests/__snapshots__/angular/http-resource-zod/model/index.zod.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ + +export * from './cat.zod'; +export * from './createPetsBody.zod'; +export * from './createPetsHeaders.zod'; +export * from './createPetsParams.zod'; +export * from './dachshund.zod'; +export * from './dog.zod'; +export * from './error.zod'; +export * from './labradoodle.zod'; +export * from './listPetsHeaders.zod'; +export * from './listPetsParams.zod'; +export * from './pet.zod'; +export * from './petWithTag.zod'; +export * from './pets.zod'; diff --git a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/endpoints.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/endpoints.ts new file mode 100644 index 0000000000..ac182449a6 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/endpoints.ts @@ -0,0 +1,544 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import { + useCallback +} from 'react'; + +import type { + CreatePetsBody, + CreatePetsParams, + Error, + ListPetsParams, + Pet, + PetWithTag, + Pets +} from './model'; + +import { useCustomInstance } from '../../../mutators/use-custom-instance-with-second-parameter'; +type SecondParameter unknown> = Parameters[1]; + + + +/** + * @summary List all pets + */ +export const useListPetsHook = () => { + const listPets = useCustomInstance(); + + return useCallback(( + params: ListPetsParams, + options?: SecondParameter>,signal?: AbortSignal +) => { + return listPets( + {url: `/pets`, method: 'GET', + params, signal + }, + options); + }, [listPets]) + } + + + + +export const getListPetsQueryKey = (params?: ListPetsParams,) => { + return [ + `/pets`, ...(params ? [params] : []) + ] as const; + } + + +export const useListPetsQueryOptions = >>, TError = Error>(params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getListPetsQueryKey(params); + + const listPets = useListPetsHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => listPets(params, requestOptions, signal); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ListPetsQueryResult = NonNullable>>> +export type ListPetsQueryError = Error + + +export function useListPets>>, TError = Error>( + params: ListPetsParams, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, request?: SecondParameter>} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary List all pets + */ + +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useListPetsQueryOptions(params,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + + + + + +/** + * @summary Create a pet + */ +export const useCreatePetsHook = () => { + const createPets = useCustomInstance(); + + return useCallback(( + createPetsBody: CreatePetsBody, + params: CreatePetsParams, + options?: SecondParameter>,signal?: AbortSignal +) => { + return createPets( + {url: `/pets`, method: 'POST', + headers: {'Content-Type': 'application/json', }, + data: createPetsBody, + params, signal + }, + options); + }, [createPets]) + } + + + +export const useCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, request?: SecondParameter>} +): UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext> => { + +const mutationKey = ['createPets']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + const createPets = useCreatePetsHook() + + + const mutationFn: MutationFunction>>, {data: CreatePetsBody;params: CreatePetsParams}> = (props) => { + const {data,params} = props ?? {}; + + return createPets(data,params,requestOptions) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type CreatePetsMutationResult = NonNullable>>> + export type CreatePetsMutationBody = CreatePetsBody + export type CreatePetsMutationError = Error + + /** + * @summary Create a pet + */ +export const useCreatePets = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, request?: SecondParameter>} + , queryClient?: QueryClient): UseMutationResult< + Awaited>>, + TError, + {data: CreatePetsBody;params: CreatePetsParams}, + TContext + > => { + return useMutation(useCreatePetsMutationOptions(options), queryClient); + } + +/** + * @summary Info for a specific pet + */ +export const useShowPetByIdHook = () => { + const showPetById = useCustomInstance(); + + return useCallback(( + petId: string, + options?: SecondParameter>,signal?: AbortSignal +) => { + return showPetById( + {url: `/pets/${petId}`, method: 'GET', signal + }, + options); + }, [showPetById]) + } + + + + +export const getShowPetByIdQueryKey = (petId: string,) => { + return [ + `/pets/${petId}` + ] as const; + } + + +export const useShowPetByIdQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getShowPetByIdQueryKey(petId); + + const showPetById = useShowPetByIdHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => showPetById(petId, requestOptions, signal); + + + + + + return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ShowPetByIdQueryResult = NonNullable>>> +export type ShowPetByIdQueryError = Error + + +export function useShowPetById>>, TError = Error>( + petId: string, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, request?: SecondParameter>} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary Info for a specific pet + */ + +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useShowPetByIdQueryOptions(petId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + + + + + +/** + * @summary Deletes a specific pet + */ +export const useDeletePetByIdHook = () => { + const deletePetById = useCustomInstance(); + + return useCallback(( + petId: string, + options?: SecondParameter>,signal?: AbortSignal +) => { + return deletePetById( + {url: `/pets/${petId}`, method: 'DELETE', signal + }, + options); + }, [deletePetById]) + } + + + +export const useDeletePetByIdMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, request?: SecondParameter>} +): UseMutationOptions>>, TError,{petId: string}, TContext> => { + +const mutationKey = ['deletePetById']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + const deletePetById = useDeletePetByIdHook() + + + const mutationFn: MutationFunction>>, {petId: string}> = (props) => { + const {petId} = props ?? {}; + + return deletePetById(petId,requestOptions) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type DeletePetByIdMutationResult = NonNullable>>> + + export type DeletePetByIdMutationError = Error + + /** + * @summary Deletes a specific pet + */ +export const useDeletePetById = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, request?: SecondParameter>} + , queryClient?: QueryClient): UseMutationResult< + Awaited>>, + TError, + {petId: string}, + TContext + > => { + return useMutation(useDeletePetByIdMutationOptions(options), queryClient); + } + +/** + * @summary health check + */ +export const useHealthCheckHook = () => { + const healthCheck = useCustomInstance(); + + return useCallback(( + + options?: SecondParameter>,signal?: AbortSignal +) => { + return healthCheck( + {url: `/health`, method: 'GET', signal + }, + options); + }, [healthCheck]) + } + + + + +export const getHealthCheckQueryKey = () => { + return [ + `/health` + ] as const; + } + + +export const useHealthCheckQueryOptions = >>, TError = Error>( options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); + + const healthCheck = useHealthCheckHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => healthCheck(requestOptions, signal); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type HealthCheckQueryResult = NonNullable>>> +export type HealthCheckQueryError = Error + + +export function useHealthCheck>>, TError = Error>( + options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, request?: SecondParameter>} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useHealthCheck>>, TError = Error>( + options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useHealthCheck>>, TError = Error>( + options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary health check + */ + +export function useHealthCheck>>, TError = Error>( + options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useHealthCheckQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + + + + + +/** + * @summary combinate nullable and $ref + */ +export const useShowPetWithOwnerHook = () => { + const showPetWithOwner = useCustomInstance(); + + return useCallback(( + petId: string, + options?: SecondParameter>,signal?: AbortSignal +) => { + return showPetWithOwner( + {url: `/pets/${petId}/owner`, method: 'GET', signal + }, + options); + }, [showPetWithOwner]) + } + + + + +export const getShowPetWithOwnerQueryKey = (petId: string,) => { + return [ + `/pets/${petId}/owner` + ] as const; + } + + +export const useShowPetWithOwnerQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getShowPetWithOwnerQueryKey(petId); + + const showPetWithOwner = useShowPetWithOwnerHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => showPetWithOwner(petId, requestOptions, signal); + + + + + + return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ShowPetWithOwnerQueryResult = NonNullable>>> +export type ShowPetWithOwnerQueryError = Error + + +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, request?: SecondParameter>} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary combinate nullable and $ref + */ + +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useShowPetWithOwnerQueryOptions(petId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} diff --git a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/cat.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/cat.ts new file mode 100644 index 0000000000..a78f78e772 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/cat.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/catType.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/catType.ts new file mode 100644 index 0000000000..a46984255b --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/catType.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/createPetsBody.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsBody.ts new file mode 100644 index 0000000000..341621e02a --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsBody.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/createPetsParams.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsParams.ts new file mode 100644 index 0000000000..d64c76b414 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/createPetsSort.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsSort.ts new file mode 100644 index 0000000000..0c2a50682f --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/dachshund.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshund.ts new file mode 100644 index 0000000000..45d0bb5462 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshund.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/dachshundBreed.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshundBreed.ts new file mode 100644 index 0000000000..2c13ab7bcb --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshundBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/dog.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dog.ts new file mode 100644 index 0000000000..a0a6d4dfb0 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dog.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/dogType.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dogType.ts new file mode 100644 index 0000000000..7be3f5414d --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dogType.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/error.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/error.ts new file mode 100644 index 0000000000..3c00b1e9eb --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/error.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/index.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/index.ts new file mode 100644 index 0000000000..cb4321d79f --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/index.ts @@ -0,0 +1,26 @@ +/** + * Generated by orval v8.2.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'; \ No newline at end of file diff --git a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodle.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodle.ts new file mode 100644 index 0000000000..5e5f6d017e --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodle.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/labradoodleBreed.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodleBreed.ts new file mode 100644 index 0000000000..0377d09fd7 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodleBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/listPetsParams.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsParams.ts new file mode 100644 index 0000000000..27134d9237 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/listPetsSort.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsSort.ts new file mode 100644 index 0000000000..35dd7a4c5c --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/pet.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pet.ts new file mode 100644 index 0000000000..3549e2bc2f --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pet.ts @@ -0,0 +1,28 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/petCallingCode.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCallingCode.ts new file mode 100644 index 0000000000..126aa75c75 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCallingCode.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/petCountry.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCountry.ts new file mode 100644 index 0000000000..15e6fec3c8 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCountry.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/petWithTag.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petWithTag.ts new file mode 100644 index 0000000000..ed930b0538 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petWithTag.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/pets.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pets.ts new file mode 100644 index 0000000000..85b2d7b24c --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pets.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/endpoints.ts b/tests/__snapshots__/react-query/hook-mutator/endpoints.ts new file mode 100644 index 0000000000..c43a40a611 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/endpoints.ts @@ -0,0 +1,540 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import { + useCallback +} from 'react'; + +import type { + CreatePetsBody, + CreatePetsParams, + Error, + ListPetsParams, + Pet, + PetWithTag, + Pets +} from './model'; + +import { useCustomInstance } from '../../../mutators/use-custom-instance.js'; +/** + * @summary List all pets + */ +export const useListPetsHook = () => { + const listPets = useCustomInstance(); + + return useCallback(( + params: ListPetsParams, + signal?: AbortSignal +) => { + return listPets( + {url: `/pets`, method: 'GET', + params, signal + }, + ); + }, [listPets]) + } + + + + +export const getListPetsQueryKey = (params?: ListPetsParams,) => { + return [ + `/pets`, ...(params ? [params] : []) + ] as const; + } + + +export const useListPetsQueryOptions = >>, TError = Error>(params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getListPetsQueryKey(params); + + const listPets = useListPetsHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => listPets(params, signal); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ListPetsQueryResult = NonNullable>>> +export type ListPetsQueryError = Error + + +export function useListPets>>, TError = Error>( + params: ListPetsParams, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary List all pets + */ + +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useListPetsQueryOptions(params,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + + + + + +/** + * @summary Create a pet + */ +export const useCreatePetsHook = () => { + const createPets = useCustomInstance(); + + return useCallback(( + createPetsBody: CreatePetsBody, + params: CreatePetsParams, + signal?: AbortSignal +) => { + return createPets( + {url: `/pets`, method: 'POST', + headers: {'Content-Type': 'application/json', }, + data: createPetsBody, + params, signal + }, + ); + }, [createPets]) + } + + + +export const useCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } +): UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext> => { + +const mutationKey = ['createPets']; +const {mutation: mutationOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }}; + + const createPets = useCreatePetsHook() + + + const mutationFn: MutationFunction>>, {data: CreatePetsBody;params: CreatePetsParams}> = (props) => { + const {data,params} = props ?? {}; + + return createPets(data,params,) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type CreatePetsMutationResult = NonNullable>>> + export type CreatePetsMutationBody = CreatePetsBody + export type CreatePetsMutationError = Error + + /** + * @summary Create a pet + */ +export const useCreatePets = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } + , queryClient?: QueryClient): UseMutationResult< + Awaited>>, + TError, + {data: CreatePetsBody;params: CreatePetsParams}, + TContext + > => { + return useMutation(useCreatePetsMutationOptions(options), queryClient); + } + +/** + * @summary Info for a specific pet + */ +export const useShowPetByIdHook = () => { + const showPetById = useCustomInstance(); + + return useCallback(( + petId: string, + signal?: AbortSignal +) => { + return showPetById( + {url: `/pets/${petId}`, method: 'GET', signal + }, + ); + }, [showPetById]) + } + + + + +export const getShowPetByIdQueryKey = (petId: string,) => { + return [ + `/pets/${petId}` + ] as const; + } + + +export const useShowPetByIdQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getShowPetByIdQueryKey(petId); + + const showPetById = useShowPetByIdHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => showPetById(petId, signal); + + + + + + return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ShowPetByIdQueryResult = NonNullable>>> +export type ShowPetByIdQueryError = Error + + +export function useShowPetById>>, TError = Error>( + petId: string, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary Info for a specific pet + */ + +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useShowPetByIdQueryOptions(petId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + + + + + +/** + * @summary Deletes a specific pet + */ +export const useDeletePetByIdHook = () => { + const deletePetById = useCustomInstance(); + + return useCallback(( + petId: string, + signal?: AbortSignal +) => { + return deletePetById( + {url: `/pets/${petId}`, method: 'DELETE', signal + }, + ); + }, [deletePetById]) + } + + + +export const useDeletePetByIdMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } +): UseMutationOptions>>, TError,{petId: string}, TContext> => { + +const mutationKey = ['deletePetById']; +const {mutation: mutationOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }}; + + const deletePetById = useDeletePetByIdHook() + + + const mutationFn: MutationFunction>>, {petId: string}> = (props) => { + const {petId} = props ?? {}; + + return deletePetById(petId,) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type DeletePetByIdMutationResult = NonNullable>>> + + export type DeletePetByIdMutationError = Error + + /** + * @summary Deletes a specific pet + */ +export const useDeletePetById = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } + , queryClient?: QueryClient): UseMutationResult< + Awaited>>, + TError, + {petId: string}, + TContext + > => { + return useMutation(useDeletePetByIdMutationOptions(options), queryClient); + } + +/** + * @summary health check + */ +export const useHealthCheckHook = () => { + const healthCheck = useCustomInstance(); + + return useCallback(( + + signal?: AbortSignal +) => { + return healthCheck( + {url: `/health`, method: 'GET', signal + }, + ); + }, [healthCheck]) + } + + + + +export const getHealthCheckQueryKey = () => { + return [ + `/health` + ] as const; + } + + +export const useHealthCheckQueryOptions = >>, TError = Error>( options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); + + const healthCheck = useHealthCheckHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => healthCheck(signal); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type HealthCheckQueryResult = NonNullable>>> +export type HealthCheckQueryError = Error + + +export function useHealthCheck>>, TError = Error>( + options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useHealthCheck>>, TError = Error>( + options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useHealthCheck>>, TError = Error>( + options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary health check + */ + +export function useHealthCheck>>, TError = Error>( + options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useHealthCheckQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + + + + + +/** + * @summary combinate nullable and $ref + */ +export const useShowPetWithOwnerHook = () => { + const showPetWithOwner = useCustomInstance(); + + return useCallback(( + petId: string, + signal?: AbortSignal +) => { + return showPetWithOwner( + {url: `/pets/${petId}/owner`, method: 'GET', signal + }, + ); + }, [showPetWithOwner]) + } + + + + +export const getShowPetWithOwnerQueryKey = (petId: string,) => { + return [ + `/pets/${petId}/owner` + ] as const; + } + + +export const useShowPetWithOwnerQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getShowPetWithOwnerQueryKey(petId); + + const showPetWithOwner = useShowPetWithOwnerHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => showPetWithOwner(petId, signal); + + + + + + return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ShowPetWithOwnerQueryResult = NonNullable>>> +export type ShowPetWithOwnerQueryError = Error + + +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary combinate nullable and $ref + */ + +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useShowPetWithOwnerQueryOptions(petId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} diff --git a/tests/__snapshots__/react-query/hook-mutator/model/cat.ts b/tests/__snapshots__/react-query/hook-mutator/model/cat.ts new file mode 100644 index 0000000000..a78f78e772 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/cat.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/catType.ts b/tests/__snapshots__/react-query/hook-mutator/model/catType.ts new file mode 100644 index 0000000000..a46984255b --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/catType.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/createPetsBody.ts b/tests/__snapshots__/react-query/hook-mutator/model/createPetsBody.ts new file mode 100644 index 0000000000..341621e02a --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/createPetsBody.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/createPetsParams.ts b/tests/__snapshots__/react-query/hook-mutator/model/createPetsParams.ts new file mode 100644 index 0000000000..d64c76b414 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/createPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/createPetsSort.ts b/tests/__snapshots__/react-query/hook-mutator/model/createPetsSort.ts new file mode 100644 index 0000000000..0c2a50682f --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/createPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/dachshund.ts b/tests/__snapshots__/react-query/hook-mutator/model/dachshund.ts new file mode 100644 index 0000000000..45d0bb5462 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/dachshund.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/dachshundBreed.ts b/tests/__snapshots__/react-query/hook-mutator/model/dachshundBreed.ts new file mode 100644 index 0000000000..2c13ab7bcb --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/dachshundBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/dog.ts b/tests/__snapshots__/react-query/hook-mutator/model/dog.ts new file mode 100644 index 0000000000..a0a6d4dfb0 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/dog.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/dogType.ts b/tests/__snapshots__/react-query/hook-mutator/model/dogType.ts new file mode 100644 index 0000000000..7be3f5414d --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/dogType.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/error.ts b/tests/__snapshots__/react-query/hook-mutator/model/error.ts new file mode 100644 index 0000000000..3c00b1e9eb --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/error.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/index.ts b/tests/__snapshots__/react-query/hook-mutator/model/index.ts new file mode 100644 index 0000000000..cb4321d79f --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/index.ts @@ -0,0 +1,26 @@ +/** + * Generated by orval v8.2.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'; \ No newline at end of file diff --git a/tests/__snapshots__/react-query/hook-mutator/model/labradoodle.ts b/tests/__snapshots__/react-query/hook-mutator/model/labradoodle.ts new file mode 100644 index 0000000000..5e5f6d017e --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/labradoodle.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/labradoodleBreed.ts b/tests/__snapshots__/react-query/hook-mutator/model/labradoodleBreed.ts new file mode 100644 index 0000000000..0377d09fd7 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/labradoodleBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/listPetsParams.ts b/tests/__snapshots__/react-query/hook-mutator/model/listPetsParams.ts new file mode 100644 index 0000000000..27134d9237 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/listPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/listPetsSort.ts b/tests/__snapshots__/react-query/hook-mutator/model/listPetsSort.ts new file mode 100644 index 0000000000..35dd7a4c5c --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/listPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/pet.ts b/tests/__snapshots__/react-query/hook-mutator/model/pet.ts new file mode 100644 index 0000000000..3549e2bc2f --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/pet.ts @@ -0,0 +1,28 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/petCallingCode.ts b/tests/__snapshots__/react-query/hook-mutator/model/petCallingCode.ts new file mode 100644 index 0000000000..126aa75c75 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/petCallingCode.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/petCountry.ts b/tests/__snapshots__/react-query/hook-mutator/model/petCountry.ts new file mode 100644 index 0000000000..15e6fec3c8 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/petCountry.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/petWithTag.ts b/tests/__snapshots__/react-query/hook-mutator/model/petWithTag.ts new file mode 100644 index 0000000000..ed930b0538 --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/petWithTag.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/hook-mutator/model/pets.ts b/tests/__snapshots__/react-query/hook-mutator/model/pets.ts new file mode 100644 index 0000000000..85b2d7b24c --- /dev/null +++ b/tests/__snapshots__/react-query/hook-mutator/model/pets.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/endpoints.ts b/tests/__snapshots__/react-query/tag-hook-mutator/endpoints.ts new file mode 100644 index 0000000000..6f0a408e39 --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/endpoints.ts @@ -0,0 +1,545 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import axios from 'axios'; +import type { + AxiosError, + AxiosRequestConfig, + AxiosResponse +} from 'axios'; + +import { + useCallback +} from 'react'; + +import type { + CreatePetsBody, + CreatePetsParams, + Error, + ListPetsParams, + Pet, + PetWithTag, + Pets +} from './model'; + +import { useCustomInstance } from '../../../mutators/use-custom-instance'; +/** + * @summary List all pets + */ +export const useListPetsHook = () => { + const listPets = useCustomInstance(); + + return useCallback(( + params: ListPetsParams, + signal?: AbortSignal +) => { + return listPets( + {url: `/pets`, method: 'GET', + params, signal + }, + ); + }, [listPets]) + } + + + + +export const getListPetsQueryKey = (params?: ListPetsParams,) => { + return [ + `/pets`, ...(params ? [params] : []) + ] as const; + } + + +export const useListPetsQueryOptions = >>, TError = Error>(params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getListPetsQueryKey(params); + + const listPets = useListPetsHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => listPets(params, signal); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ListPetsQueryResult = NonNullable>>> +export type ListPetsQueryError = Error + + +export function useListPets>>, TError = Error>( + params: ListPetsParams, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary List all pets + */ + +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useListPetsQueryOptions(params,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + + + + + +/** + * @summary Create a pet + */ +export const useCreatePetsHook = () => { + const createPets = useCustomInstance(); + + return useCallback(( + createPetsBody: CreatePetsBody, + params: CreatePetsParams, + signal?: AbortSignal +) => { + return createPets( + {url: `/pets`, method: 'POST', + headers: {'Content-Type': 'application/json', }, + data: createPetsBody, + params, signal + }, + ); + }, [createPets]) + } + + + +export const useCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } +): UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext> => { + +const mutationKey = ['createPets']; +const {mutation: mutationOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }}; + + const createPets = useCreatePetsHook() + + + const mutationFn: MutationFunction>>, {data: CreatePetsBody;params: CreatePetsParams}> = (props) => { + const {data,params} = props ?? {}; + + return createPets(data,params,) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type CreatePetsMutationResult = NonNullable>>> + export type CreatePetsMutationBody = CreatePetsBody + export type CreatePetsMutationError = Error + + /** + * @summary Create a pet + */ +export const useCreatePets = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } + , queryClient?: QueryClient): UseMutationResult< + Awaited>>, + TError, + {data: CreatePetsBody;params: CreatePetsParams}, + TContext + > => { + return useMutation(useCreatePetsMutationOptions(options), queryClient); + } + +/** + * @summary Info for a specific pet + */ +export const useShowPetByIdHook = () => { + const showPetById = useCustomInstance(); + + return useCallback(( + petId: string, + signal?: AbortSignal +) => { + return showPetById( + {url: `/pets/${petId}`, method: 'GET', signal + }, + ); + }, [showPetById]) + } + + + + +export const getShowPetByIdQueryKey = (petId: string,) => { + return [ + `/pets/${petId}` + ] as const; + } + + +export const useShowPetByIdQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getShowPetByIdQueryKey(petId); + + const showPetById = useShowPetByIdHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => showPetById(petId, signal); + + + + + + return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ShowPetByIdQueryResult = NonNullable>>> +export type ShowPetByIdQueryError = Error + + +export function useShowPetById>>, TError = Error>( + petId: string, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary Info for a specific pet + */ + +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useShowPetByIdQueryOptions(petId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + + + + + +/** + * @summary Deletes a specific pet + */ +export const useDeletePetByIdHook = () => { + const deletePetById = useCustomInstance(); + + return useCallback(( + petId: string, + signal?: AbortSignal +) => { + return deletePetById( + {url: `/pets/${petId}`, method: 'DELETE', signal + }, + ); + }, [deletePetById]) + } + + + +export const useDeletePetByIdMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } +): UseMutationOptions>>, TError,{petId: string}, TContext> => { + +const mutationKey = ['deletePetById']; +const {mutation: mutationOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }}; + + const deletePetById = useDeletePetByIdHook() + + + const mutationFn: MutationFunction>>, {petId: string}> = (props) => { + const {petId} = props ?? {}; + + return deletePetById(petId,) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type DeletePetByIdMutationResult = NonNullable>>> + + export type DeletePetByIdMutationError = Error + + /** + * @summary Deletes a specific pet + */ +export const useDeletePetById = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } + , queryClient?: QueryClient): UseMutationResult< + Awaited>>, + TError, + {petId: string}, + TContext + > => { + return useMutation(useDeletePetByIdMutationOptions(options), queryClient); + } + +/** + * @summary health check + */ +export const healthCheck = ( + options?: AxiosRequestConfig + ): Promise> => { + + + return axios.get( + `/health`,{ + responseType: 'text', + ...options,} + ); + } + + + + +export const getHealthCheckQueryKey = () => { + return [ + `/health` + ] as const; + } + + +export const getHealthCheckQueryOptions = >, TError = AxiosError>( options?: { query?:Partial>, TError, TData>>, axios?: AxiosRequestConfig} +) => { + +const {query: queryOptions, axios: axiosOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => healthCheck({ signal, ...axiosOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } +} + +export type HealthCheckQueryResult = NonNullable>> +export type HealthCheckQueryError = AxiosError + + +export function useHealthCheck>, TError = AxiosError>( + options: { query:Partial>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, axios?: AxiosRequestConfig} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useHealthCheck>, TError = AxiosError>( + options?: { query?:Partial>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, axios?: AxiosRequestConfig} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useHealthCheck>, TError = AxiosError>( + options?: { query?:Partial>, TError, TData>>, axios?: AxiosRequestConfig} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary health check + */ + +export function useHealthCheck>, TError = AxiosError>( + options?: { query?:Partial>, TError, TData>>, axios?: AxiosRequestConfig} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = getHealthCheckQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + + + + + +/** + * @summary combinate nullable and $ref + */ +export const useShowPetWithOwnerHook = () => { + const showPetWithOwner = useCustomInstance(); + + return useCallback(( + petId: string, + signal?: AbortSignal +) => { + return showPetWithOwner( + {url: `/pets/${petId}/owner`, method: 'GET', signal + }, + ); + }, [showPetWithOwner]) + } + + + + +export const getShowPetWithOwnerQueryKey = (petId: string,) => { + return [ + `/pets/${petId}/owner` + ] as const; + } + + +export const useShowPetWithOwnerQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getShowPetWithOwnerQueryKey(petId); + + const showPetWithOwner = useShowPetWithOwnerHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => showPetWithOwner(petId, signal); + + + + + + return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ShowPetWithOwnerQueryResult = NonNullable>>> +export type ShowPetWithOwnerQueryError = Error + + +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary combinate nullable and $ref + */ + +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useShowPetWithOwnerQueryOptions(petId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} diff --git a/tests/__snapshots__/react-query/tag-hook-mutator/model/cat.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/cat.ts new file mode 100644 index 0000000000..a78f78e772 --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/cat.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/catType.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/catType.ts new file mode 100644 index 0000000000..a46984255b --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/catType.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/createPetsBody.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsBody.ts new file mode 100644 index 0000000000..341621e02a --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsBody.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/createPetsParams.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsParams.ts new file mode 100644 index 0000000000..d64c76b414 --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/createPetsSort.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsSort.ts new file mode 100644 index 0000000000..0c2a50682f --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/dachshund.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/dachshund.ts new file mode 100644 index 0000000000..45d0bb5462 --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/dachshund.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/dachshundBreed.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/dachshundBreed.ts new file mode 100644 index 0000000000..2c13ab7bcb --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/dachshundBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/dog.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/dog.ts new file mode 100644 index 0000000000..a0a6d4dfb0 --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/dog.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/dogType.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/dogType.ts new file mode 100644 index 0000000000..7be3f5414d --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/dogType.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/error.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/error.ts new file mode 100644 index 0000000000..3c00b1e9eb --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/error.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/index.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/index.ts new file mode 100644 index 0000000000..cb4321d79f --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/index.ts @@ -0,0 +1,26 @@ +/** + * Generated by orval v8.2.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'; \ No newline at end of file diff --git a/tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodle.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodle.ts new file mode 100644 index 0000000000..5e5f6d017e --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodle.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/labradoodleBreed.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodleBreed.ts new file mode 100644 index 0000000000..0377d09fd7 --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodleBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/listPetsParams.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsParams.ts new file mode 100644 index 0000000000..27134d9237 --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/listPetsSort.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsSort.ts new file mode 100644 index 0000000000..35dd7a4c5c --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/pet.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/pet.ts new file mode 100644 index 0000000000..3549e2bc2f --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/pet.ts @@ -0,0 +1,28 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/petCallingCode.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/petCallingCode.ts new file mode 100644 index 0000000000..126aa75c75 --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/petCallingCode.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/petCountry.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/petCountry.ts new file mode 100644 index 0000000000..15e6fec3c8 --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/petCountry.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/petWithTag.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/petWithTag.ts new file mode 100644 index 0000000000..ed930b0538 --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/petWithTag.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/pets.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/pets.ts new file mode 100644 index 0000000000..85b2d7b24c --- /dev/null +++ b/tests/__snapshots__/react-query/tag-hook-mutator/model/pets.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/endpoints.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/endpoints.ts new file mode 100644 index 0000000000..b27c48e197 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/endpoints.ts @@ -0,0 +1,797 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +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; + + +/** + * @summary List all pets + */ +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' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/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 const getListPetsQueryKey = (params?: ListPetsParams,) => { + return [ + `/pets`, ...(params ? [params] : []) + ] as const; + } + + +export const getListPetsQueryOptions = >, TError = Error>(params: ListPetsParams, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} +) => { + +const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getListPetsQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => listPets(params, { signal, ...fetchOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } +} + +export type ListPetsQueryResult = NonNullable>> +export type ListPetsQueryError = Error + + +export function useListPets>, TError = Error>( + params: ListPetsParams, options: { query:Partial>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, fetch?: RequestInit} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useListPets>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useListPets>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary List all pets + */ + +export function useListPets>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = getListPetsQueryOptions(params,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + +/** + * @summary List all pets + */ +export const prefetchListPetsQuery = async >, TError = Error>( + queryClient: QueryClient, params: ListPetsParams, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + + ): Promise => { + + const queryOptions = getListPetsQueryOptions(params,options) + + await queryClient.prefetchQuery(queryOptions); + + return queryClient; +} + + + + +/** + * @summary Create a pet + */ +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' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/pets` +} + +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 const getCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, fetch?: RequestInit} +): UseMutationOptions>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext> => { + +const mutationKey = ['createPets']; +const {mutation: mutationOptions, fetch: fetchOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, fetch: undefined}; + + + + + const mutationFn: MutationFunction>, {data: CreatePetsBody;params: CreatePetsParams}> = (props) => { + const {data,params} = props ?? {}; + + return createPets(data,params,fetchOptions) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type CreatePetsMutationResult = NonNullable>> + export type CreatePetsMutationBody = CreatePetsBody + export type CreatePetsMutationError = Error + + /** + * @summary Create a pet + */ +export const useCreatePets = (options?: { mutation?:UseMutationOptions>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, fetch?: RequestInit} + , queryClient?: QueryClient): UseMutationResult< + Awaited>, + TError, + {data: CreatePetsBody;params: CreatePetsParams}, + TContext + > => { + return useMutation(getCreatePetsMutationOptions(options), queryClient); + } + +/** + * @summary Info for a specific pet + */ +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}` +} + +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 const getShowPetByIdQueryKey = (petId: string,) => { + return [ + `/pets/${petId}` + ] as const; + } + + +export const getShowPetByIdQueryOptions = >, TError = Error>(petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} +) => { + +const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getShowPetByIdQueryKey(petId); + + + + const queryFn: QueryFunction>> = ({ signal }) => showPetById(petId, { signal, ...fetchOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } +} + +export type ShowPetByIdQueryResult = NonNullable>> +export type ShowPetByIdQueryError = Error + + +export function useShowPetById>, TError = Error>( + petId: string, options: { query:Partial>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, fetch?: RequestInit} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useShowPetById>, TError = Error>( + petId: string, options?: { query?:Partial>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useShowPetById>, TError = Error>( + petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary Info for a specific pet + */ + +export function useShowPetById>, TError = Error>( + petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = getShowPetByIdQueryOptions(petId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + +/** + * @summary Info for a specific pet + */ +export const prefetchShowPetByIdQuery = async >, TError = Error>( + queryClient: QueryClient, petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + + ): Promise => { + + const queryOptions = getShowPetByIdQueryOptions(petId,options) + + await queryClient.prefetchQuery(queryOptions); + + return queryClient; +} + + + + +/** + * @summary Deletes a specific pet + */ +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}` +} + +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) : {} + return { data, status: res.status, headers: res.headers } as deletePetByIdResponse +} + + + + +export const getDeletePetByIdMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{petId: string}, TContext>, fetch?: RequestInit} +): UseMutationOptions>, TError,{petId: string}, TContext> => { + +const mutationKey = ['deletePetById']; +const {mutation: mutationOptions, fetch: fetchOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, fetch: undefined}; + + + + + const mutationFn: MutationFunction>, {petId: string}> = (props) => { + const {petId} = props ?? {}; + + return deletePetById(petId,fetchOptions) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type DeletePetByIdMutationResult = NonNullable>> + + export type DeletePetByIdMutationError = Error + + /** + * @summary Deletes a specific pet + */ +export const useDeletePetById = (options?: { mutation?:UseMutationOptions>, TError,{petId: string}, TContext>, fetch?: RequestInit} + , queryClient?: QueryClient): UseMutationResult< + Awaited>, + TError, + {petId: string}, + TContext + > => { + return useMutation(getDeletePetByIdMutationOptions(options), queryClient); + } + +/** + * @summary health check + */ +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` +} + +export const healthCheck = async ( options?: RequestInit): Promise => { + + const res = await fetch(getHealthCheckUrl(), + { + ...options, + method: 'GET' + + + } +) + + const body = [204, 205, 304].includes(res.status) ? null : await res.text(); + + const data: healthCheckResponse['data'] = body ? JSON.parse(body) : {} + return { data, status: res.status, headers: res.headers } as healthCheckResponse +} + + + + + +export const getHealthCheckQueryKey = () => { + return [ + `/health` + ] as const; + } + + +export const getHealthCheckQueryOptions = >, TError = Error>( options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} +) => { + +const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => healthCheck({ signal, ...fetchOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } +} + +export type HealthCheckQueryResult = NonNullable>> +export type HealthCheckQueryError = Error + + +export function useHealthCheck>, TError = Error>( + options: { query:Partial>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, fetch?: RequestInit} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useHealthCheck>, TError = Error>( + options?: { query?:Partial>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useHealthCheck>, TError = Error>( + options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary health check + */ + +export function useHealthCheck>, TError = Error>( + options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = getHealthCheckQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + +/** + * @summary health check + */ +export const prefetchHealthCheckQuery = async >, TError = Error>( + queryClient: QueryClient, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + + ): Promise => { + + const queryOptions = getHealthCheckQueryOptions(options) + + await queryClient.prefetchQuery(queryOptions); + + return queryClient; +} + + + + +/** + * @summary combinate nullable and $ref + */ +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` +} + +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 +} + + + + + +export const getShowPetWithOwnerQueryKey = (petId: string,) => { + return [ + `/pets/${petId}/owner` + ] as const; + } + + +export const getShowPetWithOwnerQueryOptions = >, TError = Error>(petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} +) => { + +const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getShowPetWithOwnerQueryKey(petId); + + + + const queryFn: QueryFunction>> = ({ signal }) => showPetWithOwner(petId, { signal, ...fetchOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } +} + +export type ShowPetWithOwnerQueryResult = NonNullable>> +export type ShowPetWithOwnerQueryError = Error + + +export function useShowPetWithOwner>, TError = Error>( + petId: string, options: { query:Partial>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, fetch?: RequestInit} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useShowPetWithOwner>, TError = Error>( + petId: string, options?: { query?:Partial>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useShowPetWithOwner>, TError = Error>( + petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary combinate nullable and $ref + */ + +export function useShowPetWithOwner>, TError = Error>( + petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = getShowPetWithOwnerQueryOptions(petId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + +/** + * @summary combinate nullable and $ref + */ +export const prefetchShowPetWithOwnerQuery = async >, TError = Error>( + queryClient: QueryClient, petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} + + ): Promise => { + + const queryOptions = getShowPetWithOwnerQueryOptions(petId,options) + + await queryClient.prefetchQuery(queryOptions); + + return queryClient; +} diff --git a/tests/__snapshots__/react-query/use-prefetch-with-function/model/cat.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/cat.ts new file mode 100644 index 0000000000..a78f78e772 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/cat.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/catType.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/catType.ts new file mode 100644 index 0000000000..a46984255b --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/catType.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/createPetsBody.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsBody.ts new file mode 100644 index 0000000000..341621e02a --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsBody.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/createPetsParams.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsParams.ts new file mode 100644 index 0000000000..d64c76b414 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/createPetsSort.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsSort.ts new file mode 100644 index 0000000000..0c2a50682f --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/dachshund.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshund.ts new file mode 100644 index 0000000000..45d0bb5462 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshund.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/dachshundBreed.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshundBreed.ts new file mode 100644 index 0000000000..2c13ab7bcb --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshundBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/dog.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dog.ts new file mode 100644 index 0000000000..a0a6d4dfb0 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dog.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/dogType.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dogType.ts new file mode 100644 index 0000000000..7be3f5414d --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dogType.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/error.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/error.ts new file mode 100644 index 0000000000..3c00b1e9eb --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/error.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/index.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/index.ts new file mode 100644 index 0000000000..cb4321d79f --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/index.ts @@ -0,0 +1,26 @@ +/** + * Generated by orval v8.2.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'; \ No newline at end of file diff --git a/tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodle.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodle.ts new file mode 100644 index 0000000000..5e5f6d017e --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodle.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/labradoodleBreed.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodleBreed.ts new file mode 100644 index 0000000000..0377d09fd7 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodleBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/listPetsParams.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsParams.ts new file mode 100644 index 0000000000..27134d9237 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/listPetsSort.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsSort.ts new file mode 100644 index 0000000000..35dd7a4c5c --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/pet.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/pet.ts new file mode 100644 index 0000000000..3549e2bc2f --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/pet.ts @@ -0,0 +1,28 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/petCallingCode.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/petCallingCode.ts new file mode 100644 index 0000000000..126aa75c75 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/petCallingCode.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/petCountry.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/petCountry.ts new file mode 100644 index 0000000000..15e6fec3c8 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/petCountry.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/petWithTag.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/petWithTag.ts new file mode 100644 index 0000000000..ed930b0538 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/petWithTag.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/pets.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/pets.ts new file mode 100644 index 0000000000..85b2d7b24c --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-function/model/pets.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/endpoints.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/endpoints.ts new file mode 100644 index 0000000000..d4f908ea3e --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/endpoints.ts @@ -0,0 +1,590 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import { + useMutation, + useQuery, + useQueryClient +} from '@tanstack/react-query'; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import { + useCallback +} from 'react'; + +import type { + CreatePetsBody, + CreatePetsParams, + Error, + ListPetsParams, + Pet, + PetWithTag, + Pets +} from './model'; + +import { useCustomInstance } from '../../../mutators/use-custom-instance'; +/** + * @summary List all pets + */ +export const useListPetsHook = () => { + const listPets = useCustomInstance(); + + return useCallback(( + params: ListPetsParams, + signal?: AbortSignal +) => { + return listPets( + {url: `/pets`, method: 'GET', + params, signal + }, + ); + }, [listPets]) + } + + + + +export const getListPetsQueryKey = (params?: ListPetsParams,) => { + return [ + `/pets`, ...(params ? [params] : []) + ] as const; + } + + +export const useListPetsQueryOptions = >>, TError = Error>(params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getListPetsQueryKey(params); + + const listPets = useListPetsHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => listPets(params, signal); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ListPetsQueryResult = NonNullable>>> +export type ListPetsQueryError = Error + + +export function useListPets>>, TError = Error>( + params: ListPetsParams, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary List all pets + */ + +export function useListPets>>, TError = Error>( + params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useListPetsQueryOptions(params,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + +/** + * @summary List all pets + */ +export const usePrefetchListPetsQuery = >>, TError = Error>(params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } +) => { + const queryClient = useQueryClient(); + const queryOptions = useListPetsQueryOptions(params,options) + return useCallback(async (): Promise => { + await queryClient.prefetchQuery(queryOptions) + return queryClient; + },[queryClient, queryOptions]); +}; + + + + +/** + * @summary Create a pet + */ +export const useCreatePetsHook = () => { + const createPets = useCustomInstance(); + + return useCallback(( + createPetsBody: CreatePetsBody, + params: CreatePetsParams, + signal?: AbortSignal +) => { + return createPets( + {url: `/pets`, method: 'POST', + headers: {'Content-Type': 'application/json', }, + data: createPetsBody, + params, signal + }, + ); + }, [createPets]) + } + + + +export const useCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } +): UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext> => { + +const mutationKey = ['createPets']; +const {mutation: mutationOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }}; + + const createPets = useCreatePetsHook() + + + const mutationFn: MutationFunction>>, {data: CreatePetsBody;params: CreatePetsParams}> = (props) => { + const {data,params} = props ?? {}; + + return createPets(data,params,) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type CreatePetsMutationResult = NonNullable>>> + export type CreatePetsMutationBody = CreatePetsBody + export type CreatePetsMutationError = Error + + /** + * @summary Create a pet + */ +export const useCreatePets = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } + , queryClient?: QueryClient): UseMutationResult< + Awaited>>, + TError, + {data: CreatePetsBody;params: CreatePetsParams}, + TContext + > => { + return useMutation(useCreatePetsMutationOptions(options), queryClient); + } + +/** + * @summary Info for a specific pet + */ +export const useShowPetByIdHook = () => { + const showPetById = useCustomInstance(); + + return useCallback(( + petId: string, + signal?: AbortSignal +) => { + return showPetById( + {url: `/pets/${petId}`, method: 'GET', signal + }, + ); + }, [showPetById]) + } + + + + +export const getShowPetByIdQueryKey = (petId: string,) => { + return [ + `/pets/${petId}` + ] as const; + } + + +export const useShowPetByIdQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getShowPetByIdQueryKey(petId); + + const showPetById = useShowPetByIdHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => showPetById(petId, signal); + + + + + + return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ShowPetByIdQueryResult = NonNullable>>> +export type ShowPetByIdQueryError = Error + + +export function useShowPetById>>, TError = Error>( + petId: string, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary Info for a specific pet + */ + +export function useShowPetById>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useShowPetByIdQueryOptions(petId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + +/** + * @summary Info for a specific pet + */ +export const usePrefetchShowPetByIdQuery = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } +) => { + const queryClient = useQueryClient(); + const queryOptions = useShowPetByIdQueryOptions(petId,options) + return useCallback(async (): Promise => { + await queryClient.prefetchQuery(queryOptions) + return queryClient; + },[queryClient, queryOptions]); +}; + + + + +/** + * @summary Deletes a specific pet + */ +export const useDeletePetByIdHook = () => { + const deletePetById = useCustomInstance(); + + return useCallback(( + petId: string, + signal?: AbortSignal +) => { + return deletePetById( + {url: `/pets/${petId}`, method: 'DELETE', signal + }, + ); + }, [deletePetById]) + } + + + +export const useDeletePetByIdMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } +): UseMutationOptions>>, TError,{petId: string}, TContext> => { + +const mutationKey = ['deletePetById']; +const {mutation: mutationOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }}; + + const deletePetById = useDeletePetByIdHook() + + + const mutationFn: MutationFunction>>, {petId: string}> = (props) => { + const {petId} = props ?? {}; + + return deletePetById(petId,) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type DeletePetByIdMutationResult = NonNullable>>> + + export type DeletePetByIdMutationError = Error + + /** + * @summary Deletes a specific pet + */ +export const useDeletePetById = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } + , queryClient?: QueryClient): UseMutationResult< + Awaited>>, + TError, + {petId: string}, + TContext + > => { + return useMutation(useDeletePetByIdMutationOptions(options), queryClient); + } + +/** + * @summary health check + */ +export const useHealthCheckHook = () => { + const healthCheck = useCustomInstance(); + + return useCallback(( + + signal?: AbortSignal +) => { + return healthCheck( + {url: `/health`, method: 'GET', signal + }, + ); + }, [healthCheck]) + } + + + + +export const getHealthCheckQueryKey = () => { + return [ + `/health` + ] as const; + } + + +export const useHealthCheckQueryOptions = >>, TError = Error>( options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); + + const healthCheck = useHealthCheckHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => healthCheck(signal); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type HealthCheckQueryResult = NonNullable>>> +export type HealthCheckQueryError = Error + + +export function useHealthCheck>>, TError = Error>( + options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useHealthCheck>>, TError = Error>( + options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useHealthCheck>>, TError = Error>( + options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary health check + */ + +export function useHealthCheck>>, TError = Error>( + options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useHealthCheckQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + +/** + * @summary health check + */ +export const usePrefetchHealthCheckQuery = >>, TError = Error>( options?: { query?:Partial>>, TError, TData>>, } +) => { + const queryClient = useQueryClient(); + const queryOptions = useHealthCheckQueryOptions(options) + return useCallback(async (): Promise => { + await queryClient.prefetchQuery(queryOptions) + return queryClient; + },[queryClient, queryOptions]); +}; + + + + +/** + * @summary combinate nullable and $ref + */ +export const useShowPetWithOwnerHook = () => { + const showPetWithOwner = useCustomInstance(); + + return useCallback(( + petId: string, + signal?: AbortSignal +) => { + return showPetWithOwner( + {url: `/pets/${petId}/owner`, method: 'GET', signal + }, + ); + }, [showPetWithOwner]) + } + + + + +export const getShowPetWithOwnerQueryKey = (petId: string,) => { + return [ + `/pets/${petId}/owner` + ] as const; + } + + +export const useShowPetWithOwnerQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } +) => { + +const {query: queryOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getShowPetWithOwnerQueryKey(petId); + + const showPetWithOwner = useShowPetWithOwnerHook(); + + const queryFn: QueryFunction>>> = ({ signal }) => showPetWithOwner(petId, signal); + + + + + + return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } +} + +export type ShowPetWithOwnerQueryResult = NonNullable>>> +export type ShowPetWithOwnerQueryError = Error + + +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options: { query:Partial>>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>>, + TError, + Awaited>> + > , 'initialData' + >, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary combinate nullable and $ref + */ + +export function useShowPetWithOwner>>, TError = Error>( + petId: string, options?: { query?:Partial>>, TError, TData>>, } + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = useShowPetWithOwnerQueryOptions(petId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + +/** + * @summary combinate nullable and $ref + */ +export const usePrefetchShowPetWithOwnerQuery = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } +) => { + const queryClient = useQueryClient(); + const queryOptions = useShowPetWithOwnerQueryOptions(petId,options) + return useCallback(async (): Promise => { + await queryClient.prefetchQuery(queryOptions) + return queryClient; + },[queryClient, queryOptions]); +}; diff --git a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/cat.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/cat.ts new file mode 100644 index 0000000000..a78f78e772 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/cat.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/catType.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/catType.ts new file mode 100644 index 0000000000..a46984255b --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/catType.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/createPetsBody.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsBody.ts new file mode 100644 index 0000000000..341621e02a --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsBody.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/createPetsParams.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsParams.ts new file mode 100644 index 0000000000..d64c76b414 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/createPetsSort.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsSort.ts new file mode 100644 index 0000000000..0c2a50682f --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/dachshund.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshund.ts new file mode 100644 index 0000000000..45d0bb5462 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshund.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/dachshundBreed.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshundBreed.ts new file mode 100644 index 0000000000..2c13ab7bcb --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshundBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/dog.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dog.ts new file mode 100644 index 0000000000..a0a6d4dfb0 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dog.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/dogType.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dogType.ts new file mode 100644 index 0000000000..7be3f5414d --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dogType.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/error.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/error.ts new file mode 100644 index 0000000000..3c00b1e9eb --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/error.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/index.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/index.ts new file mode 100644 index 0000000000..cb4321d79f --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/index.ts @@ -0,0 +1,26 @@ +/** + * Generated by orval v8.2.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'; \ No newline at end of file diff --git a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodle.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodle.ts new file mode 100644 index 0000000000..5e5f6d017e --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodle.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/labradoodleBreed.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodleBreed.ts new file mode 100644 index 0000000000..0377d09fd7 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodleBreed.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/listPetsParams.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsParams.ts new file mode 100644 index 0000000000..27134d9237 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsParams.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/listPetsSort.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsSort.ts new file mode 100644 index 0000000000..35dd7a4c5c --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsSort.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/pet.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pet.ts new file mode 100644 index 0000000000..3549e2bc2f --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pet.ts @@ -0,0 +1,28 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/petCallingCode.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCallingCode.ts new file mode 100644 index 0000000000..126aa75c75 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCallingCode.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/petCountry.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCountry.ts new file mode 100644 index 0000000000..15e6fec3c8 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCountry.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/petWithTag.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petWithTag.ts new file mode 100644 index 0000000000..ed930b0538 --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petWithTag.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/pets.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pets.ts new file mode 100644 index 0000000000..85b2d7b24c --- /dev/null +++ b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pets.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v8.2.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__/zod/circularReferences.ts b/tests/__snapshots__/zod/circularReferences.ts new file mode 100644 index 0000000000..82a96742f7 --- /dev/null +++ b/tests/__snapshots__/zod/circularReferences.ts @@ -0,0 +1,48 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Circular references + * OpenAPI spec version: 0.0.0 + */ +import * as zod from 'zod'; + +/** + * @summary Example + */ +export const GetExampleResponse = zod.object({ + "id": zod.number().optional(), + "name": zod.string().optional(), + "child": zod.unknown().optional() +}) + + +/** + * @summary Node with required child + */ +export const GetNodeWithRequiredChildResponse = zod.object({ + "id": zod.number(), + "name": zod.string(), + "child": zod.unknown() +}) + + +/** + * @summary Add list + */ +export const addListQueryLimitRegExp = new RegExp('^\\+\\d{10, 15}'); + + +export const AddListQueryParams = zod.object({ + "limit": zod.string().regex(addListQueryLimitRegExp).optional().describe('How many items to return at one time (max 100)'), + "birthdate": zod.string().date().optional().describe('birth date') +}) + +export const addListBodyListItemMax = 10; + +export const addListBodyListMax = 10; + + + +export const AddListBody = zod.object({ + "list": zod.array(zod.number().min(1).max(addListBodyListItemMax)).min(1).max(addListBodyListMax) +}) diff --git a/tests/__snapshots__/zod/coerce.ts b/tests/__snapshots__/zod/coerce.ts new file mode 100644 index 0000000000..4e42b8371e --- /dev/null +++ b/tests/__snapshots__/zod/coerce.ts @@ -0,0 +1,48 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Circular references + * OpenAPI spec version: 0.0.0 + */ +import * as zod from 'zod'; + +/** + * @summary Example + */ +export const GetExampleResponse = zod.object({ + "id": zod.coerce.number().optional(), + "name": zod.coerce.string().optional(), + "child": zod.unknown().optional() +}) + + +/** + * @summary Node with required child + */ +export const GetNodeWithRequiredChildResponse = zod.object({ + "id": zod.coerce.number(), + "name": zod.coerce.string(), + "child": zod.unknown() +}) + + +/** + * @summary Add list + */ +export const addListQueryLimitRegExpTwo = new RegExp('^\\+\\d{10, 15}'); + + +export const AddListQueryParams = zod.object({ + "limit": zod.coerce.string().regex(addListQueryLimitRegExpTwo).optional().describe('How many items to return at one time (max 100)'), + "birthdate": zod.coerce.string().date().optional().describe('birth date') +}) + +export const addListBodyListItemMaxTwo = 10; + +export const addListBodyListMaxTwo = 10; + + + +export const AddListBody = zod.object({ + "list": zod.array(zod.coerce.number().min(1).max(addListBodyListItemMaxTwo)).min(1).max(addListBodyListMaxTwo) +}) diff --git a/tests/__snapshots__/zod/date-time-options.ts b/tests/__snapshots__/zod/date-time-options.ts new file mode 100644 index 0000000000..75408dceea --- /dev/null +++ b/tests/__snapshots__/zod/date-time-options.ts @@ -0,0 +1,27 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * format test + * OpenAPI spec version: 1.0.0 + */ +import * as zod from 'zod'; + +/** + * @summary Info for a specific pet + */ +export const ShowPetByIdParams = zod.object({ + "petId": zod.string().describe('The id of the pet to retrieve'), + "testId": zod.string().describe('The id of the pet to retrieve') +}) + +export const ShowPetByIdResponse = zod.object({ + "id": zod.number().optional(), + "birthDate": zod.string().date(), + "createdAt": zod.string().datetime({"offset":true,"precision":3}), + "age": zod.number().optional(), + "legCount": zod.number().optional(), + "weight": zod.number().optional(), + "height": zod.number().optional(), + "chipNumbers": zod.array(zod.number()).optional(), + "feedingTime": zod.string().time({}).optional() +}) diff --git a/tests/__snapshots__/zod/enums.ts b/tests/__snapshots__/zod/enums.ts new file mode 100644 index 0000000000..bb50c2d2d8 --- /dev/null +++ b/tests/__snapshots__/zod/enums.ts @@ -0,0 +1,58 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Enums + * OpenAPI spec version: 1.0.0 + */ +import * as zod from 'zod'; + +/** + * @summary sample cat + */ +export const GetApiCatResponseItem = zod.union([zod.literal(1),zod.literal(2),zod.literal(3)]) +export const GetApiCatResponse = zod.array(GetApiCatResponseItem) + + +/** + * @summary sample required cat + */ +export const GetApiRequiredCatResponse = zod.object({ + "petsRequested": zod.array(zod.object({ + "colours": zod.array(zod.enum(['BLACK', 'BROWN', 'WHITE', 'GREY'])) +})).optional() +}) + + +/** + * @summary sample dog + */ +export const GetApiDogResponse = zod.object({ + "group": zod.union([zod.literal(1),zod.literal(2),zod.literal(3)]).optional(), + "petsRequested": zod.array(zod.object({ + "colour": zod.enum(['BLACK', 'BROWN']).optional() +})).optional() +}) + + +/** + * @summary sample required dog + */ +export const GetApiRequiredDogResponse = zod.object({ + "petsRequested": zod.array(zod.object({ + "colour": zod.enum(['BLACK', 'BROWN']) +})).optional() +}) + + +/** + * @summary sample duck + */ +export const GetApiDuckResponse = zod.object({ + "petsRequested": zod.array(zod.string()).optional() +}) + + +/** + * @summary sample cat dog + */ +export const GetApiCatDogResponse = zod.union([zod.literal(1),zod.literal('2'),zod.literal('a')]) diff --git a/tests/__snapshots__/zod/import-from-subdirectory.ts b/tests/__snapshots__/zod/import-from-subdirectory.ts new file mode 100644 index 0000000000..3569236c14 --- /dev/null +++ b/tests/__snapshots__/zod/import-from-subdirectory.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import * as zod from 'zod'; + +export const PostPetsResponse = zod.object({ + "id": zod.number(), + "file": zod.object({ + "id": zod.number() +}).optional() +}) + + +export const GetPetsResponse = zod.object({ + "id": zod.number() +}) diff --git a/tests/__snapshots__/zod/multiline-default.ts b/tests/__snapshots__/zod/multiline-default.ts new file mode 100644 index 0000000000..2d41b8d08a --- /dev/null +++ b/tests/__snapshots__/zod/multiline-default.ts @@ -0,0 +1,24 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Orval Multiline Default Repro + * OpenAPI spec version: 1.0.0 + */ +import * as zod from 'zod'; + +/** + * @summary Endpoint demonstrating multiline default value + */ +export const createMultilineDefaultBodyRerankPromptDefault = `# Task +You are a helpful assistant. Rerank the following information blocks according to their relevance to the given question. +Return only the indices of the most relevant blocks in descending order of relevance, using the exact response format specified below. + +# Question +{question} + +# Information Blocks +{blocks}`; + +export const CreateMultilineDefaultBody = zod.object({ + "rerank_prompt": zod.union([zod.string(),zod.null()]).default(createMultilineDefaultBodyRerankPromptDefault).describe('Prompt text with a multiline default value.') +}) diff --git a/tests/__snapshots__/zod/nestedArrays.ts b/tests/__snapshots__/zod/nestedArrays.ts new file mode 100644 index 0000000000..8f8e165239 --- /dev/null +++ b/tests/__snapshots__/zod/nestedArrays.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * NestedArrays + * OpenAPI spec version: 1.0.0 + */ +import * as zod from 'zod'; + +/** + * @summary sample + */ +export const postApiSampleResponseItemsItemMin = 2; +export const postApiSampleResponseItemsItemMax = 5; + + + +export const PostApiSampleResponse = zod.object({ + "items": zod.array(zod.array(zod.string()).min(postApiSampleResponseItemsItemMin).max(postApiSampleResponseItemsItemMax)) +}) diff --git a/tests/__snapshots__/zod/nullable-any-of-refs.ts b/tests/__snapshots__/zod/nullable-any-of-refs.ts new file mode 100644 index 0000000000..2e8399691d --- /dev/null +++ b/tests/__snapshots__/zod/nullable-any-of-refs.ts @@ -0,0 +1,41 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Nullable AnyOf Refs + * OpenAPI spec version: v1.0 + */ +import * as zod from 'zod'; + +export const GetPetsResponseItem = zod.object({ + "petId": zod.union([zod.string().nullable(),zod.string().nullable()]).nullish() +}) +export const GetPetsResponse = zod.array(GetPetsResponseItem) + + +export const GetAnimalsResponseItem = zod.object({ + "animalId": zod.union([zod.string().nullable(),zod.string().nullable(),zod.string().uuid().nullable()]).nullish(), + "secondaryId": zod.union([zod.string().nullable(),zod.string().nullable()]).nullish() +}) +export const GetAnimalsResponse = zod.array(GetAnimalsResponseItem) + + +export const GetNestedAnimalsResponseItem = zod.object({ + "nested": zod.object({ + "animalId": zod.union([zod.string().nullable(),zod.string().nullable(),zod.string().uuid().nullable()]).nullish(), + "petId": zod.union([zod.string().nullable(),zod.string().nullable()]).nullish() +}).optional() +}) +export const GetNestedAnimalsResponse = zod.array(GetNestedAnimalsResponseItem) + + +export const GetMixedNullableResponseItem = zod.object({ + "mixedId": zod.union([zod.string().nullable(),zod.string().nullable(),zod.string().uuid()]).nullish() +}) +export const GetMixedNullableResponse = zod.array(GetMixedNullableResponseItem) + + +export const GetMixedTypesResponseItem = zod.object({ + "mixedAnyOf": zod.union([zod.string().nullable(),zod.number().nullable(),zod.number().nullable(),zod.boolean().nullable()]).nullish(), + "mixedTypesNotNull": zod.union([zod.number(),zod.number(),zod.string().uuid()]).nullish() +}) +export const GetMixedTypesResponse = zod.array(GetMixedTypesResponseItem) diff --git a/tests/__snapshots__/zod/nullable-oneof-enums.ts b/tests/__snapshots__/zod/nullable-oneof-enums.ts new file mode 100644 index 0000000000..2f383e580e --- /dev/null +++ b/tests/__snapshots__/zod/nullable-oneof-enums.ts @@ -0,0 +1,45 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Nullable OneOf Enums + * Test case for issue + * OpenAPI spec version: 1.0.0 + */ +import * as zod from 'zod'; + +export const GetItemsResponseItem = zod.object({ + "hello": zod.union([zod.enum(['HI', 'OHA']),zod.enum(['']),zod.literal(null)]).nullish() +}) +export const GetItemsResponse = zod.array(GetItemsResponseItem) + + +export const GetItemsWithMultiplePropsResponseItem = zod.object({ + "hello": zod.union([zod.enum(['HI', 'OHA']),zod.enum(['']),zod.literal(null)]).nullish(), + "world": zod.union([zod.union([zod.literal(1),zod.literal(2),zod.literal(3)]),zod.union([zod.literal(true),zod.literal(false)])]).nullish(), + "optional": zod.union([zod.enum(['HI', 'OHA']),zod.enum([''])]).nullish() +}) +export const GetItemsWithMultiplePropsResponse = zod.array(GetItemsWithMultiplePropsResponseItem) + + +export const GetNestedItemsResponseItem = zod.object({ + "nested": zod.object({ + "hello": zod.union([zod.enum(['HI', 'OHA']),zod.enum(['']),zod.literal(null)]).nullish(), + "world": zod.union([zod.union([zod.literal(1),zod.literal(2),zod.literal(3)]),zod.union([zod.literal(true),zod.literal(false)])]).nullish() +}).optional() +}) +export const GetNestedItemsResponse = zod.array(GetNestedItemsResponseItem) + + +export const GetMixedEnumItemsResponseItem = zod.object({ + "mixed": zod.union([zod.enum(['HI', 'OHA']),zod.enum(['']),zod.enum(['ALWAYS', 'NEVER'])]).nullish() +}) +export const GetMixedEnumItemsResponse = zod.array(GetMixedEnumItemsResponseItem) + + +export const GetMixedTypeEnumsResponseItem = zod.object({ + "stringEnum": zod.union([zod.enum(['HI', 'OHA']),zod.enum([''])]).nullish(), + "numberEnum": zod.union([zod.union([zod.literal(1.5),zod.literal(2.5),zod.literal(3.5)]).nullable(),zod.union([zod.literal(100.1),zod.literal(200.2)])]).nullish(), + "integerEnum": zod.union([zod.union([zod.literal(10),zod.literal(20),zod.literal(30)]).nullable(),zod.union([zod.literal(1000),zod.literal(2000)])]).nullish(), + "booleanEnum": zod.union([zod.union([zod.literal(true),zod.literal(false)]).nullable(),zod.literal(true)]).nullish() +}) +export const GetMixedTypeEnumsResponse = zod.array(GetMixedTypeEnumsResponseItem) diff --git a/tests/__snapshots__/zod/preprocess.ts b/tests/__snapshots__/zod/preprocess.ts new file mode 100644 index 0000000000..ad3fb472bb --- /dev/null +++ b/tests/__snapshots__/zod/preprocess.ts @@ -0,0 +1,132 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Swagger Petstore + * OpenAPI spec version: 1.0.0 + */ +import * as zod from 'zod'; + +import { stripNill } from '../../mutators/zod-preprocess'; +/** + * @summary List all pets + */ +export const ListPetsQueryParams = zod.preprocess(stripNill, zod.object({ + "limit": zod.string().optional().describe('How many items to return at one time (max 100)'), + "sort": zod.enum(['name', '-name', 'email', '-email']).describe('Which property to sort by?\nExample: name sorts ASC while -name sorts DESC.\n') +})) + +export const ListPetsHeader = zod.preprocess(stripNill, zod.object({ + "X-EXAMPLE": zod.enum(['ONE', 'TWO', 'THREE']).describe('Header parameters') +})) + + +/** + * @summary Create a pet + */ +export const CreatePetsQueryParams = zod.preprocess(stripNill, zod.object({ + "limit": zod.string().optional().describe('How many items to return at one time (max 100)'), + "sort": zod.enum(['name', '-name', 'email', '-email']).describe('Which property to sort by?\nExample: name sorts ASC while -name sorts DESC.\n') +})) + +export const CreatePetsHeader = zod.preprocess(stripNill, zod.object({ + "X-EXAMPLE": zod.enum(['ONE', 'TWO', 'THREE']).describe('Header parameters') +})) + +export const CreatePetsBody = zod.preprocess(stripNill, zod.object({ + "name": zod.string(), + "tag": zod.string() +})) + +export const CreatePetsResponse = zod.preprocess(stripNill, zod.union([zod.union([zod.object({ + "cuteness": zod.number(), + "breed": zod.enum(['Labradoodle']) +}),zod.object({ + "length": zod.number(), + "breed": zod.enum(['Dachshund']) +})]).and(zod.object({ + "barksPerMinute": zod.number().optional(), + "type": zod.enum(['dog']) +})),zod.object({ + "petsRequested": zod.number().optional(), + "type": zod.enum(['cat']) +})]).and(zod.object({ + "@id": zod.string().optional(), + "id": zod.number(), + "name": zod.string(), + "tag": zod.string().optional(), + "email": zod.string().email().optional(), + "callingCode": zod.enum(['+33', '+420', '+33']).optional(), + "country": zod.enum(['People\'s Republic of China', 'Uruguay']).optional() +}))) + + +/** + * @summary Info for a specific pet + */ +export const ShowPetByIdParams = zod.preprocess(stripNill, zod.object({ + "petId": zod.string().describe('The id of the pet to retrieve'), + "testId": zod.string().describe('The id of the pet to retrieve') +})) + +export const ShowPetByIdResponse = zod.preprocess(stripNill, zod.union([zod.union([zod.object({ + "cuteness": zod.number(), + "breed": zod.enum(['Labradoodle']) +}),zod.object({ + "length": zod.number(), + "breed": zod.enum(['Dachshund']) +})]).and(zod.object({ + "barksPerMinute": zod.number().optional(), + "type": zod.enum(['dog']) +})),zod.object({ + "petsRequested": zod.number().optional(), + "type": zod.enum(['cat']) +})]).and(zod.object({ + "@id": zod.string().optional(), + "id": zod.number(), + "name": zod.string(), + "tag": zod.string().optional(), + "email": zod.string().email().optional(), + "callingCode": zod.enum(['+33', '+420', '+33']).optional(), + "country": zod.enum(['People\'s Republic of China', 'Uruguay']).optional() +}))) + + +/** + * @summary Deletes a specific pet + */ +export const DeletePetByIdParams = zod.preprocess(stripNill, zod.object({ + "petId": zod.string().describe('The id of the pet to delete') +})) + + +/** + * @summary combinate nullable and $ref + */ +export const ShowPetWithOwnerParams = zod.preprocess(stripNill, zod.object({ + "petId": zod.string().describe('The id of the pet') +})) + +export const ShowPetWithOwnerResponse = zod.preprocess(stripNill, zod.object({ + "tag": zod.string(), + "pet": zod.union([zod.union([zod.object({ + "cuteness": zod.number(), + "breed": zod.enum(['Labradoodle']) +}),zod.object({ + "length": zod.number(), + "breed": zod.enum(['Dachshund']) +})]).and(zod.object({ + "barksPerMinute": zod.number().optional(), + "type": zod.enum(['dog']) +})),zod.object({ + "petsRequested": zod.number().optional(), + "type": zod.enum(['cat']) +})]).and(zod.object({ + "@id": zod.string().optional(), + "id": zod.number(), + "name": zod.string(), + "tag": zod.string().optional(), + "email": zod.string().email().optional(), + "callingCode": zod.enum(['+33', '+420', '+33']).optional(), + "country": zod.enum(['People\'s Republic of China', 'Uruguay']).optional() +})).nullable() +})) diff --git a/tests/__snapshots__/zod/strict-mode.ts b/tests/__snapshots__/zod/strict-mode.ts new file mode 100644 index 0000000000..eeedbe570b --- /dev/null +++ b/tests/__snapshots__/zod/strict-mode.ts @@ -0,0 +1,48 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Circular references + * OpenAPI spec version: 0.0.0 + */ +import * as zod from 'zod'; + +/** + * @summary Example + */ +export const GetExampleResponse = zod.object({ + "id": zod.number().optional(), + "name": zod.string().optional(), + "child": zod.unknown().optional() +}).strict() + + +/** + * @summary Node with required child + */ +export const GetNodeWithRequiredChildResponse = zod.object({ + "id": zod.number(), + "name": zod.string(), + "child": zod.unknown() +}).strict() + + +/** + * @summary Add list + */ +export const addListQueryLimitRegExpOne = new RegExp('^\\+\\d{10, 15}'); + + +export const AddListQueryParams = zod.object({ + "limit": zod.string().regex(addListQueryLimitRegExpOne).optional().describe('How many items to return at one time (max 100)'), + "birthdate": zod.string().date().optional().describe('birth date') +}).strict() + +export const addListBodyListItemMaxOne = 10; + +export const addListBodyListMaxOne = 10; + + + +export const AddListBody = zod.object({ + "list": zod.array(zod.number().min(1).max(addListBodyListItemMaxOne)).min(1).max(addListBodyListMaxOne) +}).strict() diff --git a/tests/__snapshots__/zod/time-options.ts b/tests/__snapshots__/zod/time-options.ts new file mode 100644 index 0000000000..992cea95ec --- /dev/null +++ b/tests/__snapshots__/zod/time-options.ts @@ -0,0 +1,27 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * format test + * OpenAPI spec version: 1.0.0 + */ +import * as zod from 'zod'; + +/** + * @summary Info for a specific pet + */ +export const ShowPetByIdParams = zod.object({ + "petId": zod.string().describe('The id of the pet to retrieve'), + "testId": zod.string().describe('The id of the pet to retrieve') +}) + +export const ShowPetByIdResponse = zod.object({ + "id": zod.number().optional(), + "birthDate": zod.string().date(), + "createdAt": zod.string().datetime({}), + "age": zod.number().optional(), + "legCount": zod.number().optional(), + "weight": zod.number().optional(), + "height": zod.number().optional(), + "chipNumbers": zod.array(zod.number()).optional(), + "feedingTime": zod.string().time({"precision":-1}).optional() +}) diff --git a/tests/__snapshots__/zod/translationAPI.ts b/tests/__snapshots__/zod/translationAPI.ts new file mode 100644 index 0000000000..df79c22fe6 --- /dev/null +++ b/tests/__snapshots__/zod/translationAPI.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Translation API + * Translation APIs + * OpenAPI spec version: 1.0.0 + */ +import * as zod from 'zod'; + +/** + * @summary Retrieve Translations + */ +export const RetrieveTranslationsParams = zod.object({ + "locale": zod.string() +}) + +export const RetrieveTranslationsResponse = zod.record(zod.string(), zod.string()) diff --git a/tests/__snapshots__/zod/typed-arrays-tuples-v3-1.ts b/tests/__snapshots__/zod/typed-arrays-tuples-v3-1.ts new file mode 100644 index 0000000000..7925472792 --- /dev/null +++ b/tests/__snapshots__/zod/typed-arrays-tuples-v3-1.ts @@ -0,0 +1,25 @@ +/** + * Generated by orval v8.2.0 🍺 + * Do not edit manually. + * Nullables + * OpenAPI 3.1 examples + * OpenAPI spec version: 1.0.0 + */ +import * as zod from 'zod'; + +/** + * @summary sample + */ +export const PostApiSampleResponse = zod.object({ + "example_tuple": zod.tuple([zod.string(), +zod.unknown()]).optional(), + "example_tuple_additional": zod.tuple([zod.string(), +zod.unknown()]).optional(), + "example_tuple_with_object_item": zod.tuple([zod.object({ + "id": zod.string().uuid().optional() +}), +zod.string().uuid()]).optional(), + "example_const": zod.unknown().optional(), + "example_string_const": zod.literal("this_is_a_string_const").optional(), + "example_enum": zod.enum(['enum1', 'enum2']).optional() +}) From d5841f56fed42fc250c4e25e8eabd1d07b905464 Mon Sep 17 00:00:00 2001 From: The Ult Date: Sat, 16 May 2026 21:23:29 +0200 Subject: [PATCH 14/18] test(snapshots): remove stale generated snapshots Drop snapshot files carried into this branch by prior snapshot updates. These files are not part of the current branch snapshot set and they break snapshot verification plus the snapshot version check in CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../model/index.zod.ts | 20 - .../http-resource-zod/model/index.zod.ts | 20 - .../endpoints.ts | 544 ------------ .../model/cat.ts | 12 - .../model/catType.ts | 13 - .../model/createPetsBody.ts | 11 - .../model/createPetsParams.ts | 20 - .../model/createPetsSort.ts | 16 - .../model/dachshund.ts | 12 - .../model/dachshundBreed.ts | 13 - .../model/dog.ts | 17 - .../model/dogType.ts | 13 - .../model/error.ts | 11 - .../model/index.ts | 26 - .../model/labradoodle.ts | 12 - .../model/labradoodleBreed.ts | 13 - .../model/listPetsParams.ts | 20 - .../model/listPetsSort.ts | 16 - .../model/pet.ts | 28 - .../model/petCallingCode.ts | 14 - .../model/petCountry.ts | 14 - .../model/petWithTag.ts | 12 - .../model/pets.ts | 9 - .../react-query/hook-mutator/endpoints.ts | 540 ------------ .../react-query/hook-mutator/model/cat.ts | 12 - .../react-query/hook-mutator/model/catType.ts | 13 - .../hook-mutator/model/createPetsBody.ts | 11 - .../hook-mutator/model/createPetsParams.ts | 20 - .../hook-mutator/model/createPetsSort.ts | 16 - .../hook-mutator/model/dachshund.ts | 12 - .../hook-mutator/model/dachshundBreed.ts | 13 - .../react-query/hook-mutator/model/dog.ts | 17 - .../react-query/hook-mutator/model/dogType.ts | 13 - .../react-query/hook-mutator/model/error.ts | 11 - .../react-query/hook-mutator/model/index.ts | 26 - .../hook-mutator/model/labradoodle.ts | 12 - .../hook-mutator/model/labradoodleBreed.ts | 13 - .../hook-mutator/model/listPetsParams.ts | 20 - .../hook-mutator/model/listPetsSort.ts | 16 - .../react-query/hook-mutator/model/pet.ts | 28 - .../hook-mutator/model/petCallingCode.ts | 14 - .../hook-mutator/model/petCountry.ts | 14 - .../hook-mutator/model/petWithTag.ts | 12 - .../react-query/hook-mutator/model/pets.ts | 9 - .../react-query/tag-hook-mutator/endpoints.ts | 545 ------------ .../react-query/tag-hook-mutator/model/cat.ts | 12 - .../tag-hook-mutator/model/catType.ts | 13 - .../tag-hook-mutator/model/createPetsBody.ts | 11 - .../model/createPetsParams.ts | 20 - .../tag-hook-mutator/model/createPetsSort.ts | 16 - .../tag-hook-mutator/model/dachshund.ts | 12 - .../tag-hook-mutator/model/dachshundBreed.ts | 13 - .../react-query/tag-hook-mutator/model/dog.ts | 17 - .../tag-hook-mutator/model/dogType.ts | 13 - .../tag-hook-mutator/model/error.ts | 11 - .../tag-hook-mutator/model/index.ts | 26 - .../tag-hook-mutator/model/labradoodle.ts | 12 - .../model/labradoodleBreed.ts | 13 - .../tag-hook-mutator/model/listPetsParams.ts | 20 - .../tag-hook-mutator/model/listPetsSort.ts | 16 - .../react-query/tag-hook-mutator/model/pet.ts | 28 - .../tag-hook-mutator/model/petCallingCode.ts | 14 - .../tag-hook-mutator/model/petCountry.ts | 14 - .../tag-hook-mutator/model/petWithTag.ts | 12 - .../tag-hook-mutator/model/pets.ts | 9 - .../use-prefetch-with-function/endpoints.ts | 797 ------------------ .../use-prefetch-with-function/model/cat.ts | 12 - .../model/catType.ts | 13 - .../model/createPetsBody.ts | 11 - .../model/createPetsParams.ts | 20 - .../model/createPetsSort.ts | 16 - .../model/dachshund.ts | 12 - .../model/dachshundBreed.ts | 13 - .../use-prefetch-with-function/model/dog.ts | 17 - .../model/dogType.ts | 13 - .../use-prefetch-with-function/model/error.ts | 11 - .../use-prefetch-with-function/model/index.ts | 26 - .../model/labradoodle.ts | 12 - .../model/labradoodleBreed.ts | 13 - .../model/listPetsParams.ts | 20 - .../model/listPetsSort.ts | 16 - .../use-prefetch-with-function/model/pet.ts | 28 - .../model/petCallingCode.ts | 14 - .../model/petCountry.ts | 14 - .../model/petWithTag.ts | 12 - .../use-prefetch-with-function/model/pets.ts | 9 - .../endpoints.ts | 590 ------------- .../model/cat.ts | 12 - .../model/catType.ts | 13 - .../model/createPetsBody.ts | 11 - .../model/createPetsParams.ts | 20 - .../model/createPetsSort.ts | 16 - .../model/dachshund.ts | 12 - .../model/dachshundBreed.ts | 13 - .../model/dog.ts | 17 - .../model/dogType.ts | 13 - .../model/error.ts | 11 - .../model/index.ts | 26 - .../model/labradoodle.ts | 12 - .../model/labradoodleBreed.ts | 13 - .../model/listPetsParams.ts | 20 - .../model/listPetsSort.ts | 16 - .../model/pet.ts | 28 - .../model/petCallingCode.ts | 14 - .../model/petCountry.ts | 14 - .../model/petWithTag.ts | 12 - .../model/pets.ts | 9 - tests/__snapshots__/zod/circularReferences.ts | 48 -- tests/__snapshots__/zod/coerce.ts | 48 -- tests/__snapshots__/zod/date-time-options.ts | 27 - tests/__snapshots__/zod/enums.ts | 58 -- .../zod/import-from-subdirectory.ts | 19 - tests/__snapshots__/zod/multiline-default.ts | 24 - tests/__snapshots__/zod/nestedArrays.ts | 19 - .../__snapshots__/zod/nullable-any-of-refs.ts | 41 - .../__snapshots__/zod/nullable-oneof-enums.ts | 45 - tests/__snapshots__/zod/preprocess.ts | 132 --- tests/__snapshots__/zod/strict-mode.ts | 48 -- tests/__snapshots__/zod/time-options.ts | 27 - tests/__snapshots__/zod/translationAPI.ts | 17 - .../zod/typed-arrays-tuples-v3-1.ts | 25 - 121 files changed, 5144 deletions(-) delete mode 100644 tests/__snapshots__/angular/http-resource-zod-disabled/model/index.zod.ts delete mode 100644 tests/__snapshots__/angular/http-resource-zod/model/index.zod.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/endpoints.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/cat.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/catType.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsBody.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsParams.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsSort.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshund.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshundBreed.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dog.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dogType.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/error.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/index.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodle.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodleBreed.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsParams.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsSort.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pet.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCallingCode.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCountry.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petWithTag.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pets.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/endpoints.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/cat.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/catType.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/createPetsBody.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/createPetsParams.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/createPetsSort.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/dachshund.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/dachshundBreed.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/dog.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/dogType.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/error.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/index.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/labradoodle.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/labradoodleBreed.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/listPetsParams.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/listPetsSort.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/pet.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/petCallingCode.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/petCountry.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/petWithTag.ts delete mode 100644 tests/__snapshots__/react-query/hook-mutator/model/pets.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/endpoints.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/cat.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/catType.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsBody.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsParams.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsSort.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/dachshund.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/dachshundBreed.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/dog.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/dogType.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/error.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/index.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodle.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodleBreed.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsParams.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsSort.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/pet.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/petCallingCode.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/petCountry.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/petWithTag.ts delete mode 100644 tests/__snapshots__/react-query/tag-hook-mutator/model/pets.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/endpoints.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/cat.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/catType.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsBody.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsParams.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsSort.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshund.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshundBreed.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/dog.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/dogType.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/error.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/index.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodle.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodleBreed.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsParams.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsSort.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/pet.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/petCallingCode.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/petCountry.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/petWithTag.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-function/model/pets.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/endpoints.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/cat.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/catType.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsBody.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsParams.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsSort.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshund.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshundBreed.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dog.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dogType.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/error.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/index.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodle.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodleBreed.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsParams.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsSort.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pet.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCallingCode.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCountry.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petWithTag.ts delete mode 100644 tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pets.ts delete mode 100644 tests/__snapshots__/zod/circularReferences.ts delete mode 100644 tests/__snapshots__/zod/coerce.ts delete mode 100644 tests/__snapshots__/zod/date-time-options.ts delete mode 100644 tests/__snapshots__/zod/enums.ts delete mode 100644 tests/__snapshots__/zod/import-from-subdirectory.ts delete mode 100644 tests/__snapshots__/zod/multiline-default.ts delete mode 100644 tests/__snapshots__/zod/nestedArrays.ts delete mode 100644 tests/__snapshots__/zod/nullable-any-of-refs.ts delete mode 100644 tests/__snapshots__/zod/nullable-oneof-enums.ts delete mode 100644 tests/__snapshots__/zod/preprocess.ts delete mode 100644 tests/__snapshots__/zod/strict-mode.ts delete mode 100644 tests/__snapshots__/zod/time-options.ts delete mode 100644 tests/__snapshots__/zod/translationAPI.ts delete mode 100644 tests/__snapshots__/zod/typed-arrays-tuples-v3-1.ts diff --git a/tests/__snapshots__/angular/http-resource-zod-disabled/model/index.zod.ts b/tests/__snapshots__/angular/http-resource-zod-disabled/model/index.zod.ts deleted file mode 100644 index ab1c161fce..0000000000 --- a/tests/__snapshots__/angular/http-resource-zod-disabled/model/index.zod.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export * from './cat.zod'; -export * from './createPetsBody.zod'; -export * from './createPetsHeaders.zod'; -export * from './createPetsParams.zod'; -export * from './dachshund.zod'; -export * from './dog.zod'; -export * from './error.zod'; -export * from './labradoodle.zod'; -export * from './listPetsHeaders.zod'; -export * from './listPetsParams.zod'; -export * from './pet.zod'; -export * from './petWithTag.zod'; -export * from './pets.zod'; diff --git a/tests/__snapshots__/angular/http-resource-zod/model/index.zod.ts b/tests/__snapshots__/angular/http-resource-zod/model/index.zod.ts deleted file mode 100644 index ab1c161fce..0000000000 --- a/tests/__snapshots__/angular/http-resource-zod/model/index.zod.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ - -export * from './cat.zod'; -export * from './createPetsBody.zod'; -export * from './createPetsHeaders.zod'; -export * from './createPetsParams.zod'; -export * from './dachshund.zod'; -export * from './dog.zod'; -export * from './error.zod'; -export * from './labradoodle.zod'; -export * from './listPetsHeaders.zod'; -export * from './listPetsParams.zod'; -export * from './pet.zod'; -export * from './petWithTag.zod'; -export * from './pets.zod'; diff --git a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/endpoints.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/endpoints.ts deleted file mode 100644 index ac182449a6..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/endpoints.ts +++ /dev/null @@ -1,544 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; - -import { - useCallback -} from 'react'; - -import type { - CreatePetsBody, - CreatePetsParams, - Error, - ListPetsParams, - Pet, - PetWithTag, - Pets -} from './model'; - -import { useCustomInstance } from '../../../mutators/use-custom-instance-with-second-parameter'; -type SecondParameter unknown> = Parameters[1]; - - - -/** - * @summary List all pets - */ -export const useListPetsHook = () => { - const listPets = useCustomInstance(); - - return useCallback(( - params: ListPetsParams, - options?: SecondParameter>,signal?: AbortSignal -) => { - return listPets( - {url: `/pets`, method: 'GET', - params, signal - }, - options); - }, [listPets]) - } - - - - -export const getListPetsQueryKey = (params?: ListPetsParams,) => { - return [ - `/pets`, ...(params ? [params] : []) - ] as const; - } - - -export const useListPetsQueryOptions = >>, TError = Error>(params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getListPetsQueryKey(params); - - const listPets = useListPetsHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => listPets(params, requestOptions, signal); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ListPetsQueryResult = NonNullable>>> -export type ListPetsQueryError = Error - - -export function useListPets>>, TError = Error>( - params: ListPetsParams, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, request?: SecondParameter>} - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary List all pets - */ - -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useListPetsQueryOptions(params,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - - - - - -/** - * @summary Create a pet - */ -export const useCreatePetsHook = () => { - const createPets = useCustomInstance(); - - return useCallback(( - createPetsBody: CreatePetsBody, - params: CreatePetsParams, - options?: SecondParameter>,signal?: AbortSignal -) => { - return createPets( - {url: `/pets`, method: 'POST', - headers: {'Content-Type': 'application/json', }, - data: createPetsBody, - params, signal - }, - options); - }, [createPets]) - } - - - -export const useCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, request?: SecondParameter>} -): UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext> => { - -const mutationKey = ['createPets']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - const createPets = useCreatePetsHook() - - - const mutationFn: MutationFunction>>, {data: CreatePetsBody;params: CreatePetsParams}> = (props) => { - const {data,params} = props ?? {}; - - return createPets(data,params,requestOptions) - } - - - - - - - return { mutationFn, ...mutationOptions }} - - export type CreatePetsMutationResult = NonNullable>>> - export type CreatePetsMutationBody = CreatePetsBody - export type CreatePetsMutationError = Error - - /** - * @summary Create a pet - */ -export const useCreatePets = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, request?: SecondParameter>} - , queryClient?: QueryClient): UseMutationResult< - Awaited>>, - TError, - {data: CreatePetsBody;params: CreatePetsParams}, - TContext - > => { - return useMutation(useCreatePetsMutationOptions(options), queryClient); - } - -/** - * @summary Info for a specific pet - */ -export const useShowPetByIdHook = () => { - const showPetById = useCustomInstance(); - - return useCallback(( - petId: string, - options?: SecondParameter>,signal?: AbortSignal -) => { - return showPetById( - {url: `/pets/${petId}`, method: 'GET', signal - }, - options); - }, [showPetById]) - } - - - - -export const getShowPetByIdQueryKey = (petId: string,) => { - return [ - `/pets/${petId}` - ] as const; - } - - -export const useShowPetByIdQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getShowPetByIdQueryKey(petId); - - const showPetById = useShowPetByIdHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => showPetById(petId, requestOptions, signal); - - - - - - return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ShowPetByIdQueryResult = NonNullable>>> -export type ShowPetByIdQueryError = Error - - -export function useShowPetById>>, TError = Error>( - petId: string, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, request?: SecondParameter>} - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary Info for a specific pet - */ - -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useShowPetByIdQueryOptions(petId,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - - - - - -/** - * @summary Deletes a specific pet - */ -export const useDeletePetByIdHook = () => { - const deletePetById = useCustomInstance(); - - return useCallback(( - petId: string, - options?: SecondParameter>,signal?: AbortSignal -) => { - return deletePetById( - {url: `/pets/${petId}`, method: 'DELETE', signal - }, - options); - }, [deletePetById]) - } - - - -export const useDeletePetByIdMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, request?: SecondParameter>} -): UseMutationOptions>>, TError,{petId: string}, TContext> => { - -const mutationKey = ['deletePetById']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - const deletePetById = useDeletePetByIdHook() - - - const mutationFn: MutationFunction>>, {petId: string}> = (props) => { - const {petId} = props ?? {}; - - return deletePetById(petId,requestOptions) - } - - - - - - - return { mutationFn, ...mutationOptions }} - - export type DeletePetByIdMutationResult = NonNullable>>> - - export type DeletePetByIdMutationError = Error - - /** - * @summary Deletes a specific pet - */ -export const useDeletePetById = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, request?: SecondParameter>} - , queryClient?: QueryClient): UseMutationResult< - Awaited>>, - TError, - {petId: string}, - TContext - > => { - return useMutation(useDeletePetByIdMutationOptions(options), queryClient); - } - -/** - * @summary health check - */ -export const useHealthCheckHook = () => { - const healthCheck = useCustomInstance(); - - return useCallback(( - - options?: SecondParameter>,signal?: AbortSignal -) => { - return healthCheck( - {url: `/health`, method: 'GET', signal - }, - options); - }, [healthCheck]) - } - - - - -export const getHealthCheckQueryKey = () => { - return [ - `/health` - ] as const; - } - - -export const useHealthCheckQueryOptions = >>, TError = Error>( options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); - - const healthCheck = useHealthCheckHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => healthCheck(requestOptions, signal); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type HealthCheckQueryResult = NonNullable>>> -export type HealthCheckQueryError = Error - - -export function useHealthCheck>>, TError = Error>( - options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, request?: SecondParameter>} - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useHealthCheck>>, TError = Error>( - options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useHealthCheck>>, TError = Error>( - options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary health check - */ - -export function useHealthCheck>>, TError = Error>( - options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useHealthCheckQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - - - - - -/** - * @summary combinate nullable and $ref - */ -export const useShowPetWithOwnerHook = () => { - const showPetWithOwner = useCustomInstance(); - - return useCallback(( - petId: string, - options?: SecondParameter>,signal?: AbortSignal -) => { - return showPetWithOwner( - {url: `/pets/${petId}/owner`, method: 'GET', signal - }, - options); - }, [showPetWithOwner]) - } - - - - -export const getShowPetWithOwnerQueryKey = (petId: string,) => { - return [ - `/pets/${petId}/owner` - ] as const; - } - - -export const useShowPetWithOwnerQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getShowPetWithOwnerQueryKey(petId); - - const showPetWithOwner = useShowPetWithOwnerHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => showPetWithOwner(petId, requestOptions, signal); - - - - - - return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ShowPetWithOwnerQueryResult = NonNullable>>> -export type ShowPetWithOwnerQueryError = Error - - -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, request?: SecondParameter>} - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary combinate nullable and $ref - */ - -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, request?: SecondParameter>} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useShowPetWithOwnerQueryOptions(petId,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} diff --git a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/cat.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/cat.ts deleted file mode 100644 index a78f78e772..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/cat.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/catType.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/catType.ts deleted file mode 100644 index a46984255b..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/catType.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/createPetsBody.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsBody.ts deleted file mode 100644 index 341621e02a..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsBody.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/createPetsParams.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsParams.ts deleted file mode 100644 index d64c76b414..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/createPetsSort.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsSort.ts deleted file mode 100644 index 0c2a50682f..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/createPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/dachshund.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshund.ts deleted file mode 100644 index 45d0bb5462..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshund.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/dachshundBreed.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshundBreed.ts deleted file mode 100644 index 2c13ab7bcb..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dachshundBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/dog.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dog.ts deleted file mode 100644 index a0a6d4dfb0..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dog.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/dogType.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dogType.ts deleted file mode 100644 index 7be3f5414d..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/dogType.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/error.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/error.ts deleted file mode 100644 index 3c00b1e9eb..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/error.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/index.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/index.ts deleted file mode 100644 index cb4321d79f..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Generated by orval v8.2.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'; \ No newline at end of file diff --git a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodle.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodle.ts deleted file mode 100644 index 5e5f6d017e..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodle.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/labradoodleBreed.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodleBreed.ts deleted file mode 100644 index 0377d09fd7..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/labradoodleBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/listPetsParams.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsParams.ts deleted file mode 100644 index 27134d9237..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/listPetsSort.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsSort.ts deleted file mode 100644 index 35dd7a4c5c..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/listPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/pet.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pet.ts deleted file mode 100644 index 3549e2bc2f..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pet.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/petCallingCode.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCallingCode.ts deleted file mode 100644 index 126aa75c75..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCallingCode.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/petCountry.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCountry.ts deleted file mode 100644 index 15e6fec3c8..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petCountry.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/petWithTag.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petWithTag.ts deleted file mode 100644 index ed930b0538..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/petWithTag.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator-with-second-parameter/model/pets.ts b/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pets.ts deleted file mode 100644 index 85b2d7b24c..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator-with-second-parameter/model/pets.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/endpoints.ts b/tests/__snapshots__/react-query/hook-mutator/endpoints.ts deleted file mode 100644 index c43a40a611..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/endpoints.ts +++ /dev/null @@ -1,540 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; - -import { - useCallback -} from 'react'; - -import type { - CreatePetsBody, - CreatePetsParams, - Error, - ListPetsParams, - Pet, - PetWithTag, - Pets -} from './model'; - -import { useCustomInstance } from '../../../mutators/use-custom-instance.js'; -/** - * @summary List all pets - */ -export const useListPetsHook = () => { - const listPets = useCustomInstance(); - - return useCallback(( - params: ListPetsParams, - signal?: AbortSignal -) => { - return listPets( - {url: `/pets`, method: 'GET', - params, signal - }, - ); - }, [listPets]) - } - - - - -export const getListPetsQueryKey = (params?: ListPetsParams,) => { - return [ - `/pets`, ...(params ? [params] : []) - ] as const; - } - - -export const useListPetsQueryOptions = >>, TError = Error>(params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getListPetsQueryKey(params); - - const listPets = useListPetsHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => listPets(params, signal); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ListPetsQueryResult = NonNullable>>> -export type ListPetsQueryError = Error - - -export function useListPets>>, TError = Error>( - params: ListPetsParams, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary List all pets - */ - -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useListPetsQueryOptions(params,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - - - - - -/** - * @summary Create a pet - */ -export const useCreatePetsHook = () => { - const createPets = useCustomInstance(); - - return useCallback(( - createPetsBody: CreatePetsBody, - params: CreatePetsParams, - signal?: AbortSignal -) => { - return createPets( - {url: `/pets`, method: 'POST', - headers: {'Content-Type': 'application/json', }, - data: createPetsBody, - params, signal - }, - ); - }, [createPets]) - } - - - -export const useCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } -): UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext> => { - -const mutationKey = ['createPets']; -const {mutation: mutationOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }}; - - const createPets = useCreatePetsHook() - - - const mutationFn: MutationFunction>>, {data: CreatePetsBody;params: CreatePetsParams}> = (props) => { - const {data,params} = props ?? {}; - - return createPets(data,params,) - } - - - - - - - return { mutationFn, ...mutationOptions }} - - export type CreatePetsMutationResult = NonNullable>>> - export type CreatePetsMutationBody = CreatePetsBody - export type CreatePetsMutationError = Error - - /** - * @summary Create a pet - */ -export const useCreatePets = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } - , queryClient?: QueryClient): UseMutationResult< - Awaited>>, - TError, - {data: CreatePetsBody;params: CreatePetsParams}, - TContext - > => { - return useMutation(useCreatePetsMutationOptions(options), queryClient); - } - -/** - * @summary Info for a specific pet - */ -export const useShowPetByIdHook = () => { - const showPetById = useCustomInstance(); - - return useCallback(( - petId: string, - signal?: AbortSignal -) => { - return showPetById( - {url: `/pets/${petId}`, method: 'GET', signal - }, - ); - }, [showPetById]) - } - - - - -export const getShowPetByIdQueryKey = (petId: string,) => { - return [ - `/pets/${petId}` - ] as const; - } - - -export const useShowPetByIdQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getShowPetByIdQueryKey(petId); - - const showPetById = useShowPetByIdHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => showPetById(petId, signal); - - - - - - return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ShowPetByIdQueryResult = NonNullable>>> -export type ShowPetByIdQueryError = Error - - -export function useShowPetById>>, TError = Error>( - petId: string, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary Info for a specific pet - */ - -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useShowPetByIdQueryOptions(petId,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - - - - - -/** - * @summary Deletes a specific pet - */ -export const useDeletePetByIdHook = () => { - const deletePetById = useCustomInstance(); - - return useCallback(( - petId: string, - signal?: AbortSignal -) => { - return deletePetById( - {url: `/pets/${petId}`, method: 'DELETE', signal - }, - ); - }, [deletePetById]) - } - - - -export const useDeletePetByIdMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } -): UseMutationOptions>>, TError,{petId: string}, TContext> => { - -const mutationKey = ['deletePetById']; -const {mutation: mutationOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }}; - - const deletePetById = useDeletePetByIdHook() - - - const mutationFn: MutationFunction>>, {petId: string}> = (props) => { - const {petId} = props ?? {}; - - return deletePetById(petId,) - } - - - - - - - return { mutationFn, ...mutationOptions }} - - export type DeletePetByIdMutationResult = NonNullable>>> - - export type DeletePetByIdMutationError = Error - - /** - * @summary Deletes a specific pet - */ -export const useDeletePetById = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } - , queryClient?: QueryClient): UseMutationResult< - Awaited>>, - TError, - {petId: string}, - TContext - > => { - return useMutation(useDeletePetByIdMutationOptions(options), queryClient); - } - -/** - * @summary health check - */ -export const useHealthCheckHook = () => { - const healthCheck = useCustomInstance(); - - return useCallback(( - - signal?: AbortSignal -) => { - return healthCheck( - {url: `/health`, method: 'GET', signal - }, - ); - }, [healthCheck]) - } - - - - -export const getHealthCheckQueryKey = () => { - return [ - `/health` - ] as const; - } - - -export const useHealthCheckQueryOptions = >>, TError = Error>( options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); - - const healthCheck = useHealthCheckHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => healthCheck(signal); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type HealthCheckQueryResult = NonNullable>>> -export type HealthCheckQueryError = Error - - -export function useHealthCheck>>, TError = Error>( - options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useHealthCheck>>, TError = Error>( - options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useHealthCheck>>, TError = Error>( - options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary health check - */ - -export function useHealthCheck>>, TError = Error>( - options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useHealthCheckQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - - - - - -/** - * @summary combinate nullable and $ref - */ -export const useShowPetWithOwnerHook = () => { - const showPetWithOwner = useCustomInstance(); - - return useCallback(( - petId: string, - signal?: AbortSignal -) => { - return showPetWithOwner( - {url: `/pets/${petId}/owner`, method: 'GET', signal - }, - ); - }, [showPetWithOwner]) - } - - - - -export const getShowPetWithOwnerQueryKey = (petId: string,) => { - return [ - `/pets/${petId}/owner` - ] as const; - } - - -export const useShowPetWithOwnerQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getShowPetWithOwnerQueryKey(petId); - - const showPetWithOwner = useShowPetWithOwnerHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => showPetWithOwner(petId, signal); - - - - - - return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ShowPetWithOwnerQueryResult = NonNullable>>> -export type ShowPetWithOwnerQueryError = Error - - -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary combinate nullable and $ref - */ - -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useShowPetWithOwnerQueryOptions(petId,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} diff --git a/tests/__snapshots__/react-query/hook-mutator/model/cat.ts b/tests/__snapshots__/react-query/hook-mutator/model/cat.ts deleted file mode 100644 index a78f78e772..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/cat.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/catType.ts b/tests/__snapshots__/react-query/hook-mutator/model/catType.ts deleted file mode 100644 index a46984255b..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/catType.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/createPetsBody.ts b/tests/__snapshots__/react-query/hook-mutator/model/createPetsBody.ts deleted file mode 100644 index 341621e02a..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/createPetsBody.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/createPetsParams.ts b/tests/__snapshots__/react-query/hook-mutator/model/createPetsParams.ts deleted file mode 100644 index d64c76b414..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/createPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/createPetsSort.ts b/tests/__snapshots__/react-query/hook-mutator/model/createPetsSort.ts deleted file mode 100644 index 0c2a50682f..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/createPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/dachshund.ts b/tests/__snapshots__/react-query/hook-mutator/model/dachshund.ts deleted file mode 100644 index 45d0bb5462..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/dachshund.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/dachshundBreed.ts b/tests/__snapshots__/react-query/hook-mutator/model/dachshundBreed.ts deleted file mode 100644 index 2c13ab7bcb..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/dachshundBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/dog.ts b/tests/__snapshots__/react-query/hook-mutator/model/dog.ts deleted file mode 100644 index a0a6d4dfb0..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/dog.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/dogType.ts b/tests/__snapshots__/react-query/hook-mutator/model/dogType.ts deleted file mode 100644 index 7be3f5414d..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/dogType.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/error.ts b/tests/__snapshots__/react-query/hook-mutator/model/error.ts deleted file mode 100644 index 3c00b1e9eb..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/error.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/index.ts b/tests/__snapshots__/react-query/hook-mutator/model/index.ts deleted file mode 100644 index cb4321d79f..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Generated by orval v8.2.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'; \ No newline at end of file diff --git a/tests/__snapshots__/react-query/hook-mutator/model/labradoodle.ts b/tests/__snapshots__/react-query/hook-mutator/model/labradoodle.ts deleted file mode 100644 index 5e5f6d017e..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/labradoodle.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/labradoodleBreed.ts b/tests/__snapshots__/react-query/hook-mutator/model/labradoodleBreed.ts deleted file mode 100644 index 0377d09fd7..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/labradoodleBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/listPetsParams.ts b/tests/__snapshots__/react-query/hook-mutator/model/listPetsParams.ts deleted file mode 100644 index 27134d9237..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/listPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/listPetsSort.ts b/tests/__snapshots__/react-query/hook-mutator/model/listPetsSort.ts deleted file mode 100644 index 35dd7a4c5c..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/listPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/pet.ts b/tests/__snapshots__/react-query/hook-mutator/model/pet.ts deleted file mode 100644 index 3549e2bc2f..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/pet.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/petCallingCode.ts b/tests/__snapshots__/react-query/hook-mutator/model/petCallingCode.ts deleted file mode 100644 index 126aa75c75..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/petCallingCode.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/petCountry.ts b/tests/__snapshots__/react-query/hook-mutator/model/petCountry.ts deleted file mode 100644 index 15e6fec3c8..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/petCountry.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/petWithTag.ts b/tests/__snapshots__/react-query/hook-mutator/model/petWithTag.ts deleted file mode 100644 index ed930b0538..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/petWithTag.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/hook-mutator/model/pets.ts b/tests/__snapshots__/react-query/hook-mutator/model/pets.ts deleted file mode 100644 index 85b2d7b24c..0000000000 --- a/tests/__snapshots__/react-query/hook-mutator/model/pets.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/endpoints.ts b/tests/__snapshots__/react-query/tag-hook-mutator/endpoints.ts deleted file mode 100644 index 6f0a408e39..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/endpoints.ts +++ /dev/null @@ -1,545 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; - -import axios from 'axios'; -import type { - AxiosError, - AxiosRequestConfig, - AxiosResponse -} from 'axios'; - -import { - useCallback -} from 'react'; - -import type { - CreatePetsBody, - CreatePetsParams, - Error, - ListPetsParams, - Pet, - PetWithTag, - Pets -} from './model'; - -import { useCustomInstance } from '../../../mutators/use-custom-instance'; -/** - * @summary List all pets - */ -export const useListPetsHook = () => { - const listPets = useCustomInstance(); - - return useCallback(( - params: ListPetsParams, - signal?: AbortSignal -) => { - return listPets( - {url: `/pets`, method: 'GET', - params, signal - }, - ); - }, [listPets]) - } - - - - -export const getListPetsQueryKey = (params?: ListPetsParams,) => { - return [ - `/pets`, ...(params ? [params] : []) - ] as const; - } - - -export const useListPetsQueryOptions = >>, TError = Error>(params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getListPetsQueryKey(params); - - const listPets = useListPetsHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => listPets(params, signal); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ListPetsQueryResult = NonNullable>>> -export type ListPetsQueryError = Error - - -export function useListPets>>, TError = Error>( - params: ListPetsParams, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary List all pets - */ - -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useListPetsQueryOptions(params,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - - - - - -/** - * @summary Create a pet - */ -export const useCreatePetsHook = () => { - const createPets = useCustomInstance(); - - return useCallback(( - createPetsBody: CreatePetsBody, - params: CreatePetsParams, - signal?: AbortSignal -) => { - return createPets( - {url: `/pets`, method: 'POST', - headers: {'Content-Type': 'application/json', }, - data: createPetsBody, - params, signal - }, - ); - }, [createPets]) - } - - - -export const useCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } -): UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext> => { - -const mutationKey = ['createPets']; -const {mutation: mutationOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }}; - - const createPets = useCreatePetsHook() - - - const mutationFn: MutationFunction>>, {data: CreatePetsBody;params: CreatePetsParams}> = (props) => { - const {data,params} = props ?? {}; - - return createPets(data,params,) - } - - - - - - - return { mutationFn, ...mutationOptions }} - - export type CreatePetsMutationResult = NonNullable>>> - export type CreatePetsMutationBody = CreatePetsBody - export type CreatePetsMutationError = Error - - /** - * @summary Create a pet - */ -export const useCreatePets = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } - , queryClient?: QueryClient): UseMutationResult< - Awaited>>, - TError, - {data: CreatePetsBody;params: CreatePetsParams}, - TContext - > => { - return useMutation(useCreatePetsMutationOptions(options), queryClient); - } - -/** - * @summary Info for a specific pet - */ -export const useShowPetByIdHook = () => { - const showPetById = useCustomInstance(); - - return useCallback(( - petId: string, - signal?: AbortSignal -) => { - return showPetById( - {url: `/pets/${petId}`, method: 'GET', signal - }, - ); - }, [showPetById]) - } - - - - -export const getShowPetByIdQueryKey = (petId: string,) => { - return [ - `/pets/${petId}` - ] as const; - } - - -export const useShowPetByIdQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getShowPetByIdQueryKey(petId); - - const showPetById = useShowPetByIdHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => showPetById(petId, signal); - - - - - - return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ShowPetByIdQueryResult = NonNullable>>> -export type ShowPetByIdQueryError = Error - - -export function useShowPetById>>, TError = Error>( - petId: string, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary Info for a specific pet - */ - -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useShowPetByIdQueryOptions(petId,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - - - - - -/** - * @summary Deletes a specific pet - */ -export const useDeletePetByIdHook = () => { - const deletePetById = useCustomInstance(); - - return useCallback(( - petId: string, - signal?: AbortSignal -) => { - return deletePetById( - {url: `/pets/${petId}`, method: 'DELETE', signal - }, - ); - }, [deletePetById]) - } - - - -export const useDeletePetByIdMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } -): UseMutationOptions>>, TError,{petId: string}, TContext> => { - -const mutationKey = ['deletePetById']; -const {mutation: mutationOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }}; - - const deletePetById = useDeletePetByIdHook() - - - const mutationFn: MutationFunction>>, {petId: string}> = (props) => { - const {petId} = props ?? {}; - - return deletePetById(petId,) - } - - - - - - - return { mutationFn, ...mutationOptions }} - - export type DeletePetByIdMutationResult = NonNullable>>> - - export type DeletePetByIdMutationError = Error - - /** - * @summary Deletes a specific pet - */ -export const useDeletePetById = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } - , queryClient?: QueryClient): UseMutationResult< - Awaited>>, - TError, - {petId: string}, - TContext - > => { - return useMutation(useDeletePetByIdMutationOptions(options), queryClient); - } - -/** - * @summary health check - */ -export const healthCheck = ( - options?: AxiosRequestConfig - ): Promise> => { - - - return axios.get( - `/health`,{ - responseType: 'text', - ...options,} - ); - } - - - - -export const getHealthCheckQueryKey = () => { - return [ - `/health` - ] as const; - } - - -export const getHealthCheckQueryOptions = >, TError = AxiosError>( options?: { query?:Partial>, TError, TData>>, axios?: AxiosRequestConfig} -) => { - -const {query: queryOptions, axios: axiosOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); - - - - const queryFn: QueryFunction>> = ({ signal }) => healthCheck({ signal, ...axiosOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } -} - -export type HealthCheckQueryResult = NonNullable>> -export type HealthCheckQueryError = AxiosError - - -export function useHealthCheck>, TError = AxiosError>( - options: { query:Partial>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - > , 'initialData' - >, axios?: AxiosRequestConfig} - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useHealthCheck>, TError = AxiosError>( - options?: { query?:Partial>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - > , 'initialData' - >, axios?: AxiosRequestConfig} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useHealthCheck>, TError = AxiosError>( - options?: { query?:Partial>, TError, TData>>, axios?: AxiosRequestConfig} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary health check - */ - -export function useHealthCheck>, TError = AxiosError>( - options?: { query?:Partial>, TError, TData>>, axios?: AxiosRequestConfig} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = getHealthCheckQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - - - - - -/** - * @summary combinate nullable and $ref - */ -export const useShowPetWithOwnerHook = () => { - const showPetWithOwner = useCustomInstance(); - - return useCallback(( - petId: string, - signal?: AbortSignal -) => { - return showPetWithOwner( - {url: `/pets/${petId}/owner`, method: 'GET', signal - }, - ); - }, [showPetWithOwner]) - } - - - - -export const getShowPetWithOwnerQueryKey = (petId: string,) => { - return [ - `/pets/${petId}/owner` - ] as const; - } - - -export const useShowPetWithOwnerQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getShowPetWithOwnerQueryKey(petId); - - const showPetWithOwner = useShowPetWithOwnerHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => showPetWithOwner(petId, signal); - - - - - - return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ShowPetWithOwnerQueryResult = NonNullable>>> -export type ShowPetWithOwnerQueryError = Error - - -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary combinate nullable and $ref - */ - -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useShowPetWithOwnerQueryOptions(petId,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} diff --git a/tests/__snapshots__/react-query/tag-hook-mutator/model/cat.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/cat.ts deleted file mode 100644 index a78f78e772..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/cat.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/catType.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/catType.ts deleted file mode 100644 index a46984255b..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/catType.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/createPetsBody.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsBody.ts deleted file mode 100644 index 341621e02a..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsBody.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/createPetsParams.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsParams.ts deleted file mode 100644 index d64c76b414..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/createPetsSort.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsSort.ts deleted file mode 100644 index 0c2a50682f..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/createPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/dachshund.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/dachshund.ts deleted file mode 100644 index 45d0bb5462..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/dachshund.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/dachshundBreed.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/dachshundBreed.ts deleted file mode 100644 index 2c13ab7bcb..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/dachshundBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/dog.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/dog.ts deleted file mode 100644 index a0a6d4dfb0..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/dog.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/dogType.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/dogType.ts deleted file mode 100644 index 7be3f5414d..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/dogType.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/error.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/error.ts deleted file mode 100644 index 3c00b1e9eb..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/error.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/index.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/index.ts deleted file mode 100644 index cb4321d79f..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Generated by orval v8.2.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'; \ No newline at end of file diff --git a/tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodle.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodle.ts deleted file mode 100644 index 5e5f6d017e..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodle.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/labradoodleBreed.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodleBreed.ts deleted file mode 100644 index 0377d09fd7..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/labradoodleBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/listPetsParams.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsParams.ts deleted file mode 100644 index 27134d9237..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/listPetsSort.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsSort.ts deleted file mode 100644 index 35dd7a4c5c..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/listPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/pet.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/pet.ts deleted file mode 100644 index 3549e2bc2f..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/pet.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/petCallingCode.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/petCallingCode.ts deleted file mode 100644 index 126aa75c75..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/petCallingCode.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/petCountry.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/petCountry.ts deleted file mode 100644 index 15e6fec3c8..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/petCountry.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/petWithTag.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/petWithTag.ts deleted file mode 100644 index ed930b0538..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/petWithTag.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/tag-hook-mutator/model/pets.ts b/tests/__snapshots__/react-query/tag-hook-mutator/model/pets.ts deleted file mode 100644 index 85b2d7b24c..0000000000 --- a/tests/__snapshots__/react-query/tag-hook-mutator/model/pets.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/endpoints.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/endpoints.ts deleted file mode 100644 index b27c48e197..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/endpoints.ts +++ /dev/null @@ -1,797 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; - -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; - - -/** - * @summary List all pets - */ -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' : value.toString()) - } - }); - - const stringifiedParams = normalizedParams.toString(); - - return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/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 const getListPetsQueryKey = (params?: ListPetsParams,) => { - return [ - `/pets`, ...(params ? [params] : []) - ] as const; - } - - -export const getListPetsQueryOptions = >, TError = Error>(params: ListPetsParams, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} -) => { - -const {query: queryOptions, fetch: fetchOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getListPetsQueryKey(params); - - - - const queryFn: QueryFunction>> = ({ signal }) => listPets(params, { signal, ...fetchOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } -} - -export type ListPetsQueryResult = NonNullable>> -export type ListPetsQueryError = Error - - -export function useListPets>, TError = Error>( - params: ListPetsParams, options: { query:Partial>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - > , 'initialData' - >, fetch?: RequestInit} - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useListPets>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - > , 'initialData' - >, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useListPets>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary List all pets - */ - -export function useListPets>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = getListPetsQueryOptions(params,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - -/** - * @summary List all pets - */ -export const prefetchListPetsQuery = async >, TError = Error>( - queryClient: QueryClient, params: ListPetsParams, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - - ): Promise => { - - const queryOptions = getListPetsQueryOptions(params,options) - - await queryClient.prefetchQuery(queryOptions); - - return queryClient; -} - - - - -/** - * @summary Create a pet - */ -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' : value.toString()) - } - }); - - const stringifiedParams = normalizedParams.toString(); - - return stringifiedParams.length > 0 ? `/pets?${stringifiedParams}` : `/pets` -} - -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 const getCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, fetch?: RequestInit} -): UseMutationOptions>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext> => { - -const mutationKey = ['createPets']; -const {mutation: mutationOptions, fetch: fetchOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, fetch: undefined}; - - - - - const mutationFn: MutationFunction>, {data: CreatePetsBody;params: CreatePetsParams}> = (props) => { - const {data,params} = props ?? {}; - - return createPets(data,params,fetchOptions) - } - - - - - - - return { mutationFn, ...mutationOptions }} - - export type CreatePetsMutationResult = NonNullable>> - export type CreatePetsMutationBody = CreatePetsBody - export type CreatePetsMutationError = Error - - /** - * @summary Create a pet - */ -export const useCreatePets = (options?: { mutation?:UseMutationOptions>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, fetch?: RequestInit} - , queryClient?: QueryClient): UseMutationResult< - Awaited>, - TError, - {data: CreatePetsBody;params: CreatePetsParams}, - TContext - > => { - return useMutation(getCreatePetsMutationOptions(options), queryClient); - } - -/** - * @summary Info for a specific pet - */ -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}` -} - -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 const getShowPetByIdQueryKey = (petId: string,) => { - return [ - `/pets/${petId}` - ] as const; - } - - -export const getShowPetByIdQueryOptions = >, TError = Error>(petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} -) => { - -const {query: queryOptions, fetch: fetchOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getShowPetByIdQueryKey(petId); - - - - const queryFn: QueryFunction>> = ({ signal }) => showPetById(petId, { signal, ...fetchOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } -} - -export type ShowPetByIdQueryResult = NonNullable>> -export type ShowPetByIdQueryError = Error - - -export function useShowPetById>, TError = Error>( - petId: string, options: { query:Partial>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - > , 'initialData' - >, fetch?: RequestInit} - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useShowPetById>, TError = Error>( - petId: string, options?: { query?:Partial>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - > , 'initialData' - >, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useShowPetById>, TError = Error>( - petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary Info for a specific pet - */ - -export function useShowPetById>, TError = Error>( - petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = getShowPetByIdQueryOptions(petId,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - -/** - * @summary Info for a specific pet - */ -export const prefetchShowPetByIdQuery = async >, TError = Error>( - queryClient: QueryClient, petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - - ): Promise => { - - const queryOptions = getShowPetByIdQueryOptions(petId,options) - - await queryClient.prefetchQuery(queryOptions); - - return queryClient; -} - - - - -/** - * @summary Deletes a specific pet - */ -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}` -} - -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) : {} - return { data, status: res.status, headers: res.headers } as deletePetByIdResponse -} - - - - -export const getDeletePetByIdMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{petId: string}, TContext>, fetch?: RequestInit} -): UseMutationOptions>, TError,{petId: string}, TContext> => { - -const mutationKey = ['deletePetById']; -const {mutation: mutationOptions, fetch: fetchOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, fetch: undefined}; - - - - - const mutationFn: MutationFunction>, {petId: string}> = (props) => { - const {petId} = props ?? {}; - - return deletePetById(petId,fetchOptions) - } - - - - - - - return { mutationFn, ...mutationOptions }} - - export type DeletePetByIdMutationResult = NonNullable>> - - export type DeletePetByIdMutationError = Error - - /** - * @summary Deletes a specific pet - */ -export const useDeletePetById = (options?: { mutation?:UseMutationOptions>, TError,{petId: string}, TContext>, fetch?: RequestInit} - , queryClient?: QueryClient): UseMutationResult< - Awaited>, - TError, - {petId: string}, - TContext - > => { - return useMutation(getDeletePetByIdMutationOptions(options), queryClient); - } - -/** - * @summary health check - */ -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` -} - -export const healthCheck = async ( options?: RequestInit): Promise => { - - const res = await fetch(getHealthCheckUrl(), - { - ...options, - method: 'GET' - - - } -) - - const body = [204, 205, 304].includes(res.status) ? null : await res.text(); - - const data: healthCheckResponse['data'] = body ? JSON.parse(body) : {} - return { data, status: res.status, headers: res.headers } as healthCheckResponse -} - - - - - -export const getHealthCheckQueryKey = () => { - return [ - `/health` - ] as const; - } - - -export const getHealthCheckQueryOptions = >, TError = Error>( options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} -) => { - -const {query: queryOptions, fetch: fetchOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); - - - - const queryFn: QueryFunction>> = ({ signal }) => healthCheck({ signal, ...fetchOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } -} - -export type HealthCheckQueryResult = NonNullable>> -export type HealthCheckQueryError = Error - - -export function useHealthCheck>, TError = Error>( - options: { query:Partial>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - > , 'initialData' - >, fetch?: RequestInit} - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useHealthCheck>, TError = Error>( - options?: { query?:Partial>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - > , 'initialData' - >, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useHealthCheck>, TError = Error>( - options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary health check - */ - -export function useHealthCheck>, TError = Error>( - options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = getHealthCheckQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - -/** - * @summary health check - */ -export const prefetchHealthCheckQuery = async >, TError = Error>( - queryClient: QueryClient, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - - ): Promise => { - - const queryOptions = getHealthCheckQueryOptions(options) - - await queryClient.prefetchQuery(queryOptions); - - return queryClient; -} - - - - -/** - * @summary combinate nullable and $ref - */ -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` -} - -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 -} - - - - - -export const getShowPetWithOwnerQueryKey = (petId: string,) => { - return [ - `/pets/${petId}/owner` - ] as const; - } - - -export const getShowPetWithOwnerQueryOptions = >, TError = Error>(petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} -) => { - -const {query: queryOptions, fetch: fetchOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getShowPetWithOwnerQueryKey(petId); - - - - const queryFn: QueryFunction>> = ({ signal }) => showPetWithOwner(petId, { signal, ...fetchOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } -} - -export type ShowPetWithOwnerQueryResult = NonNullable>> -export type ShowPetWithOwnerQueryError = Error - - -export function useShowPetWithOwner>, TError = Error>( - petId: string, options: { query:Partial>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - > , 'initialData' - >, fetch?: RequestInit} - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useShowPetWithOwner>, TError = Error>( - petId: string, options?: { query?:Partial>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - > , 'initialData' - >, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useShowPetWithOwner>, TError = Error>( - petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary combinate nullable and $ref - */ - -export function useShowPetWithOwner>, TError = Error>( - petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = getShowPetWithOwnerQueryOptions(petId,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - -/** - * @summary combinate nullable and $ref - */ -export const prefetchShowPetWithOwnerQuery = async >, TError = Error>( - queryClient: QueryClient, petId: string, options?: { query?:Partial>, TError, TData>>, fetch?: RequestInit} - - ): Promise => { - - const queryOptions = getShowPetWithOwnerQueryOptions(petId,options) - - await queryClient.prefetchQuery(queryOptions); - - return queryClient; -} diff --git a/tests/__snapshots__/react-query/use-prefetch-with-function/model/cat.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/cat.ts deleted file mode 100644 index a78f78e772..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/cat.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/catType.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/catType.ts deleted file mode 100644 index a46984255b..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/catType.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/createPetsBody.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsBody.ts deleted file mode 100644 index 341621e02a..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsBody.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/createPetsParams.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsParams.ts deleted file mode 100644 index d64c76b414..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/createPetsSort.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsSort.ts deleted file mode 100644 index 0c2a50682f..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/createPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/dachshund.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshund.ts deleted file mode 100644 index 45d0bb5462..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshund.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/dachshundBreed.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshundBreed.ts deleted file mode 100644 index 2c13ab7bcb..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/dachshundBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/dog.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dog.ts deleted file mode 100644 index a0a6d4dfb0..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/dog.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/dogType.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/dogType.ts deleted file mode 100644 index 7be3f5414d..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/dogType.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/error.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/error.ts deleted file mode 100644 index 3c00b1e9eb..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/error.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/index.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/index.ts deleted file mode 100644 index cb4321d79f..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Generated by orval v8.2.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'; \ No newline at end of file diff --git a/tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodle.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodle.ts deleted file mode 100644 index 5e5f6d017e..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodle.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/labradoodleBreed.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodleBreed.ts deleted file mode 100644 index 0377d09fd7..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/labradoodleBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/listPetsParams.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsParams.ts deleted file mode 100644 index 27134d9237..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/listPetsSort.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsSort.ts deleted file mode 100644 index 35dd7a4c5c..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/listPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/pet.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/pet.ts deleted file mode 100644 index 3549e2bc2f..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/pet.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/petCallingCode.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/petCallingCode.ts deleted file mode 100644 index 126aa75c75..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/petCallingCode.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/petCountry.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/petCountry.ts deleted file mode 100644 index 15e6fec3c8..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/petCountry.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/petWithTag.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/petWithTag.ts deleted file mode 100644 index ed930b0538..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/petWithTag.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-function/model/pets.ts b/tests/__snapshots__/react-query/use-prefetch-with-function/model/pets.ts deleted file mode 100644 index 85b2d7b24c..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-function/model/pets.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/endpoints.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/endpoints.ts deleted file mode 100644 index d4f908ea3e..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/endpoints.ts +++ /dev/null @@ -1,590 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import { - useMutation, - useQuery, - useQueryClient -} from '@tanstack/react-query'; -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; - -import { - useCallback -} from 'react'; - -import type { - CreatePetsBody, - CreatePetsParams, - Error, - ListPetsParams, - Pet, - PetWithTag, - Pets -} from './model'; - -import { useCustomInstance } from '../../../mutators/use-custom-instance'; -/** - * @summary List all pets - */ -export const useListPetsHook = () => { - const listPets = useCustomInstance(); - - return useCallback(( - params: ListPetsParams, - signal?: AbortSignal -) => { - return listPets( - {url: `/pets`, method: 'GET', - params, signal - }, - ); - }, [listPets]) - } - - - - -export const getListPetsQueryKey = (params?: ListPetsParams,) => { - return [ - `/pets`, ...(params ? [params] : []) - ] as const; - } - - -export const useListPetsQueryOptions = >>, TError = Error>(params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getListPetsQueryKey(params); - - const listPets = useListPetsHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => listPets(params, signal); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ListPetsQueryResult = NonNullable>>> -export type ListPetsQueryError = Error - - -export function useListPets>>, TError = Error>( - params: ListPetsParams, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary List all pets - */ - -export function useListPets>>, TError = Error>( - params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useListPetsQueryOptions(params,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - -/** - * @summary List all pets - */ -export const usePrefetchListPetsQuery = >>, TError = Error>(params: ListPetsParams, options?: { query?:Partial>>, TError, TData>>, } -) => { - const queryClient = useQueryClient(); - const queryOptions = useListPetsQueryOptions(params,options) - return useCallback(async (): Promise => { - await queryClient.prefetchQuery(queryOptions) - return queryClient; - },[queryClient, queryOptions]); -}; - - - - -/** - * @summary Create a pet - */ -export const useCreatePetsHook = () => { - const createPets = useCustomInstance(); - - return useCallback(( - createPetsBody: CreatePetsBody, - params: CreatePetsParams, - signal?: AbortSignal -) => { - return createPets( - {url: `/pets`, method: 'POST', - headers: {'Content-Type': 'application/json', }, - data: createPetsBody, - params, signal - }, - ); - }, [createPets]) - } - - - -export const useCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } -): UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext> => { - -const mutationKey = ['createPets']; -const {mutation: mutationOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }}; - - const createPets = useCreatePetsHook() - - - const mutationFn: MutationFunction>>, {data: CreatePetsBody;params: CreatePetsParams}> = (props) => { - const {data,params} = props ?? {}; - - return createPets(data,params,) - } - - - - - - - return { mutationFn, ...mutationOptions }} - - export type CreatePetsMutationResult = NonNullable>>> - export type CreatePetsMutationBody = CreatePetsBody - export type CreatePetsMutationError = Error - - /** - * @summary Create a pet - */ -export const useCreatePets = (options?: { mutation?:UseMutationOptions>>, TError,{data: CreatePetsBody;params: CreatePetsParams}, TContext>, } - , queryClient?: QueryClient): UseMutationResult< - Awaited>>, - TError, - {data: CreatePetsBody;params: CreatePetsParams}, - TContext - > => { - return useMutation(useCreatePetsMutationOptions(options), queryClient); - } - -/** - * @summary Info for a specific pet - */ -export const useShowPetByIdHook = () => { - const showPetById = useCustomInstance(); - - return useCallback(( - petId: string, - signal?: AbortSignal -) => { - return showPetById( - {url: `/pets/${petId}`, method: 'GET', signal - }, - ); - }, [showPetById]) - } - - - - -export const getShowPetByIdQueryKey = (petId: string,) => { - return [ - `/pets/${petId}` - ] as const; - } - - -export const useShowPetByIdQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getShowPetByIdQueryKey(petId); - - const showPetById = useShowPetByIdHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => showPetById(petId, signal); - - - - - - return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ShowPetByIdQueryResult = NonNullable>>> -export type ShowPetByIdQueryError = Error - - -export function useShowPetById>>, TError = Error>( - petId: string, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary Info for a specific pet - */ - -export function useShowPetById>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useShowPetByIdQueryOptions(petId,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - -/** - * @summary Info for a specific pet - */ -export const usePrefetchShowPetByIdQuery = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } -) => { - const queryClient = useQueryClient(); - const queryOptions = useShowPetByIdQueryOptions(petId,options) - return useCallback(async (): Promise => { - await queryClient.prefetchQuery(queryOptions) - return queryClient; - },[queryClient, queryOptions]); -}; - - - - -/** - * @summary Deletes a specific pet - */ -export const useDeletePetByIdHook = () => { - const deletePetById = useCustomInstance(); - - return useCallback(( - petId: string, - signal?: AbortSignal -) => { - return deletePetById( - {url: `/pets/${petId}`, method: 'DELETE', signal - }, - ); - }, [deletePetById]) - } - - - -export const useDeletePetByIdMutationOptions = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } -): UseMutationOptions>>, TError,{petId: string}, TContext> => { - -const mutationKey = ['deletePetById']; -const {mutation: mutationOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }}; - - const deletePetById = useDeletePetByIdHook() - - - const mutationFn: MutationFunction>>, {petId: string}> = (props) => { - const {petId} = props ?? {}; - - return deletePetById(petId,) - } - - - - - - - return { mutationFn, ...mutationOptions }} - - export type DeletePetByIdMutationResult = NonNullable>>> - - export type DeletePetByIdMutationError = Error - - /** - * @summary Deletes a specific pet - */ -export const useDeletePetById = (options?: { mutation?:UseMutationOptions>>, TError,{petId: string}, TContext>, } - , queryClient?: QueryClient): UseMutationResult< - Awaited>>, - TError, - {petId: string}, - TContext - > => { - return useMutation(useDeletePetByIdMutationOptions(options), queryClient); - } - -/** - * @summary health check - */ -export const useHealthCheckHook = () => { - const healthCheck = useCustomInstance(); - - return useCallback(( - - signal?: AbortSignal -) => { - return healthCheck( - {url: `/health`, method: 'GET', signal - }, - ); - }, [healthCheck]) - } - - - - -export const getHealthCheckQueryKey = () => { - return [ - `/health` - ] as const; - } - - -export const useHealthCheckQueryOptions = >>, TError = Error>( options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); - - const healthCheck = useHealthCheckHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => healthCheck(signal); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type HealthCheckQueryResult = NonNullable>>> -export type HealthCheckQueryError = Error - - -export function useHealthCheck>>, TError = Error>( - options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useHealthCheck>>, TError = Error>( - options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useHealthCheck>>, TError = Error>( - options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary health check - */ - -export function useHealthCheck>>, TError = Error>( - options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useHealthCheckQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - -/** - * @summary health check - */ -export const usePrefetchHealthCheckQuery = >>, TError = Error>( options?: { query?:Partial>>, TError, TData>>, } -) => { - const queryClient = useQueryClient(); - const queryOptions = useHealthCheckQueryOptions(options) - return useCallback(async (): Promise => { - await queryClient.prefetchQuery(queryOptions) - return queryClient; - },[queryClient, queryOptions]); -}; - - - - -/** - * @summary combinate nullable and $ref - */ -export const useShowPetWithOwnerHook = () => { - const showPetWithOwner = useCustomInstance(); - - return useCallback(( - petId: string, - signal?: AbortSignal -) => { - return showPetWithOwner( - {url: `/pets/${petId}/owner`, method: 'GET', signal - }, - ); - }, [showPetWithOwner]) - } - - - - -export const getShowPetWithOwnerQueryKey = (petId: string,) => { - return [ - `/pets/${petId}/owner` - ] as const; - } - - -export const useShowPetWithOwnerQueryOptions = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } -) => { - -const {query: queryOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getShowPetWithOwnerQueryKey(petId); - - const showPetWithOwner = useShowPetWithOwnerHook(); - - const queryFn: QueryFunction>>> = ({ signal }) => showPetWithOwner(petId, signal); - - - - - - return { queryKey, queryFn, enabled: !!(petId), ...queryOptions} as UseQueryOptions>>, TError, TData> & { queryKey: DataTag } -} - -export type ShowPetWithOwnerQueryResult = NonNullable>>> -export type ShowPetWithOwnerQueryError = Error - - -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options: { query:Partial>>, TError, TData>> & Pick< - DefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): DefinedUseQueryResult & { queryKey: DataTag } -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>> & Pick< - UndefinedInitialDataOptions< - Awaited>>, - TError, - Awaited>> - > , 'initialData' - >, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } -/** - * @summary combinate nullable and $ref - */ - -export function useShowPetWithOwner>>, TError = Error>( - petId: string, options?: { query?:Partial>>, TError, TData>>, } - , queryClient?: QueryClient - ): UseQueryResult & { queryKey: DataTag } { - - const queryOptions = useShowPetWithOwnerQueryOptions(petId,options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; - - return { ...query, queryKey: queryOptions.queryKey }; -} - -/** - * @summary combinate nullable and $ref - */ -export const usePrefetchShowPetWithOwnerQuery = >>, TError = Error>(petId: string, options?: { query?:Partial>>, TError, TData>>, } -) => { - const queryClient = useQueryClient(); - const queryOptions = useShowPetWithOwnerQueryOptions(petId,options) - return useCallback(async (): Promise => { - await queryClient.prefetchQuery(queryOptions) - return queryClient; - },[queryClient, queryOptions]); -}; diff --git a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/cat.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/cat.ts deleted file mode 100644 index a78f78e772..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/cat.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/catType.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/catType.ts deleted file mode 100644 index a46984255b..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/catType.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/createPetsBody.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsBody.ts deleted file mode 100644 index 341621e02a..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsBody.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/createPetsParams.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsParams.ts deleted file mode 100644 index d64c76b414..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/createPetsSort.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsSort.ts deleted file mode 100644 index 0c2a50682f..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/createPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/dachshund.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshund.ts deleted file mode 100644 index 45d0bb5462..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshund.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/dachshundBreed.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshundBreed.ts deleted file mode 100644 index 2c13ab7bcb..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dachshundBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/dog.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dog.ts deleted file mode 100644 index a0a6d4dfb0..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dog.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/dogType.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dogType.ts deleted file mode 100644 index 7be3f5414d..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/dogType.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/error.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/error.ts deleted file mode 100644 index 3c00b1e9eb..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/error.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/index.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/index.ts deleted file mode 100644 index cb4321d79f..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Generated by orval v8.2.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'; \ No newline at end of file diff --git a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodle.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodle.ts deleted file mode 100644 index 5e5f6d017e..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodle.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/labradoodleBreed.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodleBreed.ts deleted file mode 100644 index 0377d09fd7..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/labradoodleBreed.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/listPetsParams.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsParams.ts deleted file mode 100644 index 27134d9237..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsParams.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/listPetsSort.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsSort.ts deleted file mode 100644 index 35dd7a4c5c..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/listPetsSort.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/pet.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pet.ts deleted file mode 100644 index 3549e2bc2f..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pet.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/petCallingCode.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCallingCode.ts deleted file mode 100644 index 126aa75c75..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCallingCode.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/petCountry.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCountry.ts deleted file mode 100644 index 15e6fec3c8..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petCountry.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/petWithTag.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petWithTag.ts deleted file mode 100644 index ed930b0538..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/petWithTag.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.2.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__/react-query/use-prefetch-with-hook-mutator/model/pets.ts b/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pets.ts deleted file mode 100644 index 85b2d7b24c..0000000000 --- a/tests/__snapshots__/react-query/use-prefetch-with-hook-mutator/model/pets.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Generated by orval v8.2.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__/zod/circularReferences.ts b/tests/__snapshots__/zod/circularReferences.ts deleted file mode 100644 index 82a96742f7..0000000000 --- a/tests/__snapshots__/zod/circularReferences.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Circular references - * OpenAPI spec version: 0.0.0 - */ -import * as zod from 'zod'; - -/** - * @summary Example - */ -export const GetExampleResponse = zod.object({ - "id": zod.number().optional(), - "name": zod.string().optional(), - "child": zod.unknown().optional() -}) - - -/** - * @summary Node with required child - */ -export const GetNodeWithRequiredChildResponse = zod.object({ - "id": zod.number(), - "name": zod.string(), - "child": zod.unknown() -}) - - -/** - * @summary Add list - */ -export const addListQueryLimitRegExp = new RegExp('^\\+\\d{10, 15}'); - - -export const AddListQueryParams = zod.object({ - "limit": zod.string().regex(addListQueryLimitRegExp).optional().describe('How many items to return at one time (max 100)'), - "birthdate": zod.string().date().optional().describe('birth date') -}) - -export const addListBodyListItemMax = 10; - -export const addListBodyListMax = 10; - - - -export const AddListBody = zod.object({ - "list": zod.array(zod.number().min(1).max(addListBodyListItemMax)).min(1).max(addListBodyListMax) -}) diff --git a/tests/__snapshots__/zod/coerce.ts b/tests/__snapshots__/zod/coerce.ts deleted file mode 100644 index 4e42b8371e..0000000000 --- a/tests/__snapshots__/zod/coerce.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Circular references - * OpenAPI spec version: 0.0.0 - */ -import * as zod from 'zod'; - -/** - * @summary Example - */ -export const GetExampleResponse = zod.object({ - "id": zod.coerce.number().optional(), - "name": zod.coerce.string().optional(), - "child": zod.unknown().optional() -}) - - -/** - * @summary Node with required child - */ -export const GetNodeWithRequiredChildResponse = zod.object({ - "id": zod.coerce.number(), - "name": zod.coerce.string(), - "child": zod.unknown() -}) - - -/** - * @summary Add list - */ -export const addListQueryLimitRegExpTwo = new RegExp('^\\+\\d{10, 15}'); - - -export const AddListQueryParams = zod.object({ - "limit": zod.coerce.string().regex(addListQueryLimitRegExpTwo).optional().describe('How many items to return at one time (max 100)'), - "birthdate": zod.coerce.string().date().optional().describe('birth date') -}) - -export const addListBodyListItemMaxTwo = 10; - -export const addListBodyListMaxTwo = 10; - - - -export const AddListBody = zod.object({ - "list": zod.array(zod.coerce.number().min(1).max(addListBodyListItemMaxTwo)).min(1).max(addListBodyListMaxTwo) -}) diff --git a/tests/__snapshots__/zod/date-time-options.ts b/tests/__snapshots__/zod/date-time-options.ts deleted file mode 100644 index 75408dceea..0000000000 --- a/tests/__snapshots__/zod/date-time-options.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * format test - * OpenAPI spec version: 1.0.0 - */ -import * as zod from 'zod'; - -/** - * @summary Info for a specific pet - */ -export const ShowPetByIdParams = zod.object({ - "petId": zod.string().describe('The id of the pet to retrieve'), - "testId": zod.string().describe('The id of the pet to retrieve') -}) - -export const ShowPetByIdResponse = zod.object({ - "id": zod.number().optional(), - "birthDate": zod.string().date(), - "createdAt": zod.string().datetime({"offset":true,"precision":3}), - "age": zod.number().optional(), - "legCount": zod.number().optional(), - "weight": zod.number().optional(), - "height": zod.number().optional(), - "chipNumbers": zod.array(zod.number()).optional(), - "feedingTime": zod.string().time({}).optional() -}) diff --git a/tests/__snapshots__/zod/enums.ts b/tests/__snapshots__/zod/enums.ts deleted file mode 100644 index bb50c2d2d8..0000000000 --- a/tests/__snapshots__/zod/enums.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Enums - * OpenAPI spec version: 1.0.0 - */ -import * as zod from 'zod'; - -/** - * @summary sample cat - */ -export const GetApiCatResponseItem = zod.union([zod.literal(1),zod.literal(2),zod.literal(3)]) -export const GetApiCatResponse = zod.array(GetApiCatResponseItem) - - -/** - * @summary sample required cat - */ -export const GetApiRequiredCatResponse = zod.object({ - "petsRequested": zod.array(zod.object({ - "colours": zod.array(zod.enum(['BLACK', 'BROWN', 'WHITE', 'GREY'])) -})).optional() -}) - - -/** - * @summary sample dog - */ -export const GetApiDogResponse = zod.object({ - "group": zod.union([zod.literal(1),zod.literal(2),zod.literal(3)]).optional(), - "petsRequested": zod.array(zod.object({ - "colour": zod.enum(['BLACK', 'BROWN']).optional() -})).optional() -}) - - -/** - * @summary sample required dog - */ -export const GetApiRequiredDogResponse = zod.object({ - "petsRequested": zod.array(zod.object({ - "colour": zod.enum(['BLACK', 'BROWN']) -})).optional() -}) - - -/** - * @summary sample duck - */ -export const GetApiDuckResponse = zod.object({ - "petsRequested": zod.array(zod.string()).optional() -}) - - -/** - * @summary sample cat dog - */ -export const GetApiCatDogResponse = zod.union([zod.literal(1),zod.literal('2'),zod.literal('a')]) diff --git a/tests/__snapshots__/zod/import-from-subdirectory.ts b/tests/__snapshots__/zod/import-from-subdirectory.ts deleted file mode 100644 index 3569236c14..0000000000 --- a/tests/__snapshots__/zod/import-from-subdirectory.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import * as zod from 'zod'; - -export const PostPetsResponse = zod.object({ - "id": zod.number(), - "file": zod.object({ - "id": zod.number() -}).optional() -}) - - -export const GetPetsResponse = zod.object({ - "id": zod.number() -}) diff --git a/tests/__snapshots__/zod/multiline-default.ts b/tests/__snapshots__/zod/multiline-default.ts deleted file mode 100644 index 2d41b8d08a..0000000000 --- a/tests/__snapshots__/zod/multiline-default.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Orval Multiline Default Repro - * OpenAPI spec version: 1.0.0 - */ -import * as zod from 'zod'; - -/** - * @summary Endpoint demonstrating multiline default value - */ -export const createMultilineDefaultBodyRerankPromptDefault = `# Task -You are a helpful assistant. Rerank the following information blocks according to their relevance to the given question. -Return only the indices of the most relevant blocks in descending order of relevance, using the exact response format specified below. - -# Question -{question} - -# Information Blocks -{blocks}`; - -export const CreateMultilineDefaultBody = zod.object({ - "rerank_prompt": zod.union([zod.string(),zod.null()]).default(createMultilineDefaultBodyRerankPromptDefault).describe('Prompt text with a multiline default value.') -}) diff --git a/tests/__snapshots__/zod/nestedArrays.ts b/tests/__snapshots__/zod/nestedArrays.ts deleted file mode 100644 index 8f8e165239..0000000000 --- a/tests/__snapshots__/zod/nestedArrays.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * NestedArrays - * OpenAPI spec version: 1.0.0 - */ -import * as zod from 'zod'; - -/** - * @summary sample - */ -export const postApiSampleResponseItemsItemMin = 2; -export const postApiSampleResponseItemsItemMax = 5; - - - -export const PostApiSampleResponse = zod.object({ - "items": zod.array(zod.array(zod.string()).min(postApiSampleResponseItemsItemMin).max(postApiSampleResponseItemsItemMax)) -}) diff --git a/tests/__snapshots__/zod/nullable-any-of-refs.ts b/tests/__snapshots__/zod/nullable-any-of-refs.ts deleted file mode 100644 index 2e8399691d..0000000000 --- a/tests/__snapshots__/zod/nullable-any-of-refs.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Nullable AnyOf Refs - * OpenAPI spec version: v1.0 - */ -import * as zod from 'zod'; - -export const GetPetsResponseItem = zod.object({ - "petId": zod.union([zod.string().nullable(),zod.string().nullable()]).nullish() -}) -export const GetPetsResponse = zod.array(GetPetsResponseItem) - - -export const GetAnimalsResponseItem = zod.object({ - "animalId": zod.union([zod.string().nullable(),zod.string().nullable(),zod.string().uuid().nullable()]).nullish(), - "secondaryId": zod.union([zod.string().nullable(),zod.string().nullable()]).nullish() -}) -export const GetAnimalsResponse = zod.array(GetAnimalsResponseItem) - - -export const GetNestedAnimalsResponseItem = zod.object({ - "nested": zod.object({ - "animalId": zod.union([zod.string().nullable(),zod.string().nullable(),zod.string().uuid().nullable()]).nullish(), - "petId": zod.union([zod.string().nullable(),zod.string().nullable()]).nullish() -}).optional() -}) -export const GetNestedAnimalsResponse = zod.array(GetNestedAnimalsResponseItem) - - -export const GetMixedNullableResponseItem = zod.object({ - "mixedId": zod.union([zod.string().nullable(),zod.string().nullable(),zod.string().uuid()]).nullish() -}) -export const GetMixedNullableResponse = zod.array(GetMixedNullableResponseItem) - - -export const GetMixedTypesResponseItem = zod.object({ - "mixedAnyOf": zod.union([zod.string().nullable(),zod.number().nullable(),zod.number().nullable(),zod.boolean().nullable()]).nullish(), - "mixedTypesNotNull": zod.union([zod.number(),zod.number(),zod.string().uuid()]).nullish() -}) -export const GetMixedTypesResponse = zod.array(GetMixedTypesResponseItem) diff --git a/tests/__snapshots__/zod/nullable-oneof-enums.ts b/tests/__snapshots__/zod/nullable-oneof-enums.ts deleted file mode 100644 index 2f383e580e..0000000000 --- a/tests/__snapshots__/zod/nullable-oneof-enums.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Nullable OneOf Enums - * Test case for issue - * OpenAPI spec version: 1.0.0 - */ -import * as zod from 'zod'; - -export const GetItemsResponseItem = zod.object({ - "hello": zod.union([zod.enum(['HI', 'OHA']),zod.enum(['']),zod.literal(null)]).nullish() -}) -export const GetItemsResponse = zod.array(GetItemsResponseItem) - - -export const GetItemsWithMultiplePropsResponseItem = zod.object({ - "hello": zod.union([zod.enum(['HI', 'OHA']),zod.enum(['']),zod.literal(null)]).nullish(), - "world": zod.union([zod.union([zod.literal(1),zod.literal(2),zod.literal(3)]),zod.union([zod.literal(true),zod.literal(false)])]).nullish(), - "optional": zod.union([zod.enum(['HI', 'OHA']),zod.enum([''])]).nullish() -}) -export const GetItemsWithMultiplePropsResponse = zod.array(GetItemsWithMultiplePropsResponseItem) - - -export const GetNestedItemsResponseItem = zod.object({ - "nested": zod.object({ - "hello": zod.union([zod.enum(['HI', 'OHA']),zod.enum(['']),zod.literal(null)]).nullish(), - "world": zod.union([zod.union([zod.literal(1),zod.literal(2),zod.literal(3)]),zod.union([zod.literal(true),zod.literal(false)])]).nullish() -}).optional() -}) -export const GetNestedItemsResponse = zod.array(GetNestedItemsResponseItem) - - -export const GetMixedEnumItemsResponseItem = zod.object({ - "mixed": zod.union([zod.enum(['HI', 'OHA']),zod.enum(['']),zod.enum(['ALWAYS', 'NEVER'])]).nullish() -}) -export const GetMixedEnumItemsResponse = zod.array(GetMixedEnumItemsResponseItem) - - -export const GetMixedTypeEnumsResponseItem = zod.object({ - "stringEnum": zod.union([zod.enum(['HI', 'OHA']),zod.enum([''])]).nullish(), - "numberEnum": zod.union([zod.union([zod.literal(1.5),zod.literal(2.5),zod.literal(3.5)]).nullable(),zod.union([zod.literal(100.1),zod.literal(200.2)])]).nullish(), - "integerEnum": zod.union([zod.union([zod.literal(10),zod.literal(20),zod.literal(30)]).nullable(),zod.union([zod.literal(1000),zod.literal(2000)])]).nullish(), - "booleanEnum": zod.union([zod.union([zod.literal(true),zod.literal(false)]).nullable(),zod.literal(true)]).nullish() -}) -export const GetMixedTypeEnumsResponse = zod.array(GetMixedTypeEnumsResponseItem) diff --git a/tests/__snapshots__/zod/preprocess.ts b/tests/__snapshots__/zod/preprocess.ts deleted file mode 100644 index ad3fb472bb..0000000000 --- a/tests/__snapshots__/zod/preprocess.ts +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Swagger Petstore - * OpenAPI spec version: 1.0.0 - */ -import * as zod from 'zod'; - -import { stripNill } from '../../mutators/zod-preprocess'; -/** - * @summary List all pets - */ -export const ListPetsQueryParams = zod.preprocess(stripNill, zod.object({ - "limit": zod.string().optional().describe('How many items to return at one time (max 100)'), - "sort": zod.enum(['name', '-name', 'email', '-email']).describe('Which property to sort by?\nExample: name sorts ASC while -name sorts DESC.\n') -})) - -export const ListPetsHeader = zod.preprocess(stripNill, zod.object({ - "X-EXAMPLE": zod.enum(['ONE', 'TWO', 'THREE']).describe('Header parameters') -})) - - -/** - * @summary Create a pet - */ -export const CreatePetsQueryParams = zod.preprocess(stripNill, zod.object({ - "limit": zod.string().optional().describe('How many items to return at one time (max 100)'), - "sort": zod.enum(['name', '-name', 'email', '-email']).describe('Which property to sort by?\nExample: name sorts ASC while -name sorts DESC.\n') -})) - -export const CreatePetsHeader = zod.preprocess(stripNill, zod.object({ - "X-EXAMPLE": zod.enum(['ONE', 'TWO', 'THREE']).describe('Header parameters') -})) - -export const CreatePetsBody = zod.preprocess(stripNill, zod.object({ - "name": zod.string(), - "tag": zod.string() -})) - -export const CreatePetsResponse = zod.preprocess(stripNill, zod.union([zod.union([zod.object({ - "cuteness": zod.number(), - "breed": zod.enum(['Labradoodle']) -}),zod.object({ - "length": zod.number(), - "breed": zod.enum(['Dachshund']) -})]).and(zod.object({ - "barksPerMinute": zod.number().optional(), - "type": zod.enum(['dog']) -})),zod.object({ - "petsRequested": zod.number().optional(), - "type": zod.enum(['cat']) -})]).and(zod.object({ - "@id": zod.string().optional(), - "id": zod.number(), - "name": zod.string(), - "tag": zod.string().optional(), - "email": zod.string().email().optional(), - "callingCode": zod.enum(['+33', '+420', '+33']).optional(), - "country": zod.enum(['People\'s Republic of China', 'Uruguay']).optional() -}))) - - -/** - * @summary Info for a specific pet - */ -export const ShowPetByIdParams = zod.preprocess(stripNill, zod.object({ - "petId": zod.string().describe('The id of the pet to retrieve'), - "testId": zod.string().describe('The id of the pet to retrieve') -})) - -export const ShowPetByIdResponse = zod.preprocess(stripNill, zod.union([zod.union([zod.object({ - "cuteness": zod.number(), - "breed": zod.enum(['Labradoodle']) -}),zod.object({ - "length": zod.number(), - "breed": zod.enum(['Dachshund']) -})]).and(zod.object({ - "barksPerMinute": zod.number().optional(), - "type": zod.enum(['dog']) -})),zod.object({ - "petsRequested": zod.number().optional(), - "type": zod.enum(['cat']) -})]).and(zod.object({ - "@id": zod.string().optional(), - "id": zod.number(), - "name": zod.string(), - "tag": zod.string().optional(), - "email": zod.string().email().optional(), - "callingCode": zod.enum(['+33', '+420', '+33']).optional(), - "country": zod.enum(['People\'s Republic of China', 'Uruguay']).optional() -}))) - - -/** - * @summary Deletes a specific pet - */ -export const DeletePetByIdParams = zod.preprocess(stripNill, zod.object({ - "petId": zod.string().describe('The id of the pet to delete') -})) - - -/** - * @summary combinate nullable and $ref - */ -export const ShowPetWithOwnerParams = zod.preprocess(stripNill, zod.object({ - "petId": zod.string().describe('The id of the pet') -})) - -export const ShowPetWithOwnerResponse = zod.preprocess(stripNill, zod.object({ - "tag": zod.string(), - "pet": zod.union([zod.union([zod.object({ - "cuteness": zod.number(), - "breed": zod.enum(['Labradoodle']) -}),zod.object({ - "length": zod.number(), - "breed": zod.enum(['Dachshund']) -})]).and(zod.object({ - "barksPerMinute": zod.number().optional(), - "type": zod.enum(['dog']) -})),zod.object({ - "petsRequested": zod.number().optional(), - "type": zod.enum(['cat']) -})]).and(zod.object({ - "@id": zod.string().optional(), - "id": zod.number(), - "name": zod.string(), - "tag": zod.string().optional(), - "email": zod.string().email().optional(), - "callingCode": zod.enum(['+33', '+420', '+33']).optional(), - "country": zod.enum(['People\'s Republic of China', 'Uruguay']).optional() -})).nullable() -})) diff --git a/tests/__snapshots__/zod/strict-mode.ts b/tests/__snapshots__/zod/strict-mode.ts deleted file mode 100644 index eeedbe570b..0000000000 --- a/tests/__snapshots__/zod/strict-mode.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Circular references - * OpenAPI spec version: 0.0.0 - */ -import * as zod from 'zod'; - -/** - * @summary Example - */ -export const GetExampleResponse = zod.object({ - "id": zod.number().optional(), - "name": zod.string().optional(), - "child": zod.unknown().optional() -}).strict() - - -/** - * @summary Node with required child - */ -export const GetNodeWithRequiredChildResponse = zod.object({ - "id": zod.number(), - "name": zod.string(), - "child": zod.unknown() -}).strict() - - -/** - * @summary Add list - */ -export const addListQueryLimitRegExpOne = new RegExp('^\\+\\d{10, 15}'); - - -export const AddListQueryParams = zod.object({ - "limit": zod.string().regex(addListQueryLimitRegExpOne).optional().describe('How many items to return at one time (max 100)'), - "birthdate": zod.string().date().optional().describe('birth date') -}).strict() - -export const addListBodyListItemMaxOne = 10; - -export const addListBodyListMaxOne = 10; - - - -export const AddListBody = zod.object({ - "list": zod.array(zod.number().min(1).max(addListBodyListItemMaxOne)).min(1).max(addListBodyListMaxOne) -}).strict() diff --git a/tests/__snapshots__/zod/time-options.ts b/tests/__snapshots__/zod/time-options.ts deleted file mode 100644 index 992cea95ec..0000000000 --- a/tests/__snapshots__/zod/time-options.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * format test - * OpenAPI spec version: 1.0.0 - */ -import * as zod from 'zod'; - -/** - * @summary Info for a specific pet - */ -export const ShowPetByIdParams = zod.object({ - "petId": zod.string().describe('The id of the pet to retrieve'), - "testId": zod.string().describe('The id of the pet to retrieve') -}) - -export const ShowPetByIdResponse = zod.object({ - "id": zod.number().optional(), - "birthDate": zod.string().date(), - "createdAt": zod.string().datetime({}), - "age": zod.number().optional(), - "legCount": zod.number().optional(), - "weight": zod.number().optional(), - "height": zod.number().optional(), - "chipNumbers": zod.array(zod.number()).optional(), - "feedingTime": zod.string().time({"precision":-1}).optional() -}) diff --git a/tests/__snapshots__/zod/translationAPI.ts b/tests/__snapshots__/zod/translationAPI.ts deleted file mode 100644 index df79c22fe6..0000000000 --- a/tests/__snapshots__/zod/translationAPI.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Translation API - * Translation APIs - * OpenAPI spec version: 1.0.0 - */ -import * as zod from 'zod'; - -/** - * @summary Retrieve Translations - */ -export const RetrieveTranslationsParams = zod.object({ - "locale": zod.string() -}) - -export const RetrieveTranslationsResponse = zod.record(zod.string(), zod.string()) diff --git a/tests/__snapshots__/zod/typed-arrays-tuples-v3-1.ts b/tests/__snapshots__/zod/typed-arrays-tuples-v3-1.ts deleted file mode 100644 index 7925472792..0000000000 --- a/tests/__snapshots__/zod/typed-arrays-tuples-v3-1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Generated by orval v8.2.0 🍺 - * Do not edit manually. - * Nullables - * OpenAPI 3.1 examples - * OpenAPI spec version: 1.0.0 - */ -import * as zod from 'zod'; - -/** - * @summary sample - */ -export const PostApiSampleResponse = zod.object({ - "example_tuple": zod.tuple([zod.string(), -zod.unknown()]).optional(), - "example_tuple_additional": zod.tuple([zod.string(), -zod.unknown()]).optional(), - "example_tuple_with_object_item": zod.tuple([zod.object({ - "id": zod.string().uuid().optional() -}), -zod.string().uuid()]).optional(), - "example_const": zod.unknown().optional(), - "example_string_const": zod.literal("this_is_a_string_const").optional(), - "example_enum": zod.enum(['enum1', 'enum2']).optional() -}) From 0d4eaf79a29724b1406ebd1e4cf6617853c9fd16 Mon Sep 17 00:00:00 2001 From: The Ult Date: Sat, 16 May 2026 22:24:25 +0200 Subject: [PATCH 15/18] fix(angular): apply review follow-ups for default tag bucket Tighten the Angular default-tag follow-up by reducing new test-only type assertions, documenting the tag-bucket helper contract, and removing dead shared paramsFilter/nonPrimitiveKeys plumbing that was not wired through the generator pipeline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/angular/src/http-client.test.ts | 88 ++++++++++-------- packages/angular/src/http-resource.test.ts | 100 ++++++++++----------- packages/angular/src/utils.ts | 30 +++++++ packages/core/src/types.ts | 16 ---- packages/core/src/writers/target-tags.ts | 13 +-- packages/core/src/writers/target.ts | 4 - packages/orval/src/utils/options.ts | 10 --- 7 files changed, 134 insertions(+), 127 deletions(-) diff --git a/packages/angular/src/http-client.test.ts b/packages/angular/src/http-client.test.ts index 1384dbd3b2..dceaca2c16 100644 --- a/packages/angular/src/http-client.test.ts +++ b/packages/angular/src/http-client.test.ts @@ -130,6 +130,17 @@ const createOutput = ( return output; }; +const createQueryParams = ( + overrides: Partial> = {}, +): NonNullable => ({ + schema: { name: 'GetPetByIdParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: { type: 'object' }, + requiredNullableKeys: [], + ...overrides, +}); + const createSuccessType = ( value: string, contentType: string, @@ -180,7 +191,7 @@ const createVerbOption = ( definition: '', imports: [], schemas: [], - originalSchema: {} as never, + originalSchema: { type: 'object' }, contentType: '', formData: '', formUrlEncoded: '', @@ -225,6 +236,21 @@ const createVerbOption = ( ...overrides, }) as GeneratorVerbOptions; +const createHeaderParams = ( + overrides: Partial[0]> = {}, +): Parameters[0] => ({ + title: 'PetService', + isRequestOptions: true, + isMutator: false, + isGlobalMutator: false, + provideIn: 'root', + hasAwaitedType: false, + output: createOutput(), + verbOptions: { getPetById: createVerbOption() }, + clientImplementation: '', + ...overrides, +}); + const createContextSpec = (output: NormalizedOutputOptions): ContextSpec => { const spec = { openapi: '3.1.0', @@ -412,26 +438,19 @@ describe('angular HttpClient generator', () => { it('emits filterParams helper for untagged operations in tags-split default file (#3103)', () => { const verbOptionWithQueryParams = createVerbOption({ tags: [], - queryParams: { + queryParams: createQueryParams({ schema: { name: 'GetApiProductParams', model: '', imports: [] }, - deps: [], - isOptional: true, - originalSchema: {} as never, - requiredNullableKeys: [], - }, + }), }); - const header = generateAngularHeader({ - title: 'DefaultService', - isRequestOptions: true, - isMutator: false, - isGlobalMutator: false, - provideIn: 'root', - hasAwaitedType: false, - verbOptions: { getApiProduct: verbOptionWithQueryParams }, - tag: 'default', - isDefaultTagBucket: true, - } as never); + const header = generateAngularHeader( + createHeaderParams({ + title: 'DefaultService', + verbOptions: { getApiProduct: verbOptionWithQueryParams }, + tag: 'default', + isDefaultTagBucket: true, + }), + ); expect(header).toContain('function filterParams('); }); @@ -440,33 +459,26 @@ describe('angular HttpClient generator', () => { const untaggedVerb = createVerbOption({ operationId: 'getUntaggedProduct', tags: [], - queryParams: { + queryParams: createQueryParams({ schema: { name: 'GetApiProductParams', model: '', imports: [] }, - deps: [], - isOptional: true, - originalSchema: {} as never, - requiredNullableKeys: [], - }, + }), }); const explicitDefaultVerb = createVerbOption({ operationId: 'getTaggedDefaultProduct', tags: ['default'], }); - const header = generateAngularHeader({ - title: 'DefaultService', - isRequestOptions: true, - isMutator: false, - isGlobalMutator: false, - provideIn: 'root', - hasAwaitedType: false, - verbOptions: { - getUntaggedProduct: untaggedVerb, - getTaggedDefaultProduct: explicitDefaultVerb, - }, - tag: 'default', - isDefaultTagBucket: false, - } as never); + const header = generateAngularHeader( + createHeaderParams({ + title: 'DefaultService', + verbOptions: { + getUntaggedProduct: untaggedVerb, + getTaggedDefaultProduct: explicitDefaultVerb, + }, + tag: 'default', + isDefaultTagBucket: false, + }), + ); expect(header).not.toContain('function filterParams('); }); diff --git a/packages/angular/src/http-resource.test.ts b/packages/angular/src/http-resource.test.ts index f0ceb88613..d4589ac85c 100644 --- a/packages/angular/src/http-resource.test.ts +++ b/packages/angular/src/http-resource.test.ts @@ -176,6 +176,17 @@ const createGeneratorOptions = ( return options; }; +const createQueryParams = ( + overrides: Partial> = {}, +): NonNullable => ({ + schema: { name: 'GetPetByIdParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: { type: 'object' }, + requiredNullableKeys: [], + ...overrides, +}); + const createSuccessType = ( value: string, contentType: string, @@ -226,7 +237,7 @@ const createVerbOption = ( definition: '', imports: [], schemas: [], - originalSchema: {} as never, + originalSchema: { type: 'object' }, contentType: '', formData: '', formUrlEncoded: '', @@ -273,6 +284,21 @@ const createVerbOption = ( } as GeneratorVerbOptions; }; +const createHeaderParams = ( + overrides: Partial[0]> = {}, +): Parameters[0] => ({ + title: 'PetService', + isRequestOptions: true, + isMutator: false, + isGlobalMutator: false, + provideIn: 'root', + hasAwaitedType: false, + output: createOutput(), + verbOptions: { getPetById: createVerbOption() }, + clientImplementation: '', + ...overrides, +}); + describe('angular httpResource generator', () => { beforeEach(() => { routeRegistry.reset(); @@ -1079,33 +1105,20 @@ describe('angular httpResource generator', () => { it('emits filterParams helper for untagged operations in tags-split default file (#3103)', () => { const verbOptionWithQueryParams = createVerbOption({ tags: [], - queryParams: { + queryParams: createQueryParams({ schema: { name: 'GetApiProductParams', model: '', imports: [] }, - deps: [], - isOptional: true, - name: 'params', - definition: 'params: GetApiProductParams', - implementation: 'params: GetApiProductParams', - default: false, - required: false, - type: GetterPropType.QUERY_PARAM, - } as never, + }), }); routeRegistry.set('getPetById', '/api/pets/${petId}'); - const header = generateHttpResourceHeader({ - title: 'DefaultService', - isRequestOptions: true, - isMutator: false, - isGlobalMutator: false, - provideIn: 'root', - hasAwaitedType: false, - output: createOutput(), - verbOptions: { getPetById: verbOptionWithQueryParams }, - tag: 'default', - isDefaultTagBucket: true, - clientImplementation: '', - } as never); + const header = generateHttpResourceHeader( + createHeaderParams({ + title: 'DefaultService', + verbOptions: { getPetById: verbOptionWithQueryParams }, + tag: 'default', + isDefaultTagBucket: true, + }), + ); expect(header).toContain('function filterParams('); }); @@ -1114,39 +1127,26 @@ describe('angular httpResource generator', () => { const untaggedVerb = createVerbOption({ operationId: 'getUntaggedProduct', tags: [], - queryParams: { + queryParams: createQueryParams({ schema: { name: 'GetApiProductParams', model: '', imports: [] }, - deps: [], - isOptional: true, - name: 'params', - definition: 'params: GetApiProductParams', - implementation: 'params: GetApiProductParams', - default: false, - required: false, - type: GetterPropType.QUERY_PARAM, - } as never, + }), }); const explicitDefaultVerb = createVerbOption({ operationId: 'getTaggedDefaultProduct', tags: ['default'], }); - const header = generateHttpResourceHeader({ - title: 'DefaultService', - isRequestOptions: true, - isMutator: false, - isGlobalMutator: false, - provideIn: 'root', - hasAwaitedType: false, - output: createOutput(), - verbOptions: { - getUntaggedProduct: untaggedVerb, - getTaggedDefaultProduct: explicitDefaultVerb, - }, - tag: 'default', - isDefaultTagBucket: false, - clientImplementation: '', - } as never); + const header = generateHttpResourceHeader( + createHeaderParams({ + title: 'DefaultService', + verbOptions: { + getUntaggedProduct: untaggedVerb, + getTaggedDefaultProduct: explicitDefaultVerb, + }, + tag: 'default', + isDefaultTagBucket: false, + }), + ); expect(header).not.toContain('function filterParams('); }); diff --git a/packages/angular/src/utils.ts b/packages/angular/src/utils.ts index d0cfb63697..9b4322facf 100644 --- a/packages/angular/src/utils.ts +++ b/packages/angular/src/utils.ts @@ -40,13 +40,23 @@ const PRIMITIVE_TYPE_LOOKUP = { unknown: true, } as const satisfies Record; +/** + * Narrows a schema type string to the primitive set supported by the Angular + * generators' query/header helpers. + */ export const isPrimitiveType = (t: string | undefined): t is PrimitiveType => t != undefined && Object.prototype.hasOwnProperty.call(PRIMITIVE_TYPE_LOOKUP, t); +/** + * Indicates whether the configured schema output target is Zod-based. + */ export const isZodSchemaOutput = (output: NormalizedOutputOptions): boolean => isObject(output.schemas) && output.schemas.type === 'zod'; +/** + * Removes `null` and `undefined` from a value in a type-safe way. + */ export const isDefined = (v: T | null | undefined): v is T => v != undefined; /** @@ -55,6 +65,9 @@ export const isDefined = (v: T | null | undefined): v is T => v != undefined; export const getSchemaOutputTypeRef = (typeName: string): string => `${typeName}Output`; +/** + * Converts an operation/tag title into the generated Angular service class name. + */ export const generateAngularTitle = (title: string) => { const sanTitle = sanitize(title); return `${pascal(sanTitle)}Service`; @@ -127,6 +140,14 @@ export const createRouteRegistry = () => { }; }; +/** + * Returns only the operations that belong to the current tag output. + * + * In `tags` / `tags-split` mode the writer may route untagged operations into + * the implicit `default` bucket. Callers must pass `isDefaultTagBucket: true` + * only for that synthetic bucket; a literal user-defined `default` tag should + * keep the default `false` value so untagged operations stay excluded. + */ export const getRelevantVerbOptionsForTag = ( verbOptions: Record, tag?: string, @@ -143,6 +164,10 @@ export const getRelevantVerbOptionsForTag = ( ); }; +/** + * Tracks deferred `ClientResult` aliases emitted while individual operations + * are rendered, then flushes only the aliases needed by the current file. + */ export const createReturnTypesRegistry = () => { const returnTypesToWrite = new Map(); @@ -219,6 +244,11 @@ export function isMutationVerb( return !isRetrievalVerb(verb, operationName, clientOverride); } +/** + * Selects the preferred success payload type for Angular `httpResource` + * generation, favouring JSON responses and otherwise falling back to the + * generator's default content-type rules. + */ export function getDefaultSuccessType( successTypes: ResReqTypesValue[], fallback: string, diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 03cd857fb6..e4bc1910ab 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -97,7 +97,6 @@ export interface NormalizedOverrideOutput { formUrlEncoded: boolean | NormalizedMutator; paramsSerializer?: NormalizedMutator; paramsSerializerOptions?: NormalizedParamsSerializerOptions; - paramsFilter?: NormalizedMutator; namingConvention: { enum?: NamingConvention; }; @@ -201,7 +200,6 @@ export interface NormalizedOperationOptions { formData?: NormalizedFormDataType; formUrlEncoded?: boolean | NormalizedMutator; paramsSerializer?: NormalizedMutator; - paramsFilter?: NormalizedMutator; requestOptions?: object | boolean; } @@ -528,7 +526,6 @@ export interface OverrideOutput { formUrlEncoded?: boolean | Mutator; paramsSerializer?: Mutator; paramsSerializerOptions?: ParamsSerializerOptions; - paramsFilter?: Mutator; namingConvention?: { enum?: NamingConvention; }; @@ -912,7 +909,6 @@ export interface OperationOptions { formData?: boolean | Mutator | FormDataType; formUrlEncoded?: boolean | Mutator; paramsSerializer?: Mutator; - paramsFilter?: Mutator; requestOptions?: object | boolean; } @@ -1069,7 +1065,6 @@ export interface GeneratorTarget { formData?: GeneratorMutator[]; formUrlEncoded?: GeneratorMutator[]; paramsSerializer?: GeneratorMutator[]; - paramsFilter?: GeneratorMutator[]; fetchReviver?: GeneratorMutator[]; } @@ -1087,7 +1082,6 @@ export interface GeneratorTargetFull { formData?: GeneratorMutator[]; formUrlEncoded?: GeneratorMutator[]; paramsSerializer?: GeneratorMutator[]; - paramsFilter?: GeneratorMutator[]; fetchReviver?: GeneratorMutator[]; } @@ -1106,7 +1100,6 @@ export interface GeneratorOperation { formData?: GeneratorMutator; formUrlEncoded?: GeneratorMutator; paramsSerializer?: GeneratorMutator; - paramsFilter?: GeneratorMutator; fetchReviver?: GeneratorMutator; operationName: string; types?: { @@ -1133,7 +1126,6 @@ export interface GeneratorVerbOptions { formData?: GeneratorMutator; formUrlEncoded?: GeneratorMutator; paramsSerializer?: GeneratorMutator; - paramsFilter?: GeneratorMutator; fetchReviver?: GeneratorMutator; override: NormalizedOverrideOutput; deprecated?: boolean; @@ -1304,14 +1296,6 @@ export interface GetterQueryParam { isOptional: boolean; originalSchema?: OpenApiSchemaObject; requiredNullableKeys?: string[]; - /** - * Names of query parameters whose declared schema is non-primitive - * (object, array of objects, or untyped). Used by Angular generators to - * preserve these values through the default `filterParams` helper instead - * of silently dropping them — the user's `paramsSerializer`, `mutator`, or - * `paramsFilter` is then responsible for handling them. - */ - nonPrimitiveKeys?: string[]; } export type GetterPropType = diff --git a/packages/core/src/writers/target-tags.ts b/packages/core/src/writers/target-tags.ts index 798e507e80..64feb3d785 100644 --- a/packages/core/src/writers/target-tags.ts +++ b/packages/core/src/writers/target-tags.ts @@ -34,7 +34,6 @@ function generateTargetTags( paramsSerializer: operation.paramsSerializer ? [operation.paramsSerializer] : [], - paramsFilter: operation.paramsFilter ? [operation.paramsFilter] : [], fetchReviver: operation.fetchReviver ? [operation.fetchReviver] : [], implementation: operation.implementation, implementationMock: { @@ -86,9 +85,6 @@ function generateTargetTags( operation.paramsSerializer, ] : currentOperation.paramsSerializer, - paramsFilter: operation.paramsFilter - ? [...(currentOperation.paramsFilter ?? []), operation.paramsFilter] - : currentOperation.paramsFilter, fetchReviver: operation.fetchReviver ? [...(currentOperation.fetchReviver ?? []), operation.fetchReviver] : currentOperation.fetchReviver, @@ -101,6 +97,9 @@ export function generateTargetForTags( options: NormalizedOutputOptions, ) { const isAngularClient = options.client === OutputClient.ANGULAR; + const hasUntaggedOperations = Object.values(builder.operations).some( + (operation) => operation.tags.length === 0, + ); const operations = Object.values(builder.operations).map((operation) => addDefaultTagIfEmpty(operation), @@ -159,11 +158,7 @@ export function generateTargetForTags( output: options, verbOptions: builder.verbOptions, tag, - isDefaultTagBucket: - tag === 'default' && - Object.values(builder.operations).some( - (operation) => operation.tags.length === 0, - ), + isDefaultTagBucket: tag === 'default' && hasUntaggedOperations, clientImplementation: target.implementation, }); diff --git a/packages/core/src/writers/target.ts b/packages/core/src/writers/target.ts index f62bae9a02..410333ba89 100644 --- a/packages/core/src/writers/target.ts +++ b/packages/core/src/writers/target.ts @@ -37,7 +37,6 @@ export function generateTarget( formData: [], formUrlEncoded: [], paramsSerializer: [], - paramsFilter: [], fetchReviver: [], }; const operations = Object.values(builder.operations); @@ -66,9 +65,6 @@ export function generateTarget( if (operation.paramsSerializer) { target.paramsSerializer.push(operation.paramsSerializer); } - if (operation.paramsFilter) { - target.paramsFilter.push(operation.paramsFilter); - } if (operation.clientMutators) { target.clientMutators.push(...operation.clientMutators); diff --git a/packages/orval/src/utils/options.ts b/packages/orval/src/utils/options.ts index d95aa29534..ad0dc5c126 100644 --- a/packages/orval/src/utils/options.ts +++ b/packages/orval/src/utils/options.ts @@ -293,10 +293,6 @@ export async function normalizeOptions( outputWorkspace, outputOptions.override?.paramsSerializer, ), - paramsFilter: normalizeMutator( - outputWorkspace, - outputOptions.override?.paramsFilter, - ), header: outputOptions.override?.header === false ? false @@ -638,7 +634,6 @@ function normalizeOperationsAndTags( formData, formUrlEncoded, paramsSerializer, - paramsFilter, query, angular, zod, @@ -764,11 +759,6 @@ function normalizeOperationsAndTags( ), } : {}), - ...(paramsFilter - ? { - paramsFilter: normalizeMutator(workspace, paramsFilter), - } - : {}), }, ]; }, From 9518ffa115bc67d692f6308ac3afb5c9eeac5630 Mon Sep 17 00:00:00 2001 From: The Ult Date: Sat, 16 May 2026 22:51:48 +0200 Subject: [PATCH 16/18] fix: tighten default tag helpers and doc recursion Align Angular default-tag filtering with the generated default bucket, share query param test helpers across Angular tests, and guard JSDoc item traversal against circular schemas. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/angular/src/http-client.test.ts | 33 +-- packages/angular/src/http-client.ts | 7 +- packages/angular/src/http-resource.test.ts | 34 +-- packages/angular/src/http-resource.ts | 7 +- packages/angular/src/test-helpers.ts | 17 ++ packages/angular/src/utils.test.ts | 230 ++++++++++++++++++++- packages/angular/src/utils.ts | 19 +- packages/core/src/types.ts | 52 ++++- packages/core/src/utils/doc.test.ts | 24 +++ packages/core/src/utils/doc.ts | 7 +- packages/core/src/writers/target-tags.ts | 13 +- packages/orval/src/client.ts | 2 - 12 files changed, 385 insertions(+), 60 deletions(-) create mode 100644 packages/angular/src/test-helpers.ts diff --git a/packages/angular/src/http-client.test.ts b/packages/angular/src/http-client.test.ts index dceaca2c16..91da8e6bc2 100644 --- a/packages/angular/src/http-client.test.ts +++ b/packages/angular/src/http-client.test.ts @@ -18,6 +18,7 @@ import { getHttpClientReturnTypes, resetHttpClientReturnTypes, } from './http-client'; +import { createQueryParams } from './test-helpers'; // --------------------------------------------------------------------------- // Test helpers @@ -130,17 +131,6 @@ const createOutput = ( return output; }; -const createQueryParams = ( - overrides: Partial> = {}, -): NonNullable => ({ - schema: { name: 'GetPetByIdParams', model: '', imports: [] }, - deps: [], - isOptional: true, - originalSchema: { type: 'object' }, - requiredNullableKeys: [], - ...overrides, -}); - const createSuccessType = ( value: string, contentType: string, @@ -448,14 +438,13 @@ describe('angular HttpClient generator', () => { title: 'DefaultService', verbOptions: { getApiProduct: verbOptionWithQueryParams }, tag: 'default', - isDefaultTagBucket: true, }), ); expect(header).toContain('function filterParams('); }); - it('does not treat a literal default tag as the untagged bucket', () => { + it('includes both explicit default-tagged and untagged operations in the default bucket', () => { const untaggedVerb = createVerbOption({ operationId: 'getUntaggedProduct', tags: [], @@ -476,7 +465,23 @@ describe('angular HttpClient generator', () => { getTaggedDefaultProduct: explicitDefaultVerb, }, tag: 'default', - isDefaultTagBucket: false, + }), + ); + + expect(header).toContain('function filterParams('); + }); + + it('does not enable the implicit default bucket when only explicit default tags exist', () => { + const explicitDefaultVerb = createVerbOption({ + operationId: 'getTaggedDefaultProduct', + tags: ['default'], + }); + + const header = generateAngularHeader( + createHeaderParams({ + title: 'DefaultService', + verbOptions: { getTaggedDefaultProduct: explicitDefaultVerb }, + tag: 'default', }), ); diff --git a/packages/angular/src/http-client.ts b/packages/angular/src/http-client.ts index b86ad44eab..d877e11abf 100644 --- a/packages/angular/src/http-client.ts +++ b/packages/angular/src/http-client.ts @@ -226,16 +226,11 @@ export const generateAngularHeader: ClientHeaderBuilder = ({ provideIn, verbOptions, tag, - isDefaultTagBucket, output, }) => { returnTypesRegistry.reset(); - const relevantVerbs = getRelevantVerbOptionsForTag( - verbOptions, - tag, - isDefaultTagBucket, - ); + const relevantVerbs = getRelevantVerbOptionsForTag(verbOptions, tag); const hasQueryParams = relevantVerbs.some((v) => v.queryParams); const acceptHelpers = buildAcceptHelpers(relevantVerbs, output); diff --git a/packages/angular/src/http-resource.test.ts b/packages/angular/src/http-resource.test.ts index d4589ac85c..62f7cd66ab 100644 --- a/packages/angular/src/http-resource.test.ts +++ b/packages/angular/src/http-resource.test.ts @@ -19,6 +19,7 @@ import { getAngularHttpResourceOnlyDependencies, routeRegistry, } from './http-resource'; +import { createQueryParams } from './test-helpers'; interface AngularOverride { provideIn: 'root' | 'any' | boolean; @@ -176,17 +177,6 @@ const createGeneratorOptions = ( return options; }; -const createQueryParams = ( - overrides: Partial> = {}, -): NonNullable => ({ - schema: { name: 'GetPetByIdParams', model: '', imports: [] }, - deps: [], - isOptional: true, - originalSchema: { type: 'object' }, - requiredNullableKeys: [], - ...overrides, -}); - const createSuccessType = ( value: string, contentType: string, @@ -1116,14 +1106,13 @@ describe('angular httpResource generator', () => { title: 'DefaultService', verbOptions: { getPetById: verbOptionWithQueryParams }, tag: 'default', - isDefaultTagBucket: true, }), ); expect(header).toContain('function filterParams('); }); - it('does not treat a literal default tag as the untagged bucket', () => { + it('includes both explicit default-tagged and untagged operations in the default bucket', () => { const untaggedVerb = createVerbOption({ operationId: 'getUntaggedProduct', tags: [], @@ -1144,7 +1133,24 @@ describe('angular httpResource generator', () => { getTaggedDefaultProduct: explicitDefaultVerb, }, tag: 'default', - isDefaultTagBucket: false, + }), + ); + + expect(header).toContain('function filterParams('); + }); + + it('does not enable the implicit default bucket when only explicit default tags exist', () => { + const explicitDefaultVerb = createVerbOption({ + operationId: 'getTaggedDefaultProduct', + tags: ['default'], + }); + routeRegistry.set('getTaggedDefaultProduct', '/api/products/default'); + + const header = generateHttpResourceHeader( + createHeaderParams({ + title: 'DefaultService', + verbOptions: { getTaggedDefaultProduct: explicitDefaultVerb }, + tag: 'default', }), ); diff --git a/packages/angular/src/http-resource.ts b/packages/angular/src/http-resource.ts index 639b32f40b..a6b3329a75 100644 --- a/packages/angular/src/http-resource.ts +++ b/packages/angular/src/http-resource.ts @@ -1208,7 +1208,6 @@ export const generateHttpResourceHeader: ClientHeaderBuilder = ({ output, verbOptions, tag, - isDefaultTagBucket, }) => { resetHttpClientReturnTypes(); resourceReturnTypesRegistry.reset(); @@ -1218,11 +1217,7 @@ export const generateHttpResourceHeader: ClientHeaderBuilder = ({ // the shared header duplicates helpers across every tag file and pulls in // type names the file-local `imports` filter never sees, producing missing // schema imports in the generated output. - const relevantVerbOptions = getRelevantVerbOptionsForTag( - verbOptions, - tag, - isDefaultTagBucket, - ); + const relevantVerbOptions = getRelevantVerbOptionsForTag(verbOptions, tag); const retrievals = relevantVerbOptions.filter((verbOption) => isRetrievalVerb( diff --git a/packages/angular/src/test-helpers.ts b/packages/angular/src/test-helpers.ts new file mode 100644 index 0000000000..81b0245118 --- /dev/null +++ b/packages/angular/src/test-helpers.ts @@ -0,0 +1,17 @@ +import type { GeneratorVerbOptions } from '@orval/core'; + +/** + * Builds a minimal {@link GeneratorVerbOptions.queryParams} object for use in + * unit tests. Only the fields required by the Angular generators are populated; + * everything else can be overridden via the `overrides` argument. + */ +export const createQueryParams = ( + overrides: Partial> = {}, +): NonNullable => ({ + schema: { name: 'GetPetByIdParams', model: '', imports: [] }, + deps: [], + isOptional: true, + originalSchema: { type: 'object' }, + requiredNullableKeys: [], + ...overrides, +}); diff --git a/packages/angular/src/utils.test.ts b/packages/angular/src/utils.test.ts index c7b9547315..9a7a3d2330 100644 --- a/packages/angular/src/utils.test.ts +++ b/packages/angular/src/utils.test.ts @@ -1,4 +1,9 @@ -import type { ResReqTypesValue, Verbs } from '@orval/core'; +import type { + GeneratorVerbOptions, + ResReqTypesValue, + Verbs, +} from '@orval/core'; +import { GetterPropType } from '@orval/core'; import { describe, expect, it } from 'vitest'; import { @@ -6,8 +11,13 @@ import { createRouteRegistry, generateAngularTitle, getDefaultSuccessType, + isDefined, isMutationVerb, + isPrimitiveType, isRetrievalVerb, + isZodSchemaOutput, + getRelevantVerbOptionsForTag, + getSchemaOutputTypeRef, } from './utils'; // --------------------------------------------------------------------------- @@ -268,3 +278,221 @@ describe('getDefaultSuccessType', () => { expect(result.value).toBe('FallbackType'); }); }); + +// --------------------------------------------------------------------------- +// isPrimitiveType +// --------------------------------------------------------------------------- + +describe('isPrimitiveType', () => { + it.each(['string', 'number', 'boolean', 'void', 'unknown'])( + 'returns true for primitive "%s"', + (t) => { + expect(isPrimitiveType(t)).toBe(true); + }, + ); + + it.each(['Pet', 'object', 'array', 'null', ''])( + 'returns false for non-primitive "%s"', + (t) => { + expect(isPrimitiveType(t)).toBe(false); + }, + ); + + it('returns false for undefined', () => { + expect(isPrimitiveType(undefined)).toBe(false); + }); +}); + +// --------------------------------------------------------------------------- +// isDefined +// --------------------------------------------------------------------------- + +describe('isDefined', () => { + it('returns true for truthy values', () => { + expect(isDefined('hello')).toBe(true); + expect(isDefined(0)).toBe(true); + expect(isDefined(false)).toBe(true); + }); + + it('returns false for null', () => { + expect(isDefined(null)).toBe(false); + }); + + it('returns false for undefined', () => { + expect(isDefined(undefined)).toBe(false); + }); +}); + +// --------------------------------------------------------------------------- +// getSchemaOutputTypeRef +// --------------------------------------------------------------------------- + +describe('getSchemaOutputTypeRef', () => { + it('appends Output to the type name', () => { + expect(getSchemaOutputTypeRef('Pet')).toBe('PetOutput'); + }); + + it('handles already-suffixed names', () => { + expect(getSchemaOutputTypeRef('PetOutput')).toBe('PetOutputOutput'); + }); +}); + +// --------------------------------------------------------------------------- +// isZodSchemaOutput +// --------------------------------------------------------------------------- + +describe('isZodSchemaOutput', () => { + const makeOutput = (schemas: unknown) => + ({ schemas }) as Parameters[0]; + + it('returns true when schemas.type is "zod"', () => { + expect(isZodSchemaOutput(makeOutput({ type: 'zod' }))).toBe(true); + }); + + it('returns false when schemas.type is not "zod"', () => { + expect(isZodSchemaOutput(makeOutput({ type: 'ts' }))).toBe(false); + }); + + it('returns false when schemas is a string path', () => { + expect(isZodSchemaOutput(makeOutput('/tmp/schemas'))).toBe(false); + }); + + it('returns false when schemas is undefined', () => { + expect(isZodSchemaOutput(makeOutput(undefined))).toBe(false); + }); +}); + +// --------------------------------------------------------------------------- +// getRelevantVerbOptionsForTag +// --------------------------------------------------------------------------- + +const makeVerb = (operationId: string, tags: string[]): GeneratorVerbOptions => + ({ + operationId, + operationName: operationId, + verb: 'get' as Verbs, + route: `/api/${operationId}`, + pathRoute: `/api/${operationId}`, + tags, + summary: '', + doc: '', + response: { + imports: [], + definition: { success: 'void', errors: '' }, + types: { success: [], errors: [] }, + contentTypes: [], + isBlob: false, + schemas: [], + } as GeneratorVerbOptions['response'], + body: { + implementation: '', + definition: '', + imports: [], + schemas: [], + originalSchema: {}, + contentType: '', + formData: '', + formUrlEncoded: '', + isOptional: true, + }, + headers: undefined, + queryParams: undefined, + params: [], + props: [ + { + name: 'id', + definition: 'id: string', + implementation: 'id: string', + default: false, + required: true, + type: GetterPropType.PARAM, + }, + ], + mutator: undefined, + formData: undefined, + formUrlEncoded: undefined, + paramsSerializer: undefined, + fetchReviver: undefined, + override: { + requestOptions: true, + formData: { disabled: false, arrayHandling: 'serialize' }, + formUrlEncoded: true, + paramsSerializerOptions: undefined, + angular: { + provideIn: 'root', + client: 'httpClient', + runtimeValidation: false, + }, + } as GeneratorVerbOptions['override'], + deprecated: false, + originalOperation: {} as GeneratorVerbOptions['originalOperation'], + }) as GeneratorVerbOptions; + +describe('getRelevantVerbOptionsForTag', () => { + it('returns all verbs when no tag is given', () => { + const verbOptions = { + op1: makeVerb('op1', ['pets']), + op2: makeVerb('op2', ['users']), + }; + expect(getRelevantVerbOptionsForTag(verbOptions)).toHaveLength(2); + }); + + it('filters verbs to those matching the requested tag', () => { + const verbOptions = { + op1: makeVerb('op1', ['pets']), + op2: makeVerb('op2', ['users']), + }; + const result = getRelevantVerbOptionsForTag(verbOptions, 'pets'); + expect(result).toHaveLength(1); + expect(result[0].operationId).toBe('op1'); + }); + + it('includes untagged operations in the implicit default bucket', () => { + const verbOptions = { + tagged: makeVerb('tagged', ['default']), + untagged: makeVerb('untagged', []), + }; + const result = getRelevantVerbOptionsForTag(verbOptions, 'default'); + expect(result).toHaveLength(2); + expect(result.map((v) => v.operationId)).toContain('untagged'); + }); + + it('does not pull in untagged ops when target tag is default but no untagged ops exist', () => { + const verbOptions = { + op1: makeVerb('op1', ['default']), + op2: makeVerb('op2', ['pets']), + }; + const result = getRelevantVerbOptionsForTag(verbOptions, 'default'); + expect(result).toHaveLength(1); + expect(result[0].operationId).toBe('op1'); + }); + + it('does not include untagged operations for non-default tags', () => { + const verbOptions = { + untagged: makeVerb('untagged', []), + op1: makeVerb('op1', ['pets']), + }; + const result = getRelevantVerbOptionsForTag(verbOptions, 'pets'); + expect(result).toHaveLength(1); + expect(result[0].operationId).toBe('op1'); + }); + + it('matches tags case-insensitively via camelCase normalisation', () => { + const verbOptions = { + op1: makeVerb('op1', ['Pet-Store']), + }; + const result = getRelevantVerbOptionsForTag(verbOptions, 'pet-store'); + expect(result).toHaveLength(1); + }); + + it('returns empty array when no verbs match the tag', () => { + const verbOptions = { + op1: makeVerb('op1', ['pets']), + }; + expect(getRelevantVerbOptionsForTag(verbOptions, 'users')).toHaveLength(0); + }); + + it('returns empty array for empty verbOptions', () => { + expect(getRelevantVerbOptionsForTag({}, 'pets')).toHaveLength(0); + }); +}); diff --git a/packages/angular/src/utils.ts b/packages/angular/src/utils.ts index 9b4322facf..4a7f4e8a2d 100644 --- a/packages/angular/src/utils.ts +++ b/packages/angular/src/utils.ts @@ -1,5 +1,6 @@ import { camel, + DefaultTag, type GeneratorVerbOptions, getAngularFilteredParamsHelperBody, getDefaultContentType, @@ -144,23 +145,27 @@ export const createRouteRegistry = () => { * Returns only the operations that belong to the current tag output. * * In `tags` / `tags-split` mode the writer may route untagged operations into - * the implicit `default` bucket. Callers must pass `isDefaultTagBucket: true` - * only for that synthetic bucket; a literal user-defined `default` tag should - * keep the default `false` value so untagged operations stay excluded. + * the implicit `default` bucket. When a generated tag file targets that bucket + * we also include operations whose original tag list was empty; a literal + * user-defined `default` tag is treated like any other tag unless untagged + * operations are present in the same output. */ export const getRelevantVerbOptionsForTag = ( verbOptions: Record, tag?: string, - isDefaultTagBucket = false, ): GeneratorVerbOptions[] => { - if (!tag) return Object.values(verbOptions); + const allVerbOptions = Object.values(verbOptions); + if (!tag) return allVerbOptions; const camelTag = camel(tag); + const includeUntaggedOperations = + camelTag === DefaultTag && + allVerbOptions.some((verbOption) => verbOption.tags.length === 0); - return Object.values(verbOptions).filter( + return allVerbOptions.filter( (verbOption) => verbOption.tags.some((currentTag) => camel(currentTag) === camelTag) || - (isDefaultTagBucket && verbOption.tags.length === 0), + (includeUntaggedOperations && verbOption.tags.length === 0), ); }; diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index e4bc1910ab..fd1a25297b 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -948,6 +948,11 @@ export const Verbs = { HEAD: 'head' as Verbs, }; +/** + * Canonical tag name used for the generated bucket that collects untagged operations. + */ +export const DefaultTag = 'default' as const; + export interface ImportOpenApi { spec: OpenApiDocument; input: NormalizedInputOptions; @@ -990,8 +995,8 @@ export interface Tsconfig { exactOptionalPropertyTypes?: boolean; paths?: Record; target?: TsConfigTarget; - module?: string; - moduleResolution?: string; + module?: TsConfigModule; + moduleResolution?: TsConfigModuleResolution; allowImportingTsExtensions?: boolean; }; } @@ -1013,6 +1018,47 @@ export type TsConfigTarget = | 'es2025' | 'esnext'; // https://www.typescriptlang.org/tsconfig#target +/** Accepts both the canonical casing and the all-lowercase variant of a string literal. */ +type CaseInsensitive = T | Lowercase; + +/** + * Valid values for the TypeScript `compilerOptions.module` setting. + * + * Both title-case (e.g. `"NodeNext"`) and lower-case (e.g. `"nodenext"`) are + * accepted, matching TypeScript's own case-insensitive parsing. + * + * @see {@link https://www.typescriptlang.org/tsconfig#module} + */ +export type TsConfigModule = CaseInsensitive< + | 'None' + | 'CommonJS' + | 'AMD' + | 'UMD' + | 'System' + | 'ES6' + | 'ES2015' + | 'ES2020' + | 'ES2022' + | 'ESNext' + | 'Node16' + | 'Node18' + | 'Node20' + | 'NodeNext' + | 'Preserve' +>; + +/** + * Valid values for the TypeScript `compilerOptions.moduleResolution` setting. + * + * Both title-case (e.g. `"NodeNext"`) and lower-case (e.g. `"nodenext"`) are + * accepted, matching TypeScript's own case-insensitive parsing. + * + * @see https://www.typescriptlang.org/tsconfig#moduleResolution + */ +export type TsConfigModuleResolution = CaseInsensitive< + 'Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler' +>; + export interface PackageJson { dependencies?: Record; devDependencies?: Record; @@ -1195,7 +1241,6 @@ export type ClientHeaderBuilder = (params: { output: NormalizedOutputOptions; verbOptions: Record; tag?: string; - isDefaultTagBucket?: boolean; clientImplementation: string; }) => string; @@ -1434,7 +1479,6 @@ export type GeneratorClientHeader = (data: { output: NormalizedOutputOptions; verbOptions: Record; tag?: string; - isDefaultTagBucket?: boolean; clientImplementation: string; }) => GeneratorClientExtra; diff --git a/packages/core/src/utils/doc.test.ts b/packages/core/src/utils/doc.test.ts index c8c22255ac..2587f43651 100644 --- a/packages/core/src/utils/doc.test.ts +++ b/packages/core/src/utils/doc.test.ts @@ -41,6 +41,30 @@ describe('jsDoc', () => { * @items.maxItems 5 * @items.items.minLength 1 */ +`); + }); + + it('stops traversing circular item schemas', () => { + interface CircularItems { + items?: CircularItems; + maxLength: number; + type: string; + } + + const circularItems: CircularItems = { + type: 'string', + maxLength: 50, + }; + circularItems.items = circularItems; + + expect( + jsDoc({ + type: 'array', + items: circularItems, + }), + ).toBe(`/** + * @items.maxLength 50 + */ `); }); }); diff --git a/packages/core/src/utils/doc.ts b/packages/core/src/utils/doc.ts index 475b476225..04b0f8ca45 100644 --- a/packages/core/src/utils/doc.ts +++ b/packages/core/src/utils/doc.ts @@ -42,10 +42,15 @@ const itemValidationKeys = [ function getItemValidationDocEntries( schema?: JsDocSchema, prefix = 'items', + visited = new WeakSet(), ): JsDocEntry[] { if (!schema) { return []; } + if (visited.has(schema)) { + return []; + } + visited.add(schema); const entries = itemValidationKeys.flatMap((key) => { const value = schema[key]; @@ -55,7 +60,7 @@ function getItemValidationDocEntries( return [ ...entries, - ...getItemValidationDocEntries(schema.items, `${prefix}.items`), + ...getItemValidationDocEntries(schema.items, `${prefix}.items`, visited), ]; } diff --git a/packages/core/src/writers/target-tags.ts b/packages/core/src/writers/target-tags.ts index 64feb3d785..1e19965a97 100644 --- a/packages/core/src/writers/target-tags.ts +++ b/packages/core/src/writers/target-tags.ts @@ -1,4 +1,5 @@ import { + DefaultTag, type GeneratorOperation, type GeneratorTarget, type GeneratorTargetFull, @@ -8,10 +9,16 @@ import { } from '../types'; import { compareVersions, kebab, pascal } from '../utils'; +/** + * Ensures every operation has at least one tag by falling back to the + * {@link DefaultTag} constant for untagged operations, so the tag-routing + * logic in {@link generateTargetTags} always has a bucket to assign the + * operation to. + */ function addDefaultTagIfEmpty(operation: GeneratorOperation) { return { ...operation, - tags: operation.tags.length > 0 ? operation.tags : ['default'], + tags: operation.tags.length > 0 ? operation.tags : [DefaultTag], }; } @@ -97,9 +104,6 @@ export function generateTargetForTags( options: NormalizedOutputOptions, ) { const isAngularClient = options.client === OutputClient.ANGULAR; - const hasUntaggedOperations = Object.values(builder.operations).some( - (operation) => operation.tags.length === 0, - ); const operations = Object.values(builder.operations).map((operation) => addDefaultTagIfEmpty(operation), @@ -158,7 +162,6 @@ export function generateTargetForTags( output: options, verbOptions: builder.verbOptions, tag, - isDefaultTagBucket: tag === 'default' && hasUntaggedOperations, clientImplementation: target.implementation, }); diff --git a/packages/orval/src/client.ts b/packages/orval/src/client.ts index 5890831398..4addbfb37b 100644 --- a/packages/orval/src/client.ts +++ b/packages/orval/src/client.ts @@ -123,7 +123,6 @@ export const generateClientHeader: GeneratorClientHeader = ({ output, verbOptions, tag, - isDefaultTagBucket, clientImplementation, }) => { const { header } = getGeneratorClient(outputClient, output); @@ -139,7 +138,6 @@ export const generateClientHeader: GeneratorClientHeader = ({ output, verbOptions, tag, - isDefaultTagBucket, clientImplementation, }) : '', From b719b82795b97cfc4e3c185ef3ca1333ee480ba3 Mon Sep 17 00:00:00 2001 From: The Ult Date: Sat, 16 May 2026 23:19:34 +0200 Subject: [PATCH 17/18] fix(angular): correct default-tag identity check and test housekeeping Use raw tag === DefaultTag comparison instead of camelTag === DefaultTag so user-defined tags like 'Default' or 'DEFAULT' do not incorrectly inherit untagged operations into their generated file. Also add the required index signature to CircularItems in doc.test.ts to fix the typecheck CI failure, and reorder utils.test.ts imports alphabetically. Co-Authored-By: Claude Sonnet 4.6 --- packages/angular/src/utils.test.ts | 4 ++-- packages/angular/src/utils.ts | 2 +- packages/core/src/utils/doc.test.ts | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/angular/src/utils.test.ts b/packages/angular/src/utils.test.ts index 9a7a3d2330..51a08df128 100644 --- a/packages/angular/src/utils.test.ts +++ b/packages/angular/src/utils.test.ts @@ -11,13 +11,13 @@ import { createRouteRegistry, generateAngularTitle, getDefaultSuccessType, + getRelevantVerbOptionsForTag, + getSchemaOutputTypeRef, isDefined, isMutationVerb, isPrimitiveType, isRetrievalVerb, isZodSchemaOutput, - getRelevantVerbOptionsForTag, - getSchemaOutputTypeRef, } from './utils'; // --------------------------------------------------------------------------- diff --git a/packages/angular/src/utils.ts b/packages/angular/src/utils.ts index 4a7f4e8a2d..4c4db849dd 100644 --- a/packages/angular/src/utils.ts +++ b/packages/angular/src/utils.ts @@ -159,7 +159,7 @@ export const getRelevantVerbOptionsForTag = ( const camelTag = camel(tag); const includeUntaggedOperations = - camelTag === DefaultTag && + tag === DefaultTag && allVerbOptions.some((verbOption) => verbOption.tags.length === 0); return allVerbOptions.filter( diff --git a/packages/core/src/utils/doc.test.ts b/packages/core/src/utils/doc.test.ts index 2587f43651..4fc4433fa3 100644 --- a/packages/core/src/utils/doc.test.ts +++ b/packages/core/src/utils/doc.test.ts @@ -46,6 +46,7 @@ describe('jsDoc', () => { it('stops traversing circular item schemas', () => { interface CircularItems { + [key: string]: unknown; items?: CircularItems; maxLength: number; type: string; From 0e1c20cc93c31eb5d3d0e30f8e0838c158342b38 Mon Sep 17 00:00:00 2001 From: The Ult Date: Sun, 17 May 2026 11:38:37 +0200 Subject: [PATCH 18/18] fix(angular): resolve lint errors in utils.test.ts Replace explicit null/undefined literals with typed variables to satisfy unicorn/no-null and unicorn/no-useless-undefined rules. --- packages/angular/src/utils.test.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/angular/src/utils.test.ts b/packages/angular/src/utils.test.ts index 51a08df128..2081d0916e 100644 --- a/packages/angular/src/utils.test.ts +++ b/packages/angular/src/utils.test.ts @@ -299,7 +299,8 @@ describe('isPrimitiveType', () => { ); it('returns false for undefined', () => { - expect(isPrimitiveType(undefined)).toBe(false); + const value = undefined as string | undefined; + expect(isPrimitiveType(value)).toBe(false); }); }); @@ -315,11 +316,14 @@ describe('isDefined', () => { }); it('returns false for null', () => { - expect(isDefined(null)).toBe(false); + // eslint-disable-next-line unicorn/no-null -- testing null handling explicitly + const value = null as string | null; + expect(isDefined(value)).toBe(false); }); it('returns false for undefined', () => { - expect(isDefined(undefined)).toBe(false); + const value = undefined as string | undefined; + expect(isDefined(value)).toBe(false); }); }); @@ -358,7 +362,8 @@ describe('isZodSchemaOutput', () => { }); it('returns false when schemas is undefined', () => { - expect(isZodSchemaOutput(makeOutput(undefined))).toBe(false); + const value = undefined as unknown; + expect(isZodSchemaOutput(makeOutput(value))).toBe(false); }); });