Open ruwiniwj opened 5 years ago
@ruwiniwj, I'm not able to reproduce this.
Here's your definition loaded into the latest version (v3.22.1) of Swagger UI: http://petstore.swagger.io/?url=https://gist.githubusercontent.com/shockey/59c8d8637fc098b20e59f039ac1a56d5/raw/f2259915ba3d9a29ff28e089376659efbdb2afef/5284.yaml#/default/post_file
I tried executing the operation, and I got this cURL command:
curl -X POST "https://gist.githubusercontent.com/file" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "file=@package.json;type=application/json"
Hi @shockey,
We have upgraded the swagger-ui version to 3.22.1, but the issue is still there. In our application, we are using javascript library to populate the swagger UI and following is the code segment we have used to embed the swagger UI within our application. Can you please check this?
window.swaggerUI = SwaggerUIBundle({
url: url,
dom_id: '#swagger-ui-container',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis
],
plugins: [
function() {
return {
components: {
Models: function() {
return null;
},
schemes: function() {
return null;
},
authorizeBtn: function() {
return null;
},
info: function() {
return null;
},
Servers: function() {
return null;
}
}
}
}
]
});
When creating an API resource with a multipart/form-data file upload parameter, the swagger editor and the swagger-UI generates the cURL commands differently.
Q&A (please complete the following information)
Example Swagger/OpenAPI definition:
Describe the bug you're encountering
When an API is created from the swagger file provided, the swagger-UI will generate the cURL as follows
curl -k -X POST "https://host:port/test/v1/file" -H "accept: application/json" -H "Content-Type: multipart/form-data" -H "Authorization: Bearer d779534f-ff49-357f-a9e6-64be590df7e6" -d {"file":{}}
However, the swagger editor generates the cURL in the following format;
curl -X POST "https://host:port/file" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "file=@image.png;type=image/png"
The swagger-UI presents the file data as
-d {"file":{}}
where as the swagger editor presents it as-F "file=@image.png;type=image/png"