JsonPath - 在 swagger 文件中的子级过滤器

问题描述 投票:0回答:1

您好,这是我的 swagger 文件的非常简短的示例。 我想找到具有x-policy且peerName的值为social的路径。我尝试了很多 jsonpath 但都遇到了错误。我在https://jsonpath.com进行了测试 最终结果必须是 {"/nzh/manage/contact/addContacts/","/nzh/biz/addProduct/","/nzh/subProductList/"}

{
  "swagger": "2.0",
  "paths": {
    "/nzh/manage/contact/addContacts/": {
      "put": {
        "tags": [
          "contact",
          "admin_operations"
        ],
        "summary": "",
        "operationId": "addContactsForAdmin",
        "x-policy": {
          "peerName": "social"
        }
      }
    },
    "/nzh/manage/customerClubProviderList/": {
      "get": {
        "tags": [
          "admin_operations"
        ],
        "summary": "",
        "operationId": "getAuthorizedIpList_1"
      }
    },
    "/nzh/biz/transferToContact/": {
      "get": {
        "tags": [
          "wallet"
        ],
        "summary": "",
        "operationId": "transferToContactByBusiness"
      }
    },
    "/nzh/biz/defineDiscountPercentageVoucherBrief/": {
      "get": {
        "tags": [
          "voucher"
        ],
        "summary": "",
        "operationId": "defineDiscountPercentageVoucherBrief",
        "security": [
          {
            "semi-private": []
          }
        ]
      }
    },
    "/nzh/biz/addProduct/": {
      "post": {
        "tags": [
          "market"
        ],
        "summary": "",
        "operationId": "addProduct",
        "x-policy": {
          "peerName": "social"
        }
      }
    },
    "/nzh/subProductList/": {
      "get": {
        "tags": [
          "market"
        ],
        "summary": "",
        "operationId": "subProductList",
        "security": [
          {
            "public": []
          }
        ],
        "x-policy": {
          "peerName": "social"
        }
      }
    }
  }
}
json filter jsonpath
1个回答
0
投票

这是我的一位同事找到的适当的 jsonPath。我希望对其他人有帮助。

$.paths...x-policy[?(@ == 'social')]^^^^^~
© www.soinside.com 2019 - 2024. All rights reserved.