1

[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:

Postman POST request I am using

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}:

Stoplight Studio

If that's not possible, I would like to know how it is implemented in swagger.json alone.

Helen
  • 87,344
  • 17
  • 243
  • 314
red_wolf
  • 77
  • 13

2 Answers2

0

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.

red_wolf
  • 77
  • 13
0

You have to click in the "string" type and select in the "Format" field the "binary" type.

enter image description here

karrtojal
  • 796
  • 7
  • 16