liveBook · Manning

WireMock

As explained in Build Financial Software with Generative AI (From Scratch)

WireMock is a tool for mocking HTTP-based services with programmable request matching and predefined responses.

WireMock mocks HTTP-based services by matching requests to predefined responses. It lets a frontend call realistic API endpoints while the complete backend is still unavailable, making parallel UI development practical. section 6.5.2 section 6.9

Build a local WireMock service in a few steps:

  • Create a Dockerfile from the WireMock image and add the service to docker-compose.yml. section 6.5.1
  • Mount local __files and mappings directories as volumes, so mapping changes take effect without rebuilding the container. section 6.5.1
  • Expose the service on port 8081 and inspect its administration endpoint at /__admin/. section 6.5.1
  • Define mappings that match HTTP methods and URLs, then return status codes, headers, inline bodies, or files. section 6.5.2
  • Refresh mappings through the administration API after changing files, allowing new responses to become available. section 6.5.2

Mocking ACH file data

A GET request to /api/v1/files can return ach_files_response.json from __files. A dashboard can then display uploaded ACH files without a live backend, while reusable response files keep mappings simpler. section 6.5.2 section 6.6

Matching dynamic paths

A mapping for /api/v1/files/{fileId}/batches uses urlPathTemplate and {{request.path.fileId}} to select a canned response for each file identifier, avoiding one mapping per identifier. section 6.6.1

Listing 6.30 WireMock templating example
{
    "request": {
        "method": "GET",
        "urlPathTemplate": "/api/v1/files/{fileId}/batches"  #1
    },
    "response": {
        "status": 200,
        "headers": {
            "Content-Type": "application/json"
        },
        "bodyFileName": "ach_files_batches
➥{{request.path.fileId}}.json" #2
    }
}

Inspect the compact mapping that combines a dynamic request path with a templated response filename. section 6.6.1

How Build Financial Software with Generative AI (From Scratch) covers it

How deep it goes
Explains Docker setup, volumes, mappings, response files, refreshes, and dynamic templating, while deferring advanced WireMock features.
Examples
Uses Hello World, ACH file responses, ACH batch data, administration endpoints, and a scatterplot dashboard.
What you can do after
Operate/configure WireMock through Docker, mappings, canned response files, administration refreshes, and dynamic URL templating.
How it connects
Connects WireMock with Docker, Docker Compose, HTTP APIs, Next.js, Axios, Recharts, and frontend testing.

Also explained in

Compare how 2 books explain WireMock →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Financial Software with Generative AI (From Scratch). The section links point to the parts of the book it draws on.