swagger-api / swagger-api/swagger-client

File Upload http request is missing 'Content-Lenght' header

Open
#1,488 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.7k
Forks
765
Avg merge
1d 1h
Merged PRs (30d)
6

Description

No 'Content-Lenght' header is created by the Swagger Client when binary content upload.

If the 'Content-Lenght' is defined in the swagger definition and provided in the request, the file upload succeeds.

Q&A (please complete the following information)
  • OS: macOS
  • Environment: Node.js v12.5.0
  • Method of installation: npm
  • Swagger-Client version: 3.9.6
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Swagger/OpenAPI definition:

                "requestBody": {
                    "content": {
                        "application/offset+octet-stream": {
                            "schema": {
                                "format": "binary",
                                "type": "string"
                            }
                        }
                    },
                    "description": "The file content (binary) to upload",
                    "required": true
                },

Swagger-Client usage:

SwaggerClient({
  // your config options here
})
Describe the bug you're encountering

No 'Content-Lenght' header is created by the Swagger Client when binary content upload.

To reproduce...

Steps to reproduce the behavior:

  1. Create file upload request with binary content. Provide a stream object in the body.
Expected behavior

The file should be uploaded

Screenshots
Additional context or thoughts

If the 'Content-Lenght' is defined in the swagger definition and provided in the request, the file upload succeeds.

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 by reproducing the OpenAPI 3.0 binary upload in Node.js using a stream body and Swagger Client 3.9.6, then inspect the generated request headers. The work is done when the upload request includes the required Content-Length header and the file upload succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.