Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bodyPath by regex #83

Open
hector-js opened this issue Apr 21, 2023 · 0 comments
Open

bodyPath by regex #83

hector-js opened this issue Apr 21, 2023 · 0 comments
Assignees
Labels
feature New feature for the library
Milestone

Comments

@hector-js
Copy link
Owner

Is your feature request related to a problem? Please describe.
You want to return a specific scenario based on a regex again a value in a respose.

Describe the solution you'd like
Given following request:

Scenario 1

  • request
{
  "id": "A0001"
}
  • response
{
  "id": "1"
}

Scenario 2

  • request
{
  "id": "A0002"
}
  • response
{
  "id": "2"
}

Scenario 3

  • request
{
  "id": "A0003"
}
  • response
{
  "id": "3"
}

Solution:

{
  "_post": {
    "my-path": [
      {
        "_req": {
          "_bodyPaths": {
            "$.id": "^[A].*[1]$"
          }
        },
        "_res": {
          "_body": {
            "id": "1"
          }
        }
      },
      {
        "_req": {
          "_bodyPaths": {
            "$.id": "^[A].*[2]$"
          }
        },
        "_res": {
          "_body": {
            "id": "2"
          }
        }
      },
      {
        "_req": {
          "_bodyPaths": {
            "$.id": "^[A].*[3]$"
          }
        },
        "_res": {
          "_body": {
            "id": "3"
          }
        }
      }
    ]
  }
}
@hector-js hector-js added the feature New feature for the library label Apr 21, 2023
@hector-js hector-js added this to the 2.0.0 milestone Apr 21, 2023
@hector-js hector-js self-assigned this Apr 21, 2023
hector-js added a commit that referenced this issue Apr 21, 2023
hector-js added a commit that referenced this issue Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature for the library
Projects
None yet
Development

No branches or pull requests

1 participant