首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用数组中的元素列表进行摆动

使用数组中的元素列表进行摆动
EN

Stack Overflow用户
提问于 2018-09-05 21:41:22
回答 1查看 978关注 0票数 0

我对swagger实现还是个新手。我有一个查询参数'Geschaeftsvorfall‘,它可以是字符串值A或P,当我到达终点时。我期望的是一个充满整数的arrayvalidPsd2Ids。

我已经制定了下面的代码,我不知道如何验证它。有没有人能告诉我,如果我在哪里出错了?另外,如何在响应中打印列表而不是数组?

代码语言:javascript
复制
    "parameters": {
      "Geschaeftsvorfall": {
      "name": "Geschaeftsvorfall",
      "in": "query",
      "description": "Geschaeftsvorfall",
      "required": true,
      "type": "string",
      "enum": [
        "A",
        "P"

      ]
    }
  },
                  "definitions": {
                  "ValidePsd2Ids": {
                    "type": "array",
                      "items": {
                       "properties": {
                     "ValidePsd2Ids": {
                      "type": "integer",
                         example: [100000005,
                          100000006,
100000007,
100000008,
100000009,
100000010,
100000011,
100000012,
100000013,
100000014,
100000015,
100000016,
100000017,
100000018,
100000019,
100000020,
100000021,
100000022,
100000023,
100000024,
100000025,
100000034,
100000035,
100000036,
100000037,
100000038,
100000039,
100000048,
100000049,
100000050,
100000054,
100000055,
100000056,
100000057,
100000058,
100000117,
100000163,
100000165,
100000195,
100000196,
100000197,
100000198,
100000199,
100000201,
100000214,
100000217,
100000218]
              }
            }
          }

    }
    },

    "paths": {
    "/payments/validaccounttypes/": {
      "get": {
        "tags": [
          "payments"
        ],
        "summary": "Valid PSD2 relevant accounts",
        "description": "Reads the list of valid PSD2 revelant IDs.",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "$ref": "#/parameters/Geschaeftsvorfall"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
               "items": {
            "properties": {
              "ValidePsd2Ids": {
                "type": "integer"
              }
            }
          },
              "properties": {
                "ValidePsd2Ids": {
                  "$ref": "#/definitions/ValidePsd2Ids"
                }
              }
            }

          }

            }
          }
        }
      }
EN

回答 1

Stack Overflow用户

发布于 2018-09-06 00:47:14

参数定义正确。

响应定义不正确。你说响应看起来像这样

代码语言:javascript
复制
{"ValidePsd2Ids" : [1,2,3,4,5,6,7,...]}

在OpenAPI术语中,这是一个具有包含整数数组的属性ValidePsd2Idstype: object。这可以描述为:

代码语言:javascript
复制
  "definitions": {
    "ValidePsd2Ids": {
      "type": "object",
      "properties": {
        "ValidePsd2Ids": {
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            100000005,
            100000006,
            100000007
          ]
        }
      }
    }
  },

responses应该是:

代码语言:javascript
复制
    "responses": {
      "200": {
        "description": "OK",
        "schema": {
          "$ref": "#/definitions/ValidePsd2Ids"
        }
      }
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52186624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档