MockResponse.Middleware.LocalFolderStore
8.0.1-preview
See the version list below for details.
dotnet add package MockResponse.Middleware.LocalFolderStore --version 8.0.1-preview
NuGet\Install-Package MockResponse.Middleware.LocalFolderStore -Version 8.0.1-preview
<PackageReference Include="MockResponse.Middleware.LocalFolderStore" Version="8.0.1-preview" />
<PackageVersion Include="MockResponse.Middleware.LocalFolderStore" Version="8.0.1-preview" />
<PackageReference Include="MockResponse.Middleware.LocalFolderStore" />
paket add MockResponse.Middleware.LocalFolderStore --version 8.0.1-preview
#r "nuget: MockResponse.Middleware.LocalFolderStore, 8.0.1-preview"
#:package MockResponse.Middleware.LocalFolderStore@8.0.1-preview
#addin nuget:?package=MockResponse.Middleware.LocalFolderStore&version=8.0.1-preview&prerelease
#tool nuget:?package=MockResponse.Middleware.LocalFolderStore&version=8.0.1-preview&prerelease
<a id="readme-top"></a>
MockResponse.Middleware.LocalFolderStore
This package provides a file system-based implementation for use with the MockResponse.Middleware
system. It enables serving mock API responses from a local folder, ideal for testing or offline development scenarios where remote providers like Azure Blob Storage are not feasible.
Table of Contents
- Installation
- Configuration
- LocalFolderStoreOptions Configuration
- Usage: AddLocalFolderStore
- Troubleshooting
๐ฆ Installation
dotnet add package MockResponse.Middleware.LocalFolderStore
<p align="right">(<a href="#readme-top">back to top</a>)</p>
โ๏ธ Configuration
Specify your local folder path and mock mappings in appsettings.json
:
{
...
"MockOptions": {
"ExcludedRequestPaths": ["/api/health", "/openapi", "/metrics", "/redoc", "/swagger"],
"LocalFolderStoreOptions": {
"FolderPath": "Mocks"
},
"ResponseMappings": {
"Namespace.TypeName": "ExampleResponse.json",
"Namespace.TypeName.Variant": "subfolder/ExampleResponse.Variant.json"
},
"UseMock": true
},
...
}
๐ก You can also organize your mock files using subfolders inside the specified
FolderPath
.For example,
"Namespace.TypeName.Variant": "subfolder/ExampleResponse.Variant.json"
will load the file fromMocks/subfolder/ExampleResponse.Variant.json
.
<p align="right">(<a href="#readme-top">back to top</a>)</p>
๐ง LocalFolderStoreOptions Configuration
The following configuration property is used by the local folder provider. It should be set under MockOptions:LocalFolderStoreOptions
.
Property | Type | Required | Description |
---|---|---|---|
FolderPath |
string |
โ | Path to the folder containing mock JSON files. Relative paths are resolved from the application root. |
๐ The folder should contain JSON files matching your
ResponseMappings
. You can also organize files into subfolders for variants or grouping.
<p align="right">(<a href="#readme-top">back to top</a>)</p>
๐ Usage: AddLocalFolderStore
Register the middleware in Startup.cs
or Program.cs
:
services.AddApiMocking(Configuration)
.AddLocalFolderStore();
Use the middleware:
app.UseApiMocking();
Place your mock JSON files in the folder specified by FolderPath
. Each file is served based on its ResponseMappings
key and corresponding HTTP response metadata.
<p align="right">(<a href="#readme-top">back to top</a>)</p>
๐งช Troubleshooting
Missing Configurations
โ ๏ธ Missing FolderPath
Error Message
LocalFolderStoreOptions.FolderPath must not be null or empty.
Cause
The FolderPath
was not specified under MockOptions:LocalFolderStoreOptions
, or it was empty.
Solution
Make sure your appsettings.json
(or other configuration source) includes a valid path:
{
"MockOptions": {
"LocalFolderStoreOptions": {
"FolderPath": "Mocks"
}
}
}
Runtime Errors
โ ๏ธ File not found
Error Message
The mock file 'Mocks/WeatherForecast.json' could not be found.
Cause
The file mapped in ResponseMappings
does not exist in the specified folder (or subfolder).
Solution
Verify that the filename and subdirectory (if applicable) exist under the FolderPath
. Be sure filenames match exactly (including casing on case-sensitive systems).
๐ก Use relative paths like
"subfolder/Example.json"
for files inside subdirectories.
๐ For additional error handling scenarios, see the Core Troubleshooting Guide.
<p align="right">(<a href="#readme-top">back to top</a>)</p>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- MockResponse.Middleware.Core (>= 8.0.1-preview)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
8.0.1 | 92 | 7/29/2025 |
8.0.1-preview | 113 | 6/26/2025 |