swagger-api/swagger-codegen

[javascript-closure-angular]File uploads not working

Open

#6,875 创建于 2017年11月3日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)HTML (5,474 fork)batch import
Client: JavaScript/Node.jsIssue: Bughelp wanted

仓库指标

Star
 (12,701 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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.

贡献者指南