vojtechhabarta / typescript-generator

Generates TypeScript from Java - JSON declarations, REST service client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Complex Object as request param not generated without @RequestParam annotation

almir-dev opened this issue · comments

Hi @vojtechhabarta & team,

I'm trying to generated a spring endpoint that has a request param as an object (not annotated with @RequestParam annotation).

Expected behaviour:

@GetMapping("/foo")
fun foo(req: RequestDTO): String

should be generated to:
foo(queryParams: { req: RequestDTO; }, options?: any): RestResponse<string>

but actually generates to:
foo(options?: any): RestResponse<string>

I have the same problem.
In our project we have custom Pageable dto, and also we have second object for filter
It looks like:Page<RuleDto> findAll(RuleFilter filter, Pageable pageable)
Plugin generates to: findAll(options?: O): RestResponse<Page<Rule>>
I expect one of two options:
findAll(queryParams: { page?: number; size?: number; <others merged fields from object> }, options?: O): RestResponse<Page<Rule>>
or
findAll(filter: RuleFilter; pageable: Pageable, options?: O): RestResponse<Page<Rule>>

@avzhuiko In the mean time I figured out that you need to annotate your query param with the @ModelAttribute from Spring, and additionally you have to make sure that the fields of the complex query params are mutable. Only then will it generated your complex query param.

So something like this:

@GetMapping("/foo")
fun foo(@ModelAttribute req: RequestDTO): String