swagger-api / swagger-api/swagger-codegen

[Python] parameter type 'file' not handled correctly

Open
#7,935 4 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

Description

parameter type 'file' not proper handled. The generated code contains one line

from swagger_client.models.file import file
Swagger-codegen version

2.3.1

Swagger declaration file content or url

If you post the code inline, please wrap it with

  /media/web/upload:
    post:
      responses:
        default:
      parameters:
        - type: file
          name: media
          in: formData
      consumes:
        - multipart/form-data
Command line used for generation

swagger-codegen generate -i /tmp/openapi2.0.json -l python

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

Reproduce the issue with the supplied Swagger declaration and the swagger-codegen generate -i /tmp/openapi2.0.json -l python command. Trace the Python generator or template handling formData parameters of type file, then regenerate and verify that the reported swagger_client.models.file import is no longer emitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.