ng-apimock / core

ng-apimock core module
MIT License
34 stars 20 forks source link

Match on partial body in mock #1068

Open cjsahansra opened 1 year ago

cjsahansra commented 1 year ago

When including the body in the mock, is there a way to only include a partial match on a single field? For example, if the full request body is something like this:

{
   "item": "00001",
   "color": "blue",
   "model" "X"
}

but I want the mock to only match on a single field like "item" and ignore whatever is in the remaining fields:

{
  "name": "some name",
  "request": {
    "url": "/some/url",
    "method": "POST",
    "body": {
      "item": "00001"
    }
  },
  "responses": {
    "ok": {
      "default": true,
        "data": {"response": "default mock"}
    }
}

Is this possible with ng-apimock or do I need to include the full request body in the mock?