Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement REST service layer generation technique which unfolds all arguments #792

Open
porunov opened this issue Feb 6, 2022 · 1 comment · May be fixed by #793
Open

Implement REST service layer generation technique which unfolds all arguments #792

porunov opened this issue Feb 6, 2022 · 1 comment · May be fixed by #793

Comments

@porunov
Copy link

porunov commented Feb 6, 2022

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
Copy link
Author

porunov commented Feb 6, 2022

@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?

porunov added a commit to porunov/typescript-generator that referenced this issue Feb 6, 2022
…rguments

Fixes vojtechhabarta#792

Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>
porunov added a commit to porunov/typescript-generator that referenced this issue Feb 6, 2022
…rguments

Fixes vojtechhabarta#792

Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>
porunov added a commit to porunov/typescript-generator that referenced this issue Feb 13, 2022
…rguments

Fixes vojtechhabarta#792

Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>
porunov added a commit to porunov/typescript-generator that referenced this issue Jun 7, 2022
…rguments

Fixes vojtechhabarta#792

Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>
porunov added a commit to porunov/typescript-generator that referenced this issue Jun 7, 2022
…rguments

Fixes vojtechhabarta#792

Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>
porunov added a commit to porunov/typescript-generator that referenced this issue Jun 7, 2022
…rguments

Fixes vojtechhabarta#792

Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant