gpt4 book ai didi

javascript - 通过参数而不是 formData 发送图像数组,如何更改它?

转载 作者:行者123 更新时间:2023-11-29 22:57:06 25 4
gpt4 key购买 nike

当我执行 OpenAPI 规范中的调用时,它会在参数部分而不是 formData 中放置一个文件数组。这样它就被读取为字符串而不是数组。

我尝试在 Postman 中执行相同的请求。在 Postman 中,调用有效,但在 swagger 中,它被放入参数部分,如下所示:"[object File]"。在浏览器控制台中,我试图查看它发送的内容,但那只是数组。所以我不知道为什么它被转换为字符串或者为什么它被放入参数而不是 formData。

这是 openapi yaml:

/**
* @openapi
* /routes:
* post:
* summary: Create a route
* tags:
* - Routes
* security:
* - CustomToken: []
* requestBody:
* content:
* multipart/form-data:
* schema:
* type: object
* required:
* - images
* - track
* properties:
* images:
* type: array
* minItems: 1
* maxItems: 3
* items:
* type: string
* format: binary
* track:
* type: string
* format: binary
* parameters:
* - name: name
* description: Name of the route.
* in: query
* required: true
* schema:
* type: string
* example: Utrecht naar Den Bosch
* - name: description
* description: Description of the route.
* in: query
* required: true
* schema:
* type: string
* example: Een route die langs de prachtigste punten gaat op de route van utrecht naar Den Bosch.
* - name: price
* description: The price of the route using the purchasable coins as the currency.
* in: query
* required: true
* schema:
* type: integer
* minimum: 0
* example: 1
* - name: rating
* description: The rating the route has been given.
* in: query
* required: false
* schema:
* type: integer
* minimum: 1
* maximum: 5
* example: 5
* - name: tags
* description: The tags that define if the route contains dikes, forests, mountains or cities. To select multiple values hold ctrl and click on the values you want.
* in: query
* required: true
* schema:
* type: array
* minItems: 1
* maxItems: 4
* uniqueItems: true
* items:
* type: string
* enum:
* - Dike
* - Forest
* - Mountain
* - City
* example:
* - Dike
* - Forest
* responses:
* 200:
* description: succesfully created a route
*/

Parameters正如您在此图片中看到的,参数部分包含图像。

File/formData图片应该在这里。

最佳答案

您的注释看起来是正确的。

确保您使用的是 Swagger UI v. 3.26.0 或更高版本。早期版本 did not support上传文件数组。

关于javascript - 通过参数而不是 formData 发送图像数组,如何更改它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56458967/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com