fix(angular): include query params in multi-content-type HTTP calls (#3102) - #3196
Conversation
…rval-labs#3102) When an endpoint defines multiple response content types, the Angular HttpClient generator dropped query parameters from generated http.get() calls. The params appeared in the function signature but were never passed to the HTTP request. Broaden the angularParamsRef guard so filteredParams is always generated when queryParams exists, and add inline IIFE filtering for the requestOptions=false edge case. Add unit and snapshot test coverage. Signed-off-by: jaery <jaeryong95@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughThis PR fixes query parameter handling in the Angular HTTP client code generator for endpoints with multiple response content types. The parameter filtering logic is updated to consistently apply query parameters regardless of the Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Caller
participant Service as AngularMultiContentQueryParamsTestService
participant HttpClient as Angular HttpClient
participant Server as Backend
Client->>Service: listItems(params, accept, options?)
activate Service
Service->>Service: Merge params with options.params
Service->>Service: filterParams() - sanitize query params
Service->>Service: Build/override Accept header
alt accept = 'application/json'
Service->>Service: Set responseType: 'json'
else accept = 'text/plain'
Service->>Service: Set responseType: 'text'
end
Service->>HttpClient: get(url, { params, headers, responseType })
deactivate Service
activate HttpClient
HttpClient->>Server: GET /items?filter=...&limit=... + Accept header
deactivate HttpClient
activate Server
Server-->>HttpClient: 200 OK + matching Content-Type
deactivate Server
activate HttpClient
HttpClient-->>Client: Observable<Items | string>
deactivate HttpClient
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Suggested Labels
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…rval-labs#3102) When an endpoint defines multiple response content types, the Angular HttpClient generator dropped query parameters from generated http.get() calls. The params appeared in the function signature but were never passed to the HTTP request. Broaden the angularParamsRef guard so filteredParams is always generated when queryParams exists, and add inline IIFE filtering for the requestOptions=false edge case. Add unit and snapshot test coverage with a dedicated multi-content-type spec to avoid affecting other generators. Signed-off-by: jaery <jaeryong95@gmail.com>
…/github.com/zeriong/orval into fix/angular-multi-content-query-params-3102
…rval-labs#3102) When an endpoint defines multiple response content types, the Angular HttpClient generator dropped query parameters from generated http.get() calls. The params appeared in the function signature but were never passed to the HTTP request. Broaden the angularParamsRef guard so filteredParams is always generated when queryParams exists, and add inline IIFE filtering for the requestOptions=false edge case. Add unit and snapshot test coverage with a dedicated multi-content-type spec to avoid affecting other generators. Signed-off-by: jaery <jaeryong95@gmail.com>
…/github.com/zeriong/orval into fix/angular-multi-content-query-params-3102
The previous commit inadvertently modified the shared petstore.yaml, adding a text/plain content type to listPets. This exposed pre-existing bugs in httpResource (TS1016: required param after optional) and mock generator (TS2451: duplicate variable). Revert petstore.yaml and all affected snapshots to master state. The multi-content-type + query params scenario is covered by a dedicated spec instead. Signed-off-by: jaery <jaeryong95@gmail.com>
Summary
Closes #3102
application/json+text/plain), the AngularHttpClientgenerator included query parameters in the function signature but never passed them tohttp.get()/http.post()calls.angularParamsRefwas gated onisRequestOptions, so whenrequestOptions=falseor when the observe-branching condition excluded multi-content-type paths,filteredParamswas never generated.angularParamsRefto always be set whenqueryParamsexists. SplitparamsDeclarationinto two branches: sharedfilterParamshelper (whenisRequestOptions=true) and inline IIFE filtering (whenisRequestOptions=false).Changes
packages/angular/src/http-client.tsgetAngularFilteredParamsExpression, broadenangularParamsRefguard, addisRequestOptionsbranching forparamsDeclarationpackages/angular/src/http-client.test.tsrequestOptions=false+ multi-content-type + query paramstests/specifications/petstore.yamltext/plaincontent type tolistPets200 response for snapshot coverageTest plan
bun vitest run packages/angular/src/http-client.test.ts(37/37)bun vitest run(2179/2182, 3 pre-existing failures inresolve-version.test.ts)bun run test:snapshots(67/67 tasks)listPetssnapshot includesparams: filteredParamsin all content-type branchesSummary by CodeRabbit
Bug Fixes
Tests