当我执行OpenAPI规范中的调用时,它将在参数部分而不是formData中放置文件数组。这样,它就可以读取为字符串而不是数组。
我尝试在邮递员中执行相同的请求。在Postman中,该调用有效,但在招摇中,它被放入参数部分,如下所示:"[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图像应位于此处。
答案 0 :(得分:1)
您的注释看起来正确。这是Swagger UI的问题–当前(截至2019年6月),它不支持包含文件数组的OAS3多部分请求。请关注此问题以获取状态更新:
https://github.com/swagger-api/swagger-ui/issues/4600