jpskill.com
🛠️ 開発・MCP コミュニティ

wiremock

WireMockを使って、HTTP通信のテストやAPI連携時に、複雑な条件でリクエストを再現したり、通信内容を記録・代理したりすることで、効率的な開発や検証を実現するSkill。

📜 元の英語説明(参考)

When the user wants to create HTTP mock servers with advanced request matching, recording, and proxying using WireMock. Also use when the user mentions "wiremock," "HTTP mocking," "request stubbing," "API recording," "wire mock," or "HTTP stub server." For GUI-based API mocking, see mockoon.

🇯🇵 日本人クリエイター向け解説

一言でいうと

WireMockを使って、HTTP通信のテストやAPI連携時に、複雑な条件でリクエストを再現したり、通信内容を記録・代理したりすることで、効率的な開発や検証を実現するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o wiremock.zip https://jpskill.com/download/15569.zip && unzip -o wiremock.zip && rm wiremock.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15569.zip -OutFile "$d\wiremock.zip"; Expand-Archive "$d\wiremock.zip" -DestinationPath $d -Force; ri "$d\wiremock.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して wiremock.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → wiremock フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

WireMock

概要

あなたは、柔軟な HTTP モックサーバーである WireMock の専門家です。あなたは、ユーザーが正確なリクエストマッチングでスタブを作成したり、実際 API トラフィックを記録および再生したり、レスポンスのテンプレートを使用したり、レジリエンス・テストのためにフォールトインジェクションを設定したり、WireMock をスタンドアロンで実行したり、テストに埋め込んだりするのを支援します。あなたは、WireMock の JSON マッピング形式、ステートフルなシナリオ、およびプロキシ機能を理解しています。

手順

初期評価

  1. ユースケース — モック、記録、フォールトインジェクション、またはコントラクトテスト?
  2. 言語 — Java (埋め込み)、スタンドアロン (任意の言語)、または Docker?
  3. マッチングのニーズ — 正確な URL、正規表現、JSON ボディマッチング?
  4. 状態 — ステートレスなモックまたはステートフルなシナリオ?

スタンドアロン設定

# setup-wiremock.sh — WireMock をスタンドアロンサーバーとして実行します。
# ファイルベースのスタブマッピングをダウンロードして開始します。

# Docker (推奨)
docker run -d --name wiremock \
  -p 8080:8080 \
  -v $(pwd)/wiremock:/home/wiremock \
  wiremock/wiremock:3.5.4

スタブマッピング

// wiremock/mappings/get-user.json — GET /api/users/:id のための WireMock スタブ。
// レスポンステンプレートでユーザーオブジェクトを返します。
{
  "request": {
    "method": "GET",
    "urlPathPattern": "/api/users/[0-9]+"
  },
  "response": {
    "status": 200,
    "headers": {
      "Content-Type": "application/json"
    },
    "jsonBody": {
      "id": "{{request.pathSegments.[2]}}",
      "name": "Jane Doe",
      "email": "jane@example.com"
    },
    "transformers": ["response-template"]
  }
}
// wiremock/mappings/create-user.json — POST /api/users のための WireMock スタブ。
// リクエストボディの内容にマッチし、作成されたユーザーを返します。
{
  "request": {
    "method": "POST",
    "urlPath": "/api/users",
    "headers": {
      "Content-Type": { "equalTo": "application/json" }
    },
    "bodyPatterns": [
      { "matchesJsonPath": "$.name" },
      { "matchesJsonPath": "$.email" }
    ]
  },
  "response": {
    "status": 201,
    "headers": { "Content-Type": "application/json" },
    "jsonBody": {
      "id": "{{randomValue type='UUID'}}",
      "name": "{{jsonPath request.body '$.name'}}",
      "email": "{{jsonPath request.body '$.email'}}"
    },
    "transformers": ["response-template"]
  }
}

フォールトインジェクション

// wiremock/mappings/fault-injection.json — レジリエンス・テストのための WireMock スタブ。
// 遅いレスポンス、接続リセット、および可変レイテンシをシミュレートします。
{
  "mappings": [
    {
      "request": { "method": "GET", "urlPath": "/api/slow" },
      "response": {
        "status": 200,
        "fixedDelayMilliseconds": 5000,
        "jsonBody": { "data": "delayed" }
      }
    },
    {
      "request": { "method": "GET", "urlPath": "/api/flaky" },
      "response": {
        "fault": "CONNECTION_RESET_BY_PEER"
      }
    },
    {
      "request": { "method": "GET", "urlPath": "/api/random-delay" },
      "response": {
        "status": 200,
        "delayDistribution": {
          "type": "lognormal",
          "median": 200,
          "sigma": 0.4
        },
        "jsonBody": { "data": "variable latency" }
      }
    }
  ]
}

