swagger-api / swagger-api/swagger-codegen
[javascript-closure-angular]File uploads not working
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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