-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Description
Q&A (please complete the following information)
- OS: macOS
- Browser: chrome
- Version: 81.0.4044.138 (Official Build) (64-bit)
- Method of installation: dist assets
- Swagger-UI version: 3.10.0 (I've tried several versions and it happens with them all)
- Swagger/OpenAPI version: Swagger 2.0 (Happens with both Swagger 2.0 and OpenAPI 3.0)
Content & configuration
I created an example project on github to demonstrate the issue. https://github.com/mike2184/swagger-ui-test
Swagger UI hosted on GItHub pages here: https://mike2184.github.io/swagger-ui-test/#/pet/uploadFile
Example Swagger/OpenAPI definition:
I'm using https://petstore.swagger.io/v2/swagger.json in the example I created to show this issue.
Swagger-UI configuration options:
const ui = SwaggerUIBundle({
url : "./swagger.yaml",
dom_id : '#swagger-ui',
deepLinking : true,
presets : [ SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset ],
plugins : [ SwaggerUIBundle.plugins.DownloadUrl ],
layout : "StandaloneLayout",
requestInterceptor : function(req) {
// Having the following line of code that adds a header causes the generated curl request to change from
// -F "file=@cake.jpg;type=image/jpeg" to -d {"file":{}}
req.headers['x-test-header'] = 'test value';
return req;
}
})Describe the bug you're encountering
If I make any changes to the headers using the requestInterceptor it changes the file upload in the generated curl request from -F "file=@cake.jpg;type=image/jpeg" to -d {"file":{}}
To reproduce...
Steps to reproduce the behavior:
- Go to https://mike2184.github.io/swagger-ui-test/#/pet/uploadFile
- Click Try it out for /pet/{petId}/uploadImage API
- Set petId to 1
- Click choose file and select any image file
- Click execute
- Notice: generated curl request has -d {"file":{}} instead of -F "file=@cake.jpg;type=image/jpeg"
Expected behavior
Generated curl request should be -F "file=@cake.jpg;type=image/jpeg"
Screenshots
Metadata
Metadata
Assignees
Labels
No labels
