swagger-api / swagger-api/swagger-codegen

[Javascript] Problems on deserialize text type and on file response

Open
#3,297 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: JavaScript/Node.js help wanted Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

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.
deserialize
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
file
And this is fine on other language like java or ruby, but not on javascript. It gives this error:
file2

Thanks in advance for support

I'm using Swagger-codegen version 2.2.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce both failures with the generated Node.js client using an API response of text/plain and another returning a file. Start by inspecting the generated JavaScript deserialization and file-response handling, then verify that text responses and file responses complete without the reported errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.