Implement REST service layer generation technique which unfolds all arguments

This issue has been created since 2022-02-06.

Right now this framework could generate controller methods such as:

testControllerMethod( param1: string, param2: number, queryParams: { param3?: string; param4: number; }, data: entityDTO  ): RestResponse<SomeData> ;

This means that the method interface is a simple wrapper around http controller which doesn't provide any abstraction over http controller.
The user who uses such methods should be aware of where parameters should go (it is a request parameter? is it a path variable? is it an entity data?).
I would suggest adding a feature flag which provides a service abstraction layer instead of a simple HttpClient wrapper.
Maybe something like: serviceLayerInsteadOfWrapperLayer: boolean.
I think (not sure yet), that we could relay on null value of an argument as an indicator for a value to not being provided to the HttpClient.
So, maybe, we could generate an implementation like the next one:

testServiceMethod( param1: string, param2: number, param3?: string, param4: number, param5: entityDTO ): RestResponse<SomeData> 
{

  queryParams = {};
  
  if(param3 != null){
    queryParams["param3"] = param3;
  }
  queryParams["param4"] = param4;

  return this.httpClient.request({ method: "POST", url: uriEncoding`some/path/${param1}/${param2}`, queryParams: queryParams, data: param5 });
}
porunov wrote this answer on 2022-02-06

@vojtechhabarta What do you think about it? Would it make sense to implement such a feature or do you see any problems if we relay on null value for optional method arguments?

More Details About Repo
Owner Name vojtechhabarta
Repo Name typescript-generator
Full Name vojtechhabarta/typescript-generator
Language Java
Created Date 2014-11-03
Updated Date 2022-09-24
Star Count 943
Watcher Count 23
Fork Count 211
Issue Count 74

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
justoverclock/flarum-ext-keywords 0 2022-09-14 2022-09-26
Console error on resource's relation edit/view 3 2022-07-06 2022-08-09
frontend: explain of query forced to local mode 0 2022-07-27 2022-08-10
Fix incompatibility with Field Manager 3 2021-06-05 2022-07-16
Block Ordering Bug $this->orderBy('neoblocks.sortOrder') not being set. 3 2021-06-07 2022-04-06
Print inventory render time on compile 2 2021-07-02 2022-08-25
[BUG] Handling categorical data layer render slowdown 6 2021-10-14 2022-09-26
Archived episodes randomly being changed to "Wanted" triggering massive downloads 23 2022-05-09 2022-08-06
Parse the binary which is statically compiled. 1 2020-04-18 2022-07-23
VMware GuestInfo Service - encrypted password extraction 4 2022-01-24 2022-09-29
Can you release the mfsbsd version for 11.3-RELEASE? 2 2019-08-23 2022-09-19
Wave removes startupProbe 3 2021-12-07 2022-09-26
"mount(2): Operation not permitted" in plain docker installation 18 2020-04-01 2022-08-12
Edit function does not appear to work 8 2020-10-19 2022-09-22
stripExtensions doesn't work with dot files 4 2020-06-23 2021-12-31
ffmpeg 4.3.2 broken by upgrade 2 2021-04-27 2022-09-19
Parallel as edge attribute and stored in inter-nodes 1 2021-02-12 2022-08-16
Store voltages of nodes 1 2021-02-13 2022-07-16
[Bug]: RCON connection refused on ARK after more than 10 hours 4 2022-06-04 2022-07-28
Shears and Forged Shears are identical 2 2022-08-24 2022-08-30
Implement recover for wasm architecture 3 2022-06-16 2022-09-20
Can`t login 0 2015-11-19 2021-12-28
Link to the CouchDB wiki SSL walkthrough. Closes #606 1 2021-03-29 2022-09-13
Trying to run two instances of Fall Guys (EasyAntiCheat) 1 2022-07-11 2022-08-28
大佬能否增加接口返回BASE64的图片码 2 2022-06-27 2022-09-02
Inline suspend functions with lambdas in ktx-async 4 2018-04-29 2022-08-21
Azure Key Vault 400 - Some input not valid 2 2022-04-26 2022-09-08
Aggregating Assets by Category provides shifting results for Compute 3 2021-09-29 2022-08-22
Changing GeoJSON/GeoData layer visibility programmatically 0 2021-05-25 2022-09-24
Pose detection Question 1 2021-08-03 2022-09-03
Rules disabled by configuration file cannot be enabled inline 0 2021-06-23 2022-09-11
WiFi does not stay connected to sync progress 12 2022-06-28 2022-09-16
New dictionary system broken (because of STARDICT_DATA_DIR?) 7 2022-06-29 2022-09-21
Sheets API V4 - To Be Added? 1 2016-11-19 2022-09-29
Configure online editor 8 2021-01-29 2022-09-05
Artifact GC: add finalizer to workflows 2 2022-04-25 2022-09-18
Support deploy StatefulSet using yaml files 0 2021-06-11 2022-09-22
Error in compilar flutter 3 2021-07-15 2022-09-23
Use https scheme in examples 0 2020-01-07 2022-09-15
I can't use vue-cool-lightbox pls help me out 3 2020-12-08 2022-07-06
Composite, included build, dependency substitution to project + configuration 12 2022-06-15 2022-09-18
Dependabot should group commits into a single pull request and do monthly updates only 2 2020-12-10 2022-09-03
where does the input dimension changes in discriminator? 2 2021-06-15 2022-09-28
[FEATURE REQUEST]: execute jobs scheduled at the same time sequentially 0 2021-01-10 2022-09-12
Corrupted 1b_lyrics checkpoint? 11 2020-05-02 2022-09-22
Modify Clipboard API permission to encompass writes in addition to reads 0 2022-09-01 2022-08-30
Add a policy option to disable Brave Rewards 0 2022-09-01 2022-08-30
Broken TodoMVC example 1 2022-03-23 2022-09-13
Add a warning in WDT when using symfony/symfony 1 2021-10-16 2022-08-02
CS1729 code fix does not respect naming convention for records 2 2021-10-05 2022-08-23