docusaurus-openapi-docs icon indicating copy to clipboard operation
docusaurus-openapi-docs copied to clipboard

Missing boundary in Content-Type when multipart/form-data

Open AchrafAmil opened this issue 2 years ago • 7 comments

Describe the bug

The interactive Prism console for upload endpoint doesn't seem to make the right call for endpoints with content-type multipart/form-data

Expected behavior

Expects the call made from the console to specify a boundary (otherwise the server receiving the request fails with a legit java.io.IOException: Failed to parse multipart: Content-Type's boundary parameter is missing).

Current behavior

The request it makes when hitting the "send api request" seems malformatted.

Possible solution

Specify the boundary, e.g. content-type: multipart/form-data; boundary=------WebKitFormBoundaryF6sSRjfPR0gJB7xK

Steps to reproduce

  1. Go to https://docs.nabla.com/server/copilot-listen-from-file
  2. (you don't care about having a working api key or even about specifying correct values for the rest of the fields)
  3. Drag & drop a random file, and inspect the network request it makes.
  4. The request body is multi-part and has a boundary but it's not specified in the content-type header.

Screenshots

image

Untitled

Your Environment

  • Version used:
    "@asyncapi/generator": "^1.10.9",
    "@docusaurus/core": "^2.4.1",
    "@docusaurus/preset-classic": "^2.4.1",
    "@mdx-js/react": "^1.6.22",
    "clsx": "^1.1.1",
    "docusaurus-plugin-openapi-docs": "^2.0.0-beta.3",
    "docusaurus-theme-openapi-docs": "^2.0.0-beta.3",
    "prism-react-renderer": "^1.3.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "html-loader": "^4.2.0"
  • Environment name and version Chrome 117.0.5938.92 arm64
  • Operating System and version: macOS Ventura 13.3.1
  • Link to your project: docs.nabla.com

AchrafAmil avatar Oct 05 '23 15:10 AchrafAmil

:tada: Thanks for opening your first issue here! Welcome to the community!

Hi @AchrafAmil, did #625 address your issue?

sserrata avatar Oct 18 '23 14:10 sserrata

Thanks for sharing, I didn't know about #625. Just upgraded to beta-4 to have it and it seems to fix the boundary issue: image

But it now doesn't include the json string item in the FormData (request_parameters).

As you can see in the screenshot the body doesn't include the request_parameters as it used to in the beta3.

image

AchrafAmil avatar Oct 18 '23 17:10 AchrafAmil

Tested with the new stable 2.0.0:

    "@docusaurus/core": "^2.4.3",
    "@docusaurus/preset-classic": "^2.4.3",
    "docusaurus-plugin-openapi-docs": "^2.0.0",
    "docusaurus-theme-openapi-docs": "^2.0.0",

and I'm still facing the same problem as my previous comment (it does not include the json string item in the FormData).

@sserrata let me know if you need any more details on this

AchrafAmil avatar Nov 24 '23 10:11 AchrafAmil

Hi @AchrafAmil can you test again using 2.0.1? Thanks!

sserrata avatar Dec 01 '23 18:12 sserrata

Now it's working, wow awesome, thanks a lot! 🎉

(I'll let you decide if we can already close this issue, etc)

AchrafAmil avatar Dec 08 '23 12:12 AchrafAmil

Though, now that I succeed in uploading a file I start hitting the 5 secs timeout pretty easily... Is there any way to override the timeout other than the hardcode swizzle from #327 and #351 ? 🙏

Because doing an eject swizzle for ApiExplorer/Request breaks my docs: image image

AchrafAmil avatar Dec 08 '23 13:12 AchrafAmil