首页 > 解决方案 > 为什么 Swagger Schema 中忽略了过滤器属性?

问题描述

我正在尝试构建一个简单的 Swagger 模型:

resources:
  - kind: PlayersDB
    api_version: players/v2
    path: players
    attributes:
    ...
    status:
      - name: status
        type: string
        x-extensible-enum: [HEALTHY, INJURED]
        ...
        example: HEALTHY
        required: true
        filters:
          - type: SearchFilter
            strategy: exact
            include_on:
              - list

由于某种原因,生成的 HTML 不会在查询参数下呈现状态过滤器。这让我觉得我没有正确地做到这一点。

也就是说,当我将架构编辑为:

resources:
  - kind: PlayersDB
    api_version: players/v2
    path: players
    attributes:
    ...
    status:
      - name: status
        type: string
        x-extensible-enum: [HEALTHY, INJURED]
        ...
        example: HEALTHY
        required: true
    filters:
      - property: status
        type: SearchFilter
        field: status
        strategy: exact
        example: HEALTHY
        include_on:
          - list

过滤器被渲染。

一些上下文:对于我正在使用的 spec.yaml -> html redoc-cli(这是 OpenAPI 的 CLI 工具 -> html 包)。

问题是是否可以渲染 #1 或者 OpenAPI 格式不支持它?

我确实阅读了https://swagger.io/docs/specification/adding-examples/Object and Property Examples上的部分,但没有找到很多与过滤器相关的信息。

标签: swaggeropenapiredoc

解决方案


推荐阅读