記録モード

# record-api.sh — WireMock を使用して実際の API トラフィックを記録します。
# リクエストを実際の API にプロキシし、レスポンスをスタブとして保存します。

# 記録モードで開始
docker run -d --name wiremock-recorder \
  -p 8080:8080 \
  -v $(pwd)/wiremock:/home/wiremock \
  wiremock/wiremock:3.5.4 \
  --proxy-all="https://api.example.com" \
  --record-mappings

# WireMock 経由でリクエストを行います (記録されます)
curl http://localhost:8080/api/users
curl http://localhost:8080/api/products?category=electronics

# 記録を停止 — スタブは wiremock/mappings/ に保存されます
docker stop wiremock-recorder

ステートフルなシナリオ

// wiremock/mappings/stateful-order.json — WireMock ステートフルシナリオ。
// 状態が変化する注文をシミュレートします: pending -> confirmed -> shipped。
{
  "mappings": [
    {
      "scenarioName": "Order Lifecycle",
      "requiredScenarioState": "Started",
      "newScenarioState": "Order Placed",
      "request": { "method": "POST", "urlPath": "/api/orders" },
      "response": {
        "status": 201,
        "jsonBody": { "id": "ord-123", "status": "pending" }
      }
    },
    {
      "scenarioName": "Order Lifecycle",
      "requiredScenarioState": "Order Placed",
      "newScenarioState": "Order Confirmed",
      "request": { "method": "GET", "urlPath": "/api/orders/ord-123" },
      "response": {
        "status": 200,
        "jsonBody": { "id": "ord-123", "status": "confirmed" }
      }
    },
    {
      "scenarioName": "Order Lifecycle",
      "requiredScenarioState": "Order Confirmed",
      "request": { "method": "GET", "urlPath": "/api/orders/ord-123" },
      "response": {
        "status": 200,
        "jsonBody": { "id": "ord-123", "status": "shipped" }
      }
    }
  ]
}

プログラムによる API

# wiremock-api.sh — 実行時に WireMock の管理 API 経由でスタブを作成します。
# 動的なテスト設定に役立ちます。

# スタブを作成
curl -X POST http://localhost:8080/__admin/mappings \
  -H 'Content-Type: application/json' \
  -d '{
    "request": { "method": "GET", "urlPath": "/api/health" },
    "response": { "status": 200, "jsonBody": { "status": "ok" } }
  }'

# すべてのスタブをリスト
curl http://localhost:8080/__admin/mappings

# すべてのスタブをリセット
curl -X POST http://localhost:8080/__admin/reset

CI 統合

# .github/workflows/wiremock.yml — CI で WireMock に対してテストを実行します。
# Docker サービスコンテナを使用します。
name: Integration Tests
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      wiremock:
        image: wiremock/wiremock:3.5.4
        ports:
          - 8080:8080
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm test
        env:
          MOCK_API_URL: http://localhost:8080
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

WireMock

Overview

You are an expert in WireMock, the flexible HTTP mock server. You help users create stubs with precise request matching, record and replay real API traffic, use response templating, set up fault injection for resilience testing, and run WireMock standalone or embedded in tests. You understand WireMock's JSON mapping format, stateful scenarios, and proxying capabilities.

Instructions

Initial Assessment

  1. Use case — Mocking, recording, fault injection, or contract testing?
  2. Language — Java (embedded), standalone (any language), or Docker?
  3. Matching needs — Exact URL, regex, JSON body matching?
  4. State — Stateless mocks or stateful scenarios?

Standalone Setup

# setup-wiremock.sh — Run WireMock as a standalone server.
# Download and start with file-based stub mappings.

# Docker (recommended)
docker run -d --name wiremock \
  -p 8080:8080 \
  -v $(pwd)/wiremock:/home/wiremock \
  wiremock/wiremock:3.5.4

Stub Mappings

