HenrikJensen.ServiceStub
1.0.0-beta2
Prefix Reserved
dotnet add package HenrikJensen.ServiceStub --version 1.0.0-beta2
NuGet\Install-Package HenrikJensen.ServiceStub -Version 1.0.0-beta2
<PackageReference Include="HenrikJensen.ServiceStub" Version="1.0.0-beta2" />
<PackageVersion Include="HenrikJensen.ServiceStub" Version="1.0.0-beta2" />
<PackageReference Include="HenrikJensen.ServiceStub" />
paket add HenrikJensen.ServiceStub --version 1.0.0-beta2
#r "nuget: HenrikJensen.ServiceStub, 1.0.0-beta2"
#:package HenrikJensen.ServiceStub@1.0.0-beta2
#addin nuget:?package=HenrikJensen.ServiceStub&version=1.0.0-beta2&prerelease
#tool nuget:?package=HenrikJensen.ServiceStub&version=1.0.0-beta2&prerelease
Service Stub
A Service Stub intercepts HTTP requests and serves local service stubs for testing purposes, eliminating the need for external dependencies.
It supports mapping static JSON files and “Minimal API-like” methods to specific endpoint paths and HTTP methods.
Named collections of mappings are supported, making it easy to switch between sets of responses and enabling flexible testing scenarios.
Static JSON
A top-level folder is used to store static JSON files. The path to this folder can be configured in appsettings.json or programmatically.
Within this folder, you can create any number of collection folders, each with an arbitrary name. Inside each collection folder, the folder structure should mirror the path segments of your API endpoints - each subfolder represents a path segment. For every endpoint, place static JSON files named after the corresponding HTTP method (such as get.json, post.json, etc.) inside the subfolder representing the last path segment.
Minimal API-like Methods
Endpoint paths can be mapped to static methods in a Minimal API-like fashion. This allows responses to return dynamic values.
A collection name can optionally be specified with each app.MapStub call in Program.cs.
API
The Service Stub API can be used to change the active collection at runtime.
To enable this, add app.UseStubApi(); in Program.cs, and refer to the included Stub.http file (see the example project) for instructions on how to call the API.
Collections
The default collection is named _default.
Example
See the included website project for a working example.
| 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 is compatible. 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
- No dependencies.
-
net9.0
- No dependencies.
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 |
|---|