question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

karate : Complex JSON Schema matching

See original GitHub issue
Feature: Complex Schema
  Background:
    * def JSONtobeValidiated =
    """

  {
  "MyArray": {
    "MYinternalDetails": [
      {
        "SomeField": "dc",
        "textfield": [],
        "OptionalArray1": [
          {
            "Users": "Y",
            "IsAllowed": "Y"
          },
          {
            "Users": "Y",
            "IsAllowed": "Y"
          }
        ]
      },
      {
        "SomeField": "cd",
        "textfield": [],
        "OptionalArray3": [
          {
            "Astring": "Lazy",
            "AnotherString": "N",
            "textfield": []
          },
          {
            "Astring": "FREE",
            "AnotherString": "N",
            "textfield": [
              {
                "title": "Name",
                "alertMessage": "Please enter valid name."
              },
              {
                "title": "Mobile No",
                "alertMessage": "Please enter mobile no."
              }
            ]
          }
        ]
      },
      {
        "SomeField": "gv",
        "textfield": [
          {
            "title": "First",
            "alertMessage": "SOme Alert"
          }
        ]
      },
      {
        "SomeField": "rp",
        "textfield": []
      }
    ]
  }
}"""

    * def textfield = { title: '#string', alertMessage: '#string' }
    * def OptionalArray1 = { Users: '#string',IsAllowed: '#string' }
    * def OptionalArray3 = { Astring: '#string' ,AnotherString: '#string', textfield: '##[]'  }

    * def MYinternalDetails =
    """
      {
        SomeField: '#string',
        textfield: '##[]',
        OptionalArray1: '##[] OptionalArray1'
        OptionalArray3: '##[] OptionalArray3'
      }

    """

    * def ValidJsonSchema = { MyArray: { MYinternalDetails: '#[] MYinternalDetails' } }

  Scenario: These matches works

    * match JSONtobeValidiated.MyArray.MYinternalDetails == '#[]'
    * match JSONtobeValidiated.MyArray.MYinternalDetails == '#[4]'
    * match JSONtobeValidiated contains  { MyArray: '#ignore' }
    * match JSONtobeValidiated contains { MyArray: { MYinternalDetails: '#ignore' } }



  Scenario: These match doesn't work
    * match JSONtobeValidiated contains { MyArray: { MYinternalDetails: '#[] MYinternalDetails' } }

  Scenario: These match doesn't work either

    * match JSONtobeValidiated.MyArray.MYinternalDetails == '#[] MYinternalDetails'

  Scenario: These match Also doesn't work

    * match JSONtobeValidiated == ValidJsonSchema



In Above Example , Schema matching doesn’t seems to be working as expected. Need to match full JSON schema.

Reference: https://stackoverflow.com/questions/49231115/karate-complex-json-schema-matching

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
avyasbmscommented, Apr 26, 2018

Confirming that it worked for many other cases as well. Thanks again!

1reaction
avyasbmscommented, Apr 11, 2018

Hey @ptrthomas It seems to be working. I’ll check more cases and will confirm. Thanks a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

karate : Complex JSON Schema matching - Stack Overflow
JsonSmartJsonProvider'. How do I get following Working * match JSONtobeValidiated == ValidJsonSchema.
Read more >
karate : Complex JSON Schema matching · Issue #346 - GitHub
In Above Example , Schema matching doesn't seems to be working as expected. Need to match full JSON schema. Reference: https://stackoverflow.com ...
Read more >
Karate JSON Schema Validation : Karate API Testing Tutorials
In this video, We are going to learn about the Karate JSON Schema Validation. JSON Schema validation for API is important and KARATE...
Read more >
APIs Unleashed 05: Schema Validation - Synapse QA
Schema validation can be easily achieved in KarateDSL by using fuzzy matching markers. Karate offers a wide range of markers for validating JSON...
Read more >
Karate | Test Automation Made Simple.
URISyntaxException and match not working as expected because of special or ... Embedded expressions are useful when you have complex JSON read from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found