简体   繁体   English

挥舞着数组中的元素列表

[英]swagger with list of elements in an array

I am new to swagger implementation. 我是急于执行的新手。 I have a query parameter 'Geschaeftsvorfall' which can be of string value A or P and when I hit the end point. 我有一个查询参数“ Geschaeftsvorfall”,该参数可以是字符串值A或P,当我到达终点时。 I expect an array[validPsd2Ids] filled with integers. 我期望一个用整数填充的array [validPsd2Ids]。

I have formulated below code and I don't know how to validate it. 我已经制定了以下代码,但我不知道如何验证它。 can someone tell me if I am going wrong some where? 有人可以告诉我我在哪里出错了吗? Also what can I do to print a List instead of array in my response? 另外,我该如何在响应中打印列表而不是数组?

    "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"
                }
              }
            }

          }

            }
          }
        }
      }

The parameter definition is correct. 参数定义正确。

The response definition is not correct. 响应定义不正确。 You say that the response looks like 您说响应看起来像

{"ValidePsd2Ids" : [1,2,3,4,5,6,7,...]}

In OpenAPI terms, this is a type: object with a property ValidePsd2Ids that contains an array of integers. 用OpenAPI术语来说,这是一种type: object ,其属性ValidePsd2Ids包含整数数组。 This can be described as: 这可以描述为:

  "definitions": {
    "ValidePsd2Ids": {
      "type": "object",
      "properties": {
        "ValidePsd2Ids": {
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            100000005,
            100000006,
            100000007
          ]
        }
      }
    }
  },

and the responses should be: responses应该是:

    "responses": {
      "200": {
        "description": "OK",
        "schema": {
          "$ref": "#/definitions/ValidePsd2Ids"
        }
      }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM