-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Javascript] Problems on deserialize text type and on file response #3297
Comments
@donFotter I think you're correct in saying that the Javascript API client does not support plain text response or binary data response at the moment. May I know if you've cycle to contribute a fix to address the issue? Here is a good starting point: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache#L297 |
I'm sorry, but I'm really in trouble with the development of the new api which I'm working on. |
@donFotter that's ok. Thanks again for sharing the fix. We'll see if someone from the community has cycle to contribute a fix. |
I've had a similar problem with an API returning content-type text but in json format. There are two option to fix this: However, of course this will only work for Json data so I'm not sure about unintended side-effects. If agreed upon, I can supply a PR to parse the response.text as JSON as suggested above. This will only be applied if superagent is unable to supply the response.body itself. |
When you've time, please file a PR so that we can review the change. |
Hi,
I'm testing my api on the generated nodejs(javascript) client. I've found two problems, that break the client when called.
First:
when I've a call that return text/plain, SuperAgent initialize the body to {}, so data it's never null and doesn't verify the if condition, and in the end it gives an error.
I've done a fix for my case, just adding this line in the if clauses
"if (data == null || (returnType==='String' && Object.keys(data).length === 0 && data.constructor === Object))" but I think this is a bug and has to be correct
Second:
I've a call where the response is a file
And this is fine on other language like java or ruby, but not on javascript. It gives this error:
Thanks in advance for support
I'm using Swagger-codegen version 2.2.0
The text was updated successfully, but these errors were encountered: