Wiremock: Multiple stubs per json file

Created on 27 Nov 2018  路  3Comments  路  Source: tomakehurst/wiremock

Feature requests

Would be great to have multiple stubs in the same file (for example, in an array). Something like the following json:

[
  {
    "request": {
      "method": "GET",
      "url": "/some/thing"
    },
    "response": {
      "status": 200,
      "body": "Hello world!",
      "headers": {
        "Content-Type": "text/plain"
      }
    }
  },
  {
    "request": {
      "method": "GET",
      "url": "/some/thing2"
    },
    "response": {
      "status": 200,
      "body": "Hello world! 2",
      "headers": {
        "Content-Type": "text/plain"
      }
    }
  }
]

This is particularly useful for grouping stubs, and having a manageable amount of files.

PS: Thanks for the great work!

Most helpful comment

In case anyone runs across this trying to get multiple mapping into one json file as I did, be aware that the suggested format above is not what ended up in the code. There is no requests array, just mappings. See

https://github.com/tomakehurst/wiremock/blob/master/src/test/resources/multi-stub/multi.json

for a working example.

All 3 comments

In case anyone runs across this trying to get multiple mapping into one json file as I did, be aware that the suggested format above is not what ended up in the code. There is no requests array, just mappings. See

https://github.com/tomakehurst/wiremock/blob/master/src/test/resources/multi-stub/multi.json

for a working example.

In case anyone runs across this trying to get multiple mapping into one json file as I did, be aware that the suggested format above is not what ended up in the code. There is no requests array, just mappings. See

https://github.com/tomakehurst/wiremock/blob/master/src/test/resources/multi-stub/multi.json

for a working example.

Thanks this helped me :)

Was this page helpful?
0 / 5 - 0 ratings