[英]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"
]
}
}
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.