swagger-js icon indicating copy to clipboard operation
swagger-js copied to clipboard

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

Open PiotrNestor opened this issue 5 years ago • 0 comments

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.

PiotrNestor avatar Dec 09 '19 12:12 PiotrNestor