如何在 Swagger 中正确定义数组的查询参数输入,以便在 UI 中显示输入字段?

How to properly define query param input of array in Swagger so input fields shows in UI?

提问人:Juraj Zovinec 提问时间:11/17/2023 更新时间:11/17/2023 访问量:10

问:

我想更新我的 Swagger,以输入字段将显示在 Swagger 的 UI 中。输入字段应接受包含逗号分隔的子字符串(角色 ID)的字符串。 我怎样才能实现它?Swagger 甚至支持这样的功能吗?

enter image description here

架构:

{
  "components": {},
  "info": {
    "contact": {},
    "description": "Offers user-related information.",
    "title": "User feature",
    "version": "1.0"
  },
  "openapi": "3.0.0",
  "paths": {
    "/user/user-management/find-users": {
      "get": {
        "operationId": "FIND_USERS",
        "parameters": [
          {
            "name": "roleIds",
            "required": false,
            "in": "query",
            "schema": {
              "minItems": 1,
              "nullable": false,
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "content": {},
            "description": "Retrieve a list of users."
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "http://localhost:3000"
    }
  ]
}
Swagger Swagger-UI

评论


答: 暂无答案