feat: respect Encoding Object while building requests (#9105)

This change fixes both:

1. making multipart/form-data requests with content-type
   header for every individual boundary
2. generating correct CURL command for multipart/form-data
   request, allowing specifying content-type header for every
   individual boundary

Refs #4826
Refs #5356
This commit is contained in:
Vladimír Gorej
2023-08-01 15:20:22 +02:00
committed by GitHub
parent 9caa5e88b0
commit b2814737d6
5 changed files with 321 additions and 283 deletions

View File

@@ -111,7 +111,18 @@ const curlify = (request, escape, newLine, ext = "") => {
addNewLine()
addIndent()
addWordsWithoutLeadingSpace("-F")
if (v instanceof win.File) {
/**
* SwaggerClient produces specialized sub-class of File class, that only
* accepts string data and retain this data in `data`
* public property throughout the lifecycle of its instances.
*
* This sub-class is exclusively used only when Encoding Object
* is defined within the Media Type Object (OpenAPI 3.x.y).
*/
if (v instanceof win.File && typeof v.valueOf() === "string") {
addWords(`${extractedKey}=${v.data}${v.type ? `;type=${v.type}` : ""}`)
} else if (v instanceof win.File) {
addWords(`${extractedKey}=@${v.name}${v.type ? `;type=${v.type}` : ""}`)
} else {
addWords(`${extractedKey}=${v}`)