swagger-ui——打开api 3、multipart/form-data数组问题
swagger-ui - open api 3, multipart/form-data array problem
我ui使用 OpenApi 3.0.2 规范ui大摇大摆-ui。
我设置了一个包含 multipart/form-data 内容的 requestBody。
当我执行来自 swagger-ui 的请求时一切正常,但是...
如果我添加一个数组类型的参数,它会在 curl 调用中转换成这样:
-F "tags=my,tag"
我需要分解数组
-F 'tags[]=my' \
-F 'tags[]=tag'
我查看了文档并找到了一些样式和爆炸属性,但它们仅适用于参数属性,不适用于 requestBody (?)。
在我的路线文件中:
post:
tags:
- media-image
summary: Create a media image
requestBody:
description: A JSON object containing media image information
required: true
content:
multipart/form-data:
schema:
allOf:
- $ref: '../schemas/media-image-fillable.yaml'
- required:
- title
- back_office_title
- alt
- file
媒体图片-fillable.yaml
type: object
allOf:
- $ref: './media-image-base.yaml'
- properties:
file:
type: string
format: binary
tags:
type: array
items:
type: string
和媒体图像-base.yaml
type: object
properties:
title:
type: string
back_office_title:
type: string
description:
type: string
alt:
type: string
好的,我找到了解决方案。
我只需要在 tags[]
中重命名 tags
属性,现在可以了。
我ui使用 OpenApi 3.0.2 规范ui大摇大摆-ui。
我设置了一个包含 multipart/form-data 内容的 requestBody。
当我执行来自 swagger-ui 的请求时一切正常,但是...
如果我添加一个数组类型的参数,它会在 curl 调用中转换成这样:
-F "tags=my,tag"
我需要分解数组
-F 'tags[]=my' \
-F 'tags[]=tag'
我查看了文档并找到了一些样式和爆炸属性,但它们仅适用于参数属性,不适用于 requestBody (?)。
在我的路线文件中:
post:
tags:
- media-image
summary: Create a media image
requestBody:
description: A JSON object containing media image information
required: true
content:
multipart/form-data:
schema:
allOf:
- $ref: '../schemas/media-image-fillable.yaml'
- required:
- title
- back_office_title
- alt
- file
媒体图片-fillable.yaml
type: object
allOf:
- $ref: './media-image-base.yaml'
- properties:
file:
type: string
format: binary
tags:
type: array
items:
type: string
和媒体图像-base.yaml
type: object
properties:
title:
type: string
back_office_title:
type: string
description:
type: string
alt:
type: string
好的,我找到了解决方案。
我只需要在 tags[]
中重命名 tags
属性,现在可以了。