Skip to content

JSON Schema does not allow root array for multiple workflows #271

@Depechie

Description

@Depechie

When using the provided json schema https://raw.githubusercontent.com/microsoft/RulesEngine/main/schema/workflow-schema.json within VSCode for json editing, not all samples will be accepted.

The schema expects a single object as root, not an array... meaning following json is invalid:

[
    {
        "WorkflowName": "NestedInputDemoWorkflow1",
        "Rules": [
        {
        "RuleName": "CheckNestedSimpleProp",
        "ErrorMessage": "One or more adjust rules failed.",
        "ErrorType": "Error",
        "RuleExpressionType": "LambdaExpression",
        "Expression": "input1.NestedProp.SimpleProp == \"nestedSimpleProp\""
        }
        ]
    },
    {
        "WorkflowName": "NestedInputDemoWorkflow2",
        "Rules": [
        {
        "RuleName": "CheckNestedListProp",
        "ErrorMessage": "One or more adjust rules failed.",
        "ErrorType": "Error",
        "RuleExpressionType": "LambdaExpression",
        "Expression": "input1.NestedProp.ListProp[0].Id == 1 && input1.NestedProp.ListProp[1].Value == \"second\""
        }
        ]
    }
]

But this will be marked valid:

{
    "WorkFlowName": "Discounts",
    "Rules": [
        {
            "RuleName": "GiveDiscount10",
            "SuccessEvent": "10",
            "ErrorMessage": "One or more adjust rules failed.",
            "ErrorType": "Error",
            "RuleExpressionType": "LambdaExpression",
            "Expression": "input1.country == \"india\" AND input1.loyaltyFactor <= 2 AND input1.totalPurchasesToDate >= 5000"
          },
          {
            "RuleName": "GiveDiscount20",
            "SuccessEvent": "20",
            "ErrorMessage": "One or more adjust rules failed.",
            "ErrorType": "Error",
            "RuleExpressionType": "LambdaExpression",
            "Expression": "input1.country == \"india\" AND input1.loyaltyFactor >= 3 AND input1.totalPurchasesToDate >= 10000"
          }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions