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

Codegen for typescript-angular2 - "responseType" is always "ResponseContentType.Json" #4037

Closed
MaciejGit opened this issue Oct 19, 2016 · 4 comments

Comments

@MaciejGit
Copy link
Contributor

MaciejGit commented Oct 19, 2016

Description

While generating typescript-angular2 API, requestOption.responseType is always set to ResponseContentType.Json. This is causing issues when API returns 204 and there is no content to be parsed to json. Angular 2 is trying to parse response according to responseType and failing in this case.

Moreover, extraHttpRequestParams is not applied (parameter is not used).

Another suspicious thing is that "consumes" and "produces" are never used. Shouldn't they be applied in request / response?

ResponseType and extraHttpRequestParams seems to be properly done for typescript-angular.

Swagger-codegen version

2.2.1

Swagger declaration file content or url

http://petstore.swagger.io/v2/swagger.json

Command line used for generation

java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l typescript-angular2 -o c:\temp\ng2_api_client

Steps to reproduce

Run client API generation on Petstore swagger.json - all requestOption.responseType are Json and extraHttpRequestParams is not used.

Related issues
Suggest a Fix

mustache template modification for typescript-angular2 (see typescript-angular as an example)?

@wing328
Copy link
Contributor

wing328 commented Oct 20, 2016

@MaciejGit thanks for reporting the issue.

Another suspicious thing is that "consumes" and "produces" are never used. Shouldn't they be applied in request / response?

We also want to support it. Please refer to the discussion here.

mustache template modification for typescript-angular2 (see typescript-angular as an example)?

May I know if you've time to contribute the enhancement? If yes, I can show you some good starting points.

@wing328 wing328 added this to the v2.2.2 milestone Oct 20, 2016
@MaciejGit
Copy link
Contributor Author

Hi @wing328 - I think I will have time tomorrow, can you send me instructions please?

@wing328
Copy link
Contributor

wing328 commented Oct 21, 2016

@MaciejGit thanks. My comment in #3081 (comment) is a good starting point.

Then you will need to insert the logic here: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache#L65

To test the change, please do the following to update the Petstore sample and verify the change:

mvn clean package
./bin/typescript-angular2-petstore-all.sh

Any question just let me know.

@MaciejGit
Copy link
Contributor Author

Done, see: #4060

Please let me know how does it look like.

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

No branches or pull requests

2 participants