【问题标题】:swagger-ui - open api 3, multipart/form-data array problemswagger-ui - 打开 api 3,multipart/form-data 数组问题
【发布时间】:2019-04-12 06:37:30
【问题描述】:

我正在使用带有 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

【问题讨论】:

  • 您能发布您的 OpenAPI 定义文件吗?
  • 好的,我发了,谢谢

标签: swagger-ui openapi


【解决方案1】:

好的,我找到了解决方案。
我只需要在tags[] 中重命名tags 属性,现在它可以工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-30
    • 1970-01-01
    • 2015-09-19
    • 2015-12-23
    • 2019-06-10
    • 2020-11-08
    • 2014-06-11
    相关资源
    最近更新 更多