Skip to content

Commit 61e368e

Browse files
author
The Ult
committed
fix(angular): address coderabbit review feedback on paramsFilter
- fix(docs): correct HttpParams behavior — does not throw on undefined, stringifies to literal 'undefined'; handle it explicitly - fix(angular): include paramsFilter in resource mutator imports so generated .resource.ts files compile when paramsFilter is configured - fix(core): check Array.isArray(type) && type.includes('object') before array recursion in isSchemaNonPrimitive to handle mixed type unions - fix(options): tighten usesAngularGenerator guard to require both client === ANGULAR_QUERY and httpClient === ANGULAR, not just httpClient
1 parent eeabd88 commit 61e368e

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

docs/content/docs/guides/angular.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ export const filterPetstoreParams = (
783783
The built-in helper is **not** called alongside your filter. In particular,
784784
you are responsible for:
785785

786-
- stripping `undefined` (Angular's `HttpParams` constructor will throw)
786+
- stripping `undefined` (Angular's `HttpParams` does not safely represent it for query encoding; handle it explicitly)
787787
- handling `null` (Angular treats it as the literal string `"null"`)
788788
- filtering arrays (`new HttpParams({ fromObject: { tags: [{}] } })` is
789789
invalid)

packages/angular/src/http-resource.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,7 @@ const buildHttpResourceExtraFile = (
15531553
verbOption.formData,
15541554
verbOption.formUrlEncoded,
15551555
verbOption.paramsSerializer,
1556+
verbOption.paramsFilter,
15561557
].filter(
15571558
(value): value is NonNullable<typeof value> => value !== undefined,
15581559
);

packages/core/src/getters/query-params.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ const isSchemaNonPrimitive = (schema: OpenApiSchemaObject): boolean => {
8181
if (type === 'object') {
8282
return true;
8383
}
84+
if (Array.isArray(type) && type.includes('object')) {
85+
return true;
86+
}
8487
if (type === 'array' || (Array.isArray(type) && type.includes('array'))) {
8588
const items = (schema as { items?: unknown }).items;
8689
if (isOpenApiSchemaObject(items)) {
@@ -90,9 +93,6 @@ const isSchemaNonPrimitive = (schema: OpenApiSchemaObject): boolean => {
9093
// referenced objects must still be flagged so it survives the filter.
9194
return isRefObject(items);
9295
}
93-
if (Array.isArray(type) && type.includes('object')) {
94-
return true;
95-
}
9696

9797
const compositions = [
9898
...(Array.isArray(schema.oneOf) ? (schema.oneOf as unknown[]) : []),

packages/orval/src/utils/options.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ export async function normalizeOptions(
476476
// but never called, so fail fast instead of emitting a dead import.
477477
const usesAngularGenerator =
478478
normalizedOptions.output.client === OutputClient.ANGULAR ||
479-
normalizedOptions.output.httpClient === OutputHttpClient.ANGULAR;
479+
(normalizedOptions.output.client === OutputClient.ANGULAR_QUERY &&
480+
normalizedOptions.output.httpClient === OutputHttpClient.ANGULAR);
480481
if (normalizedOptions.output.override.paramsFilter && !usesAngularGenerator) {
481482
throw new Error(
482483
styleText(

0 commit comments

Comments
 (0)