'How to configure/define file upload in POST req in Stoplight Studio - for OpenAPI documentation
[Please bear with me, I'm completely new to APIs, OpenAPI and Stoplight Studio.]
BACKGROUND FOR THE QUESTION
I am using Stoplight Studio to implement OpenAPI documentation for a POST request, which involves a file upload.
This is what my FormData looks like:
body:{"displayName":"exampleFileCSV","fields":[/*<<content from my fileupload>>*/]}
uploadFile: (binary)
This is what my Postman POST request looks like:
QUESTION:
I'm not able to figure out how to reproduce the same request in Stoplight Studio to document the API in OpenAPI. I need to configure the post request with the formData:{body, fileUpload}:
If that's not possible, I would like to know how it is implemented in swagger.json alone.
Solution 1:[1]
Though there is no way in stoplight studio to implement this, there is a SIMPLE SOLUTION to code it in swagger.json file.
schema:
type: string
format: binary
https://swagger.io/docs/specification/describing-request-body/file-upload/
You can define a property under content as string in stoplight studio and make the change of adding the 'format: binary' in swagger.json code. Stoplight studio will respect the change without overriding it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | anik4404 |


