swagger-ui - swagger-ui - 打开 api 3,multipart/form-data 数组问题
问题描述
我正在使用带有 OpenApi 3.0.2 规范的 swagger-ui。
我设置了一个包含多部分/表单数据内容的 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
media-image-fillable.yaml
type: object
allOf:
- $ref: './media-image-base.yaml'
- properties:
file:
type: string
format: binary
tags:
type: array
items:
type: string
和 media-image-base.yaml
type: object
properties:
title:
type: string
back_office_title:
type: string
description:
type: string
alt:
type: string
解决方案
好的,我找到了解决方案。
我只需要在 中重命名tags
属性tags[]
,现在它可以工作了。
推荐阅读
- ios - AVCaptureVideoPreviewLayer 横向帧
- angular - 如何在角度 4 中安装 SignalR
- c# - Xamarin.Forms 项目中的 HtmlAgilityPack 中缺少方法?
- wordpress - 为什么数百张图片从我的上传文件夹中消失了?
- json - 我想导入一个 JSON 文件,并在此过程中使用 JSON 文件中包含的处理函数。
- angular - 从 Angular-Material 项目中删除 HammerJS
- java - Spring Boot 微服务 Intellij 理念
- jquery - Spring Boot 无法接收来自 JQuery 的 POST
- mysql - 波兰语字符无法通过 jdbc MYSQL 插入数据库
- google-app-engine - 如何从项目中完全删除 Cloud Datastore?