blue-veery-gmbh / spring-rest-2-ts

spring rest 2 ts is typescript generator which produces data model and services in typescript based on Spring MVC annotations. It supports generation for Angular and React
MIT License
64 stars 17 forks source link

Spring Data Pageable extension does not work as intended #51

Closed ememisya closed 7 months ago

ememisya commented 7 months ago

When verifying by running the default project tests it seems Pageable extension does not quite work as intended. I get the following output

@Injectable()
export class ManufacturerCtrl {
  httpService: HttpClient;

 public constructor(httpService: HttpClient) {
    this.httpService = httpService;
  }

 public findManufacturers(): Observable<any>  {
    return this.httpService.get('api/manufacturer', {responseType: 'text'}).pipe(map(res => JSON.parse(res)));
  }

}

This appears to be due to the Pageable.class being converted into tsAny (TSSimpleType) and not the expected type by tsParameter.getType() instanceof TSParameterizedTypeReference<?>

ememisya commented 7 months ago

It appears the following line of code is necessary for this to occur during configuration.

modelClassesConverter.preConverted(tsGenerator.getJavaPackageToTsModuleConverter(), Pageable.class);
gunner121 commented 7 months ago

Hi, did you try to add ConversionExtension like we described here https://github.com/blue-veery-gmbh/spring-rest-2-ts#support-for-spring-data-in-spring-rest-controllers---since-ver-122 Probably it is just missing in the tests.

ememisya commented 7 months ago

You are correct. I was under the mistaken impression that com.blueveery.springrest2ts.examples.test.SpringDataPageableTest was actually executing when cloning the project and running "mvn test", apparently not.

I missed the following line. My apologies. https://github.com/blue-veery-gmbh/spring-rest-2-ts/blob/86b75e9265454049c3162bfba6792607a02491c4/spring-rest2ts-examples/pom.xml#L167