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

Can't Produce Observable Service #28

Open
sotg-duncan-idaho opened this issue Feb 23, 2022 · 1 comment
Open

Can't Produce Observable Service #28

sotg-duncan-idaho opened this issue Feb 23, 2022 · 1 comment

Comments

@sotg-duncan-idaho
Copy link

sotg-duncan-idaho commented Feb 23, 2022

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?

@tomasz-wozniak75
Copy link
Contributor

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

patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants