如何在 Stoplight Studio 的 POST 请求中 configure/define 上传文件 - 用于 OpenAPI 文档

How to configure/define file upload in POST req in Stoplight Studio - for OpenAPI documentation

[请耐心等待,我是 APIs、OpenAPI 和 Stoplight Studio 的新手。]

问题背景

我正在使用 Stoplight Studio 为 POST 请求实施 OpenAPI 文档,其中涉及文件上传。

这是我的 FormData 的样子:

body:{"displayName":"exampleFileCSV","fields":[/*<<content from my fileupload>>*/]}
uploadFile: (binary)

这是我的 Postman POST 请求的样子:

问题:

我无法弄清楚如何在 Stoplight Studio 中重现相同的请求以记录 OpenAPI 中的 API。我需要使用 formData:{body, fileUpload}:

配置 post 请求

如果那不可能,我想知道它是如何单独在 swagger.json 中实现的。

虽然在 stoplight studio 中没有办法实现这个,但有一个简单的解决方案可以在 swagger.json 文件中对其进行编码。

      schema:
    type: string
    format: binary

https://swagger.io/docs/specification/describing-request-body/file-upload/

您可以在 content as string 中定义一个 属性 并在 swagger.json 代码中添加 'format: binary' 进行更改。 Stoplight studio 将尊重更改而不覆盖它。