swagger-api / swagger-api/swagger-codegen

[javascript-closure-angular]File uploads not working

Open
#6,875 1 comment 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

Description

The javascript-closure-angular client generated by swagger maven plugin and online swagger editor can’t upload file.

Swagger-codegen version

online swagger editor and swagger maven plugin version 2.2.2

Swagger declaration file content or url
put:
      consumes:
        - multipart/form-data
      parameters:
        - name: name
          in: query
          required: true
          type: string
        - name: schemaVersion
          in: query
          required: true
          type: string
        - name: dataVersion
          in: query
          required: true
          type: string
        - name: file
          in: formData
          required: true
          type: file
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
 formParams['file'] = file;
  /** @type {!Object} */
  var httpRequestParams = {
    method: 'PUT',
    url: path,
    json: false,
        data: this.httpParamSerializer(formParams),
    params: queryParameters,
    headers: headerParams
  };
Command line used for generation

io.swagger
swagger-codegen-maven-plugin
${swagger-codegen-maven-plugin.version}



generate


${basedir}/../csputility/src/main/resources/api/servorch.yaml
javascript-closure-angular
${basedir}/src/main/webapp/lib/swagger/


Suggest a fix/enhancement

When I upload the file ,the response status code is always 415,and I can't push any file.
The generated client of angular for file uploading is different form $http in traditional angular,because the troditional one works well.

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

Start by reproducing the generated javascript-closure-angular client from the provided multipart/form-data Swagger declaration using swagger-codegen 2.2.2 and the swagger-codegen-maven-plugin. Compare the generated request configuration with the working traditional Angular upload behavior, then verify that the request uses the declared multipart content type and accepts the file upload without a 415 response.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.