swagger-api / swagger-api/swagger-ui

Authorization header is not added to reqest while calling multipart/form-data from swagger UI v3

Open
#9,095 9 comments 0 reactions 0 assignees View on GitHub

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:

  1. Use the above schema
  2. Click on "Try it out" for the /sponsors/{sponsorContext}/documents/upload route which uses a multipart/form-data body
  3. provide values for document name, and upload file in document content.
  4. click on authorize header on top and provide basic auth.
  5. click on execute.
Expected behavior

Authorize header should be send along with the request.

current behavior

Authorize header is missing in the request.

Screenshots

image

image

Additional context or thoughts

multipart/form-data should send Authorize header along with the request for authenticating with server.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.