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
  • #3944
Closed
Open
Issue created Sep 24, 2019 by Administrator@rootContributor

TypeScript (Node): Better support for binary upload and download

Created by: clemens-smartparking

Is your feature request related to a problem? Please describe.

When having a form data parameter, e.g.:

{
    "name": "file",
    "required": true,
    "in": "formData",
    "description": "",
    "type": "file"
}

the generated API simply takes a Buffer object. However, I think it would be nice to support the other request options, especially the one to pass meta data along with the file (also see the example on https://github.com/request/request in the 'multipart/form-data (Multipart Form Uploads)' section).

When downloading a file the generated API seems to ignores the produces swagger spec, e.g. when using:

"produces": [
    "application/octet-stream"
],

the request is done with application/json (or am I doing something wrong?)

Describe the solution you'd like

This is how I currently do the file upload and download:

  const part = {
        value: Buffer.from('Test file content'),
        options: {
            filename: 'filename'
        }
  }
  const putResponse = await api.filePut(part as any);

  const getResponse = await api.filesGet(putResponse.body.uri,
    {
      headers: {
        Accept: 'application/octet-stream'
      }
    });

There are two hacks here:

  1. the part object is cast to any because the api expect a Buffer (it works anyway)
  2. the Accept: 'application/octet-stream' header must be passed in manually
Assignee
Assign to
Time tracking