swagger-api / swagger-api/swagger-codegen

[Go] api-client uplaodFile fieldName issue

Open
#9,522 0 comments 0 reactions 0 assignees View on GitHub

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.