swagger-api / swagger-api/swagger-codegen
[Go] api-client uplaodFile fieldName issue
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Swagger go api-client
Description
In go-client genereated code using swagger-condgen-cli,in the prepareRequest function,
fieldName is hard-coded to "file"
Swagger-codegen version
2.3.1
Swagger declaration file content or url
Line details:w.CreateFormFile("file", filepath.Base(fileName))
file:api_client.go
Here in above line fieldName is hardcoded to file.
Ideally it should be fieldName
part, err := w.CreateFormFile(fieldName, filepath.Base(fileName))
Because of this issue,api_client for upload file is failing with field != "file"
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 with the generated api_client.go file and inspect prepareRequest where CreateFormFile currently receives the hard-coded "file" value. Trace the generator template that produces this line, then verify that uploads using a field name other than "file" use that name successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100