mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 13:00:33 +01:00
Using static mappings with body as files #735
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vebbo2 on GitHub (Dec 18, 2025).
Originally assigned to: @StefH on GitHub.
Hi, I want to mock a very large API response, which means I would prefer to put it in a separate file, rather than encode it and embed it in my static mapping file.
I found in docs that I should put my static files in
__filesdirectory and useBodyFileName, however I cannot make it work. I tried all the different folder mount locations, but all of them give the following exception during test run, indicating that file was probably not found:Putting my response directly inside
Bodyworks fine, which means rest of my configuration is not the issue.My setup:
Tests.csproj
Fixture.cs
mapping.json
GetProductDetailsResponse.json
Image used:
sheyenrath/wiremock.net-alpine:latestInspecting it shows me that all mapping and body files are there in their mounted directories:
Is this scenario supported? If so, what should be proper configuration?
@StefH commented on GitHub (Dec 22, 2025):
@vebbo2
If you are using WireMock.Net, you need to use the
BodyAsFileproperty.16e3872402/examples/WireMock.Net.Console.NET8/__admin/mappings/BodyAsFileExample.json (L20)The
BodyFileNameis from the WireMock Java version.