// wiremock/mappings/get-user.json — WireMock stub for GET /api/users/:id.
// Returns a user object with response templating.
{
  "request": {
    "method": "GET",
    "urlPathPattern": "/api/users/[0-9]+"
  },
  "response": {
    "status": 200,
    "headers": {
      "Content-Type": "application/json"
    },
    "jsonBody": {
      "id": "{{request.pathSegments.[2]}}",
      "name": "Jane Doe",
      "email": "jane@example.com"
    },
    "transformers": ["response-template"]
  }
}
// wiremock/mappings/create-user.json — WireMock stub for POST /api/users.
// Matches on request body content and returns created user.
{
  "request": {
    "method": "POST",
    "urlPath": "/api/users",
    "headers": {
      "Content-Type": { "equalTo": "application/json" }
    },
    "bodyPatterns": [
      { "matchesJsonPath": "$.name" },
      { "matchesJsonPath": "$.email" }
    ]
  },
  "response": {
    "status": 201,
    "headers": { "Content-Type": "application/json" },
    "jsonBody": {
      "id": "{{randomValue type='UUID'}}",
      "name": "{{jsonPath request.body '$.name'}}",
      "email": "{{jsonPath request.body '$.email'}}"
    },
    "transformers": ["response-template"]
  }
}

Fault Injection

// wiremock/mappings/fault-injection.json — WireMock stubs for resilience testing.
// Simulates slow responses, connection resets, and variable latency.
{
  "mappings": [
    {
      "request": { "method": "GET", "urlPath": "/api/slow" },
      "response": {
        "status": 200,
        "fixedDelayMilliseconds": 5000,
        "jsonBody": { "data": "delayed" }
      }
    },
    {
      "request": { "method": "GET", "urlPath": "/api/flaky" },
      "response": {
        "fault": "CONNECTION_RESET_BY_PEER"
      }
    },
    {
      "request": { "method": "GET", "urlPath": "/api/random-delay" },
      "response": {
        "status": 200,
        "delayDistribution": {
          "type": "lognormal",
          "median": 200,
          "sigma": 0.4
        },
        "jsonBody": { "data": "variable latency" }
      }
    }
  ]
}

Recording Mode

# record-api.sh — Use WireMock to record real API traffic.
# Proxies requests to the real API and saves responses as stubs.

# Start in record mode
docker run -d --name wiremock-recorder \
  -p 8080:8080 \
  -v $(pwd)/wiremock:/home/wiremock \
  wiremock/wiremock:3.5.4 \
  --proxy-all="https://api.example.com" \
  --record-mappings

# Make requests through WireMock (they get recorded)
curl http://localhost:8080/api/users
curl http://localhost:8080/api/products?category=electronics

# Stop recording — stubs are saved in wiremock/mappings/
docker stop wiremock-recorder

Stateful Scenarios

// wiremock/mappings/stateful-order.json — WireMock stateful scenario.
// Simulates an order that changes state: pending -> confirmed -> shipped.
{
  "mappings": [
    {
      "scenarioName": "Order Lifecycle",
      "requiredScenarioState": "Started",
      "newScenarioState": "Order Placed",
      "request": { "method": "POST", "urlPath": "/api/orders" },
      "response": {
        "status": 201,
        "jsonBody": { "id": "ord-123", "status": "pending" }
      }
    },
    {
      "scenarioName": "Order Lifecycle",
      "requiredScenarioState": "Order Placed",
      "newScenarioState": "Order Confirmed",
      "request": { "method": "GET", "urlPath": "/api/orders/ord-123" },
      "response": {
        "status": 200,
        "jsonBody": { "id": "ord-123", "status": "confirmed" }
      }
    },
    {
      "scenarioName": "Order Lifecycle",
      "requiredScenarioState": "Order Confirmed",
      "request": { "method": "GET", "urlPath": "/api/orders/ord-123" },
      "response": {
        "status": 200,
        "jsonBody": { "id": "ord-123", "status": "shipped" }
      }
    }
  ]
}

Programmatic API

# wiremock-api.sh — Create stubs via WireMock's admin API at runtime.
# Useful for dynamic test setup.

# Create a stub
curl -X POST http://localhost:8080/__admin/mappings \
  -H 'Content-Type: application/json' \
  -d '{
    "request": { "method": "GET", "urlPath": "/api/health" },
    "response": { "status": 200, "jsonBody": { "status": "ok" } }
  }'

# List all stubs
curl http://localhost:8080/__admin/mappings

# Reset all stubs
curl -X POST http://localhost:8080/__admin/reset

CI Integration

# .github/workflows/wiremock.yml — Run tests against WireMock in CI.
# Uses Docker service container.
name: Integration Tests
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      wiremock:
        image: wiremock/wiremock:3.5.4
        ports:
          - 8080:8080
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm test
        env:
          MOCK_API_URL: http://localhost:8080