Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #10773
Closed
Open
Issue created Nov 04, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [Python] Incorrect name attribute when uploading file / form data

Created by: plague006

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Uploads to API endpoints were not working. The server says that no file was uploaded. I traced the cause to

openapi-generator version

5.3.0 (since at least 5.1.X)

OpenAPI declaration file content or url

Full spec: https://cs.business.stingray.com/assets/swagger.yaml

Relevant snippet:

    post:
      parameters:
        - in: formData
          name: file-en
          type: file
          required: false
Generation Details

--generator-name python

Steps to reproduce

Attempt to upload a file, note that the name sent is file_en and not file-en.

Related issues/PRs
Suggest a fix

I was able to get things working by changing params['file'][param_name] = [param_value] to params['file'][base_name] = [param_value] in api_client.py:745 and api_client.py:749 of my generated client. In the api_client mustache, that would be: https://github.com/OpenAPITools/openapi-generator/blob/b3ec7faa8fc55d89f8df5ccc7e394fb8cb87f299/modules/openapi-generator/src/main/resources/python/api_client.mustache#L765-L769

Assignee
Assign to
Time tracking