gstroup / apimocker

node.js module to run a simple http server for mock service responses.
MIT License
280 stars 81 forks source link

Multiple types params path/queryString, body #112

Open ludovicoloreti opened 5 years ago

ludovicoloreti commented 5 years ago

Hello, nice work! Really appreciate it.

I have a question regarding having multiple types of params, both in path (var/:id) and in body ({"dynamicValue": "string"}).

How to do with it? I've just read your documentation twice, but it seems hard to solve it.

Need something like this:

url: asd/:firstId/rotfl/:secondId body: "edit" -> {"value":"string"}

So I've got 2 int path (firstId and secondId) and a body in json.

My JSON looks like:

[
  {
    "firstId": 123,
    "list": [
      {
        "secondId": 1,
        "val1": "content of type string",
         "val2": "content of type string",
        "date": "2019-05-27T13:08:44.183Z"
      },
     {
        "secondId": 2,
        "val1": "content of type string",
         "val2": "content of type string",
        "date": "2019-01-27T13:08:44.183Z"
      },
    ]
  },
  {
    "firstId": 456,
    "list": [
      {
        "secondId": 1,
        "val1": "content of type string",
         "val2": "content of type string",
        "date": "2019-02-27T13:08:44.183Z"
      },
     {
        "secondId": 342,
        "val1": "content of type string",
         "val2": "content of type string",
        "date": "2019-03-27T13:08:44.183Z"
      },
    ]
  }
]

Could you please help 'bout this?

gstroup commented 5 years ago

Glad that apimocker is helping you! I don't fully understand your question. So, you are sending a request with params both in the path, and the body. Right? What are you expecting from apimocker? Do you want to send different responses based on params from both the path and the body? I think this should work as long as your parameters all have different keys.