HenrikJensen.ServiceStub 1.0.0-beta2

Prefix Reserved
This is a prerelease version of HenrikJensen.ServiceStub.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package HenrikJensen.ServiceStub --version 1.0.0-beta2
                    
NuGet\Install-Package HenrikJensen.ServiceStub -Version 1.0.0-beta2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HenrikJensen.ServiceStub" Version="1.0.0-beta2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HenrikJensen.ServiceStub" Version="1.0.0-beta2" />
                    
Directory.Packages.props
<PackageReference Include="HenrikJensen.ServiceStub" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HenrikJensen.ServiceStub --version 1.0.0-beta2
                    
#r "nuget: HenrikJensen.ServiceStub, 1.0.0-beta2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package HenrikJensen.ServiceStub@1.0.0-beta2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=HenrikJensen.ServiceStub&version=1.0.0-beta2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=HenrikJensen.ServiceStub&version=1.0.0-beta2&prerelease
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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