Repository navigation
feat(typescript-angular): add withHttpResource option for signal-based GET resources - #24964
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 36 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
5124c05 to
a344b41
Compare
|
About cubic review:
|
…d GET resources Opt-in, Angular 20+. Every GET operation without a request body gets a <operation>Resource method next to its Observable method, returning an Angular httpResource (httpResource.text or httpResource.blob when the response is text or binary). Writes keep only their Observable method. The query, header and credential code moves into a partial shared by both paths, so the output of every existing configuration is unchanged. Adds a sample build inside typescript-angular-v22-provided-in-root with an HttpTestingController spec.
a344b41 to
3fe558b
Compare
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
View guided diff | Re-trigger cubic
|
Great feature! We're waiting for this / considering moving to ng-openapi. Would love to see this PR make it! |
|
@wing328 thanks for running CI. only red one is Samples TS clients and it fails on master too - pom.xml in typescript-angular v18-v21 provided-in-root samples declares exec-maven-plugin twice (line 13 and 100), so maven stops before build |
|
@thekhegay I've fixed the CI failure via #25343 Can you please merge the latest master into your branch? I'll then merge it if all the tests pass. |
|
done, merged master in f16c0ea |
|
PR merged. Thanks for the contribution. |
Adds an opt-in
withHttpResourceoption totypescript-angular(Angular 20+; a lowerngVersionis refused).Every GET operation without a request body gets a
<operationId>Resourcemethod next to its Observable method, returning an AngularHttpResourceRef:undefined, or leaving a required parameter null/undefined, keeps the resource idle.httpResource, texthttpResource.text, binaryhttpResource.blob, chosen at generation time the same wayselectHeaderAcceptdoes.withCredentials,contextandtransferCachebehave exactly like the Observable methods.defaultValue,injector,equal,debugName,context,transferCache.observe,httpHeaderAccept,parse, and resource signatures in the*Interfacefiles.With the option off the output is unchanged: regenerating every
bin/configsfile gives zero diff. Tested with Java unit tests and a new sample build (typescript-angular-v22-provided-in-root/builds/with-http-resource) with anHttpTestingControllerspec; the generated code was also compiled and run against Angular 20, 21 and 22.Closes #21263. Related: #22537 — this keeps the Observable methods and doesn't touch existing samples.
PR checklist
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim
Summary by cubic
Adds an opt-in
withHttpResourceoption totypescript-angularthat generates signal-based<operationId>Resourcemethods next to the existing Observable methods. With the option off, generated output is unchanged; enabling it requires Angular 20+ and rejects lowerngVersionvalues.New Features
<operationId>Resourcemethod returning an AngularHttpResourceRef; JSON, text, and binary responses usehttpResource,httpResource.text, andhttpResource.blob.undefinedor a required parameter isnull/undefined.withCredentials,context, andtransferCachebehavior matches the Observable methods.defaultValue,injector,equal,debugName,context, andtransferCache.observe,httpHeaderAccept, andparseremain Observable-only.Closes #21263.
Written for commit f16c0ea. Summary will update on new commits.