简体   繁体   English

逻辑应用程序中的 HTTP + swagger - 解析模式

[英]HTTP + swagger in logic app - parsing the schema

I am using HTTP+Swagger to make API call(hosted in APIM gateway) in logic app.我正在使用 HTTP+Swagger 在逻辑应用程序中进行 API 调用(托管在 APIM 网关中)。

In Logic app we can use the parse Json to parse the schema and it provide us access to the individual element of the JSON payload(which we can use in downstream logic).在逻辑应用程序中,我们可以使用解析器 Json 来解析模式,它使我们能够访问 JSON 有效负载(我们可以在下游逻辑中使用)的单个元素。 But we have to manually paste the schema in the schema field of parseJson activity.但是我们必须手动将模式粘贴到 parseJson 活动的模式字段中。

I want to automate the process.我想自动化这个过程。 I am looking a way where I can collect the Json schema in a variable and then parse my Json through this variable(schema).我正在寻找一种方法,我可以在一个变量中收集 Json 模式,然后通过这个变量(模式)解析我的 Json。 This will help me not to make manual interferences with logic app in case of change in schema.这将帮助我避免在架构发生变化时手动干扰逻辑应用程序。

Any help much appreciated.非常感谢任何帮助。

Thanks,谢谢,

You don't really have to manually write the JSON schema but you just need a sample of the JSON that you want to parse.您实际上不必手动编写 JSON 架构,但您只需要要解析的 JSON 的示例。 Consider here is some sample考虑这里是一些样本

[
  {
    "document": "A",
    "min": 7500001,
    "policy": "X"
  },
  {
    "document": "B",
    "min": 7500001,
    "policy": "Y"
  },
  {
    "document": "C",
    "min": 7500001,
    "policy": "Z"
  },
{
    "document": "D",
    "min": 7500002,
    "policy": "X"
  }
]

So you need to use Use sample payload to generate schema .所以你需要使用Use sample payload to generate schema

在此处输入图像描述

在此处输入图像描述

and then you will be automatically have generated schema然后您将自动生成架构

在此处输入图像描述

Below is the generated schema下面是生成的架构

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "document": {
                "type": "string"
            },
            "min": {
                "type": "integer"
            },
            "policy": {
                "type": "string"
            }
        },
        "required": [
            "document",
            "min",
            "policy"
        ]
    }
}

Updated Answer更新的答案


So, This would work even when you have a JSON change just remove the required from the schema and this would work perfectly when you are trying to use the same parameters as before.因此,即使您进行了 JSON 更改,这也可以正常工作,只需从架构中删除所需的内容,并且当您尝试使用与以前相同的参数时,这将完美地工作。

For example, I have changed my sample to例如,我将样本更改为

[
  {
    "document": "A",
    "min": 7500001,
    "sample":"test1"
  },
  {
    "document": "B",
    "min": 7500001,
    "sample":"test2"
  },
  {
    "document": "C",
    "min": 7500001,
    "policy": "Z"
  },
{
    "document": "D",
    "min": 7500002,
    "policy": "X"
  }
]

and remain the schema to be the same as before, this would fail due to schema validation并保持架构与以前相同,这将由于架构验证而失败

在此处输入图像描述

but when you just remove the required from schema ie,但是当您只是从架构中删除所需的内容时,即

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "document": {
                "type": "string"
            },
            "min": {
                "type": "integer"
            },
            "policy": {
                "type": "string"
            }
        }
    }
}

在此处输入图像描述

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

相关问题 Azure 逻辑应用程序 HTTP 请求身份验证 Scope - Azure Logic App HTTP Request Authentication Scope 如何在不定义架构的情况下使用 Azure 逻辑应用转发请求 - How to forward a request as it is using Azure logic app without defining schema 逻辑应用查询 Azure Table 使用 HTTP 和 Managed Identity 认证 - Logic App query Azure Table using HTTP and Managed Identity authentication Azure 逻辑应用程序 HTTP 操作步骤 - 动态获取 endOfDate 日期 - Azure Logic App HTTP Action step - dynamically get endOfDate date 无法让客户端证书在逻辑应用程序的 HTTP 操作中工作 - Cannot get Client Certificate to work in HTTP Action of Logic App 从 base64 编码字符串解析 Azure 逻辑应用程序中的 JSON 数组,以在 For_each 中使用 - Parsing JSON array in Azure Logic App from base64 encoded string to use in For_each 在 nodejs 中解析 http 响应 - Parsing http response in nodejs 跳过逻辑应用连接器 - Skipping logic app connector 无法从逻辑应用执行 HTTP 后操作到 Asp.net 核心 Web API - Can't perform HTTP Post Action from Logic App to Asp.net Core Web API 逻辑应用中的 TrackedPropertiesEvaluationFailed 错误 - TrackedPropertiesEvaluationFailed error in logic app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM