Open sotg-duncan-idaho opened 2 years ago
Hey
Based on your controller signature I created example, please apply attached patch (created by intelij) next execute example com.blueveery.springrest2ts.examples.test.TsCodeGenerationsTest#customTypeMapping
at the end in the console You will have link to the generated file ctrls-spring.ts
, please open it and search for RegistrationCtrl
. I have following result:
public createRegistration(registration: RegistrationRequest): Observable<RegistrationRequest> { const headers = new HttpHeaders().set('Content-type', 'application/json'); return this.httpService.post('api/product/some/path', JSON.stringify(registration), { headers, responseType: 'text' }).pipe(map(res => JSON.parse(res))); }
Please let me know if You have the same content. If yes You can find desired config in com.blueveery.springrest2ts.examples.test.TsCodeGenerationsTest#customTypeMapping
Tomasz
Hello,
I'm having a bit of trouble getting started. I have followed the example trying to produce and observable based service but the output is not as expected. I am using the example code provided on the HOWTO to configure an "Angular4ImplementationGenerator"
The output is:
public createRegistration(arg1: RegistrationRequest): RegistrationRequest { const headers = new HttpHeaders().set('Content-type', 'application/json'); return this.httpService.post('/sec/registrations/create', JSON.stringify(arg1) , {headers, responseType: 'text'}).pipe(map(res => JSON.parse(res))); }
instead of the desired:
public createRegistration(arg1: RegistrationRequest): Observable<RegistrationRequest> { const headers = new HttpHeaders().set('Content-type', 'application/json'); return this.httpService.post<RegistrationRequest>('/sec/registrations/create', arg1 , {headers, responseType: 'text'}); }
My MVC Controller definition is:
@PostMapping(path = PATH_CREATE_REGISTRATION, produces = "application/json") @ResponseBody @ResponseStatus(HttpStatus.CREATED) public RegistrationRequest createRegistration(HttpServletRequest httpRequest, @RequestBody RegistrationRequest registration) throws Exception {
What am I doing wrong?