Skip to content

WireMock Hosting

This guide provides step-by-step instructions for configuring Wiremock hosting in your Aspire AppHost using Wiremock CLI. This will allow you to automatically pull down Wiremock cloud project stubs and run a mock server locally using the CLI.

📚 Useful Resources

📋 Prerequisites

Complete the shared mocking prerequisites, then make sure you have:

  • ✅ Wiremock CLI installed (npm install -g @wiremock/cli)
  • ✅ Wiremock Cloud project(s) with mocks defined (optional, for auto-update feature)

🛠️ Configure WireMock CLI Hosting

The SAIF.Platform.Aspire.Hosting.WiremockCli namespace runs each mock through the WireMock CLI executable and can pull its definitions from WireMock Cloud. See the SAIF.Platform.Aspire.Hosting WireMock reference for how it compares with the package's other WireMock integrations, and the WiremockCli README for its features, AddMock parameters, and default storage directory.

Usage Example

// Create the WireMock CLI resource
var wiremock = builder
    .AddWiremockCli("wiremock");

// Add a mock service that pulls definitions from WireMock Cloud
var mockApi = wiremock.AddMock(
    name: "external-api",
    port: 8080,
    wiremockProjectId: "abc123xyz",  // Your WireMock Cloud mock API ID
    autoUpdate: true
);

// Wire your application to reference the mock service
builder
    .AddProject<Projects.MyApiService>("my-api-service")
    .WithReference(mockApi)
    .WaitFor(mockApi);

To get the wiremockProjectId, follow Find your mock API ID.

Feedback

Please provide feedback on these APIs through:

  • 🐛 Issues for bugs or problems
  • 💡 Feature requests for improvements
  • 📝 Discussions for general feedback