# Nested object matching — exact match, nested field ignore/pattern, and bodyFromFile with override.
# The __ separator navigates into nested objects: child3__child4__pincode = child3.child4.pincode.
# /api/examples/3 returns a 3-level deep object; /api/examples/4 returns an extended variant.

GetNestedObject_ExactMatch:
  # Full deep match — every nested field asserted exactly.
  # Good baseline before introducing matchers.
  tags:
    - nested
  api:
    request:
      method: GET
      path: /api/examples/3
    response:
      statusCode: 200
      body:
        id: 1
        child1:
          email: child1@gmail.com
          age: 20
          child2:
            name: test-3
            pincode: 989898
        child3:
          email: child3@gmail.com
          age: 30
          child4:
            name: test-4
            pincode: 676767
        child5:
          email: child5@gmail.com
          age: 40

GetNestedObject_IgnoreNestedFields:
  # ignore: uses __ to target a specific deeply nested field, and a top-level key to remove an entire subtree.
  tags:
    - nested
    - ignore
  api:
    request:
      method: GET
      path: /api/examples/3
    response:
      statusCode: 200
      body:
        id: 1
        child1:
          email: child1@gmail.com
          age: 20
          child2:
            name: test-3
            pincode: 989898
        child3:
          email: child3@gmail.com
          age: 30
          child4:
            name: test-4
            pincode: 121212
      matcher:
        ignore:
          - child3__child4__pincode  # targets child3.child4.pincode specifically
          - child5                   # removes the entire child5 subtree

GetNestedObject_PatternOnNestedField:
  # pattern: validates child3.child4.pincode with a regex; all other fields matched exactly.
  # The matched field is excluded from the structural diff after validation.
  tags:
    - nested
    - pattern
  api:
    request:
      method: GET
      path: /api/examples/3
    response:
      statusCode: 200
      body:
        id: 1
        child1:
          email: child1@gmail.com
          age: 20
          child2:
            name: test-3
            pincode: 989898
        child3:
          email: child3@gmail.com
          age: 30
          child4:
            name: test-4
        child5:
          email: child5@gmail.com
          age: 40
      matcher:
        pattern:
          child3__child4__pincode: "^[0-9]{1,6}$"

GetNestedObject_BodyFromFileWithOverride:
  # Expected body loaded from Response/multi-level.json.
  # override: adds extra fields — /api/examples/4 returns an extended variant of the same structure.
  tags:
    - nested
    - bodyFromFile
    - override
  api:
    request:
      method: GET
      path: /api/examples/4
    response:
      statusCode: 200
      bodyFromFile: multi-level.json
      override:
        child1:
          child2:
            extra: extra1
        child3:
          child4:
            extra: extra2
