Home > OS >  Docker Container with Wiremock could not find stub mappings
Docker Container with Wiremock could not find stub mappings

Time:02-03

Link to the Repo:enter image description here

ERROR:

enter image description here

enter image description here

CodePudding user response:

The mapping should be made to $PWD:/home/wiremock/mappings where PWD has the json files.

Also json files should look like this:

{
  "mappings": [
    {
      "id": "679dd3ce-55e5-45ee-b270-01dcf1b371ca",
      "request": {
        "urlPattern": "^/hello",
        "method": "GET"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "status": "success",
          "message": "Hello"
        },
        "headers": {
          "Content-Type": "text/plain"
        }
      },
      "uuid": "679dd3ce-55e5-45ee-b270-01dcf1b371ca"
    },
    {
      "id": "679dd3ce-55e5-45ee-b270-01dcf1b371c2",
      "request": {
        "urlPattern": "^/hello-2",
        "method": "GET"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "status": "success",
          "message": "Hello-2"
        },
        "headers": {
          "Content-Type": "text/plain"
        }
      },
      "uuid": "679dd3ce-55e5-45ee-b270-01dcf1b371c2"
    }
  ]
}

if you are running it json request object then the mapping should provide the mappings and the __files so need to map the containing folder:

docker run -it --rm \
  -p 8090:8080 \
  -v $PWD/samples/hello/stubs:/home/wiremock \
  wiremock/wiremock

enter image description here

  •  Tags:  
  • Related