【问题标题】:How to catch JSON Array value in Swagger (PowerApps)如何在 Swagger (PowerApps) 中捕获 JSON 数组值
【发布时间】:2020-09-17 15:17:31
【问题描述】:

我需要一些帮助,我想使用 JSON 一次性将批量记录传递给我的应用程序,但在将其解析为 Swagger 时出现错误。

运气好吗?

这是我的 JSON(它来自 PowerApps 转换为 JSON) ---------------

[
  {
    "ItemId": "2HPB110X-V02",
    "TransferId": "TO-2008-000201"
  },
  {
    "ItemId": "2HPB85X-V02",
    "TransferId": "TO-2008-000201"
  },
  {
    "ItemId": "2HPB134X-V02",
    "TransferId": "TO-2008-000201"
  },
  {
    "ItemId": "2HPB134X-V02",
    "TransferId": "TO-2008-000201"
  }
]

我的网络服务需要像这样通过。 (来自 SWAGGER 的预期输出)

{
  "record": [
    {
      "ItemId": "2HPB110X-V02",
      "TransferId": "TO-2008-000201"
    },
    {
      "ItemId": "2HPB85X-V02",
      "TransferId": "TO-2008-000201"
    },
    {
      "ItemId": "2HPB134X-V02",
      "TransferId": "TO-2008-000201"
    },
    {
      "ItemId": "2HPB134X-V02",
      "TransferId": "TO-2008-000201"
    }
  ]
}

这是我的招摇: --------------------

/api/services/XXXXXServiceGroup/XXXXXService/TestBulkInsertList:
    post:
      responses:
        '200':
          description: Success
          schema: {type: string, title: Message}
      summary: TestBulkInsertList
      operationId: TestBulkInsertList
      parameters:
      - {name: Content-Type, in: header, required: true, type: string, default: application/json}
      - name: body
        in: body
        required: true
        schema:
          type: array
          maxItems: 20
          items: {$ref: '#/definitions/shipNowData'}
definitions:
  shipNowData:
    type: object
    properties:
      transferId: {type: string}
      itemId: {type: string}
    xml: {name: record}
parameters: {}
responses: {}

【问题讨论】:

    标签: arrays json swagger


    【解决方案1】:

    找到了:

    /api/services/XXXXXServiceGroup/XXXXXService/TestBulkInsertList:
        post:
          responses:
            '200':
              description: Success
              schema: {type: string, title: Message}
          summary: TestBulkInsertList
          operationId: TestBulkInsertList
          parameters:
          - {name: Content-Type, in: header, required: true, type: string, default: application/json}
          - name: body
            in: body
            required: true
            schema:
              type: object
              properties:
                record:
                  type: array
                  items: {$ref: '#/definitions/shipNowData'}
          description: TestBulkInsertList
    definitions:
      shipNowData:
        type: object
        properties:
          transferId: {type: string}
          itemId: {type: string}
        xml: {name: record}
    parameters: {}
    responses: {}
    

    【讨论】:

      猜你喜欢
      • 2019-12-21
      • 2021-08-14
      • 2021-09-04
      • 2020-05-30
      • 2017-09-04
      • 2016-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多