swagger-api / swagger-api/swagger-ui
Authorization header is not added to reqest while calling multipart/form-data from swagger UI v3
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: Windows, linux
- Browser: chrome
- Version: 114.0.5735.199
- Method of installation: docker compose
- Swagger-UI version: 4.18.2
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Example Swagger/OpenAPI definition:
{
"openapi" : "3.0.1",
"info" : {
"title" : "IBM PEM REST API Documentation ",
"description" : "API document for IBM PEM Services.\n
"
},
"externalDocs" : { },
"servers" : [ {
"url" : "https://localhost:9443/mrmws"
}, {
"url" : "http://st:8080/apis"
}, {
"url" : "https://localhost:9444/mrmws"
}, {
"url" : "/"
} ],
"security" : [ {
"basicAuth" : [ ]
} ],
"tags" : [ {
"name" : "System Configuration Type Services"
}, {
"name" : "Code Services"
}, {
"name" : "CodeList Services"
}, {
"name" : "CodeList Type Services"
} ],
"paths" : {
"/sponsors/{sponsorContext}/documents/upload" : {
"post" : {
"security": [
{
"basicAuth": []
}
],
"tags" : [ "Document Services" ],
"summary" : "Upload Document",
"description" : "Service for uploading documents.",
"operationId" : "documentUpload",
"parameters" : [ {
"name" : "dualUriPattern",
"in" : "path",
"description" : "uri pattern: possible values (sponsor|partner)",
"required" : true,
"style" : "simple",
"explode" : false,
"schema" : {
"type" : "string"
}
}, {
"name" : "sponsorContext",
"in" : "path",
"description" : "The sponsor context URI (short name to identify the company).",
"required" : true,
"style" : "simple",
"explode" : false,
"schema" : {
"type" : "string"
}
} ],
"requestBody" : {
"content" : {
"multipart/form-data" : {
"schema" : {
"required" : [ "documentCategory", "documentContents", "documentName" ],
"type" : "object",
"properties" : {
"documentCategory" : {
"type" : "string",
"description" : "The category of the document.",
"enum" : [ "LOGO", "ACTIVITY" ]
},
"documentContents" : {
"type" : "string",
"description" : "Upload the required document. The file size limit is 2MB.",
"format" : "binary"
},
"documentName" : {
"description" : "Name of the document."
},
"isEncrypted" : {
"type" : "string",
"description" : "The document is encrypted.",
"default" : "TRUE",
"enum" : [ "TRUE", "FALSE" ]
},
"partnerKey" : {
"description" : "Unique key to identify the partner."
}
}
}
}
},
"required" : true
},
"responses" : {
"200" : {
"description" : "Successful",
"content" : { }
},
"400" : {
"description" : "Bad request",
"content" : { }
},
"500" : {
"description" : "Internal Failure",
"content" : { }
}
}
}
},
"components" : {
"schemas" : {
"securitySchemes" : {
"BasicAuthentication" : {
"type" : "http",
"scheme" : "basic"
}
},
"security": [
{
"basicAuth": []
}
]
}
}
Steps to reproduce the behavior:
- Use the above schema
- Click on "Try it out" for the /sponsors/{sponsorContext}/documents/upload route which uses a multipart/form-data body
- provide values for document name, and upload file in document content.
- click on authorize header on top and provide basic auth.
- click on execute.
Expected behavior
Authorize header should be send along with the request.
current behavior
Authorize header is missing in the request.
Screenshots
Additional context or thoughts
multipart/form-data should send Authorize header along with the request for authenticating with server.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the multipart/form-data request in Swagger UI using the provided OpenAPI definition and the /sponsors/{sponsorContext}/documents/upload route. Inspect the generated request after authorizing with Basic Authentication; done means the Authorization header is included when the multipart request is executed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api, authentication, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100