Mugi.Schema 0.1.3

dotnet add package Mugi.Schema --version 0.1.3
                    
NuGet\Install-Package Mugi.Schema -Version 0.1.3
                    
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="Mugi.Schema" Version="0.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mugi.Schema" Version="0.1.3" />
                    
Directory.Packages.props
<PackageReference Include="Mugi.Schema" />
                    
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 Mugi.Schema --version 0.1.3
                    
#r "nuget: Mugi.Schema, 0.1.3"
                    
#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 Mugi.Schema@0.1.3
                    
#: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=Mugi.Schema&version=0.1.3
                    
Install as a Cake Addin
#tool nuget:?package=Mugi.Schema&version=0.1.3
                    
Install as a Cake Tool

Mugi.Schema

Mugi.Schema adds typed request input to the Mugi web framework. A schema combines route parameters, query values, headers, form fields, and JSON body fields into one input record, and the handler runs only after parsing and validation succeed.

Install

<ItemGroup>
  <PackageReference Include="Mugi" Version="0.1.3" />
  <PackageReference Include="Mugi.Schema" Version="0.1.3" />
  <PackageReference Include="Mugi.Generators" Version="0.1.3" />
</ItemGroup>

The Mugi.Generators package reads the field selectors and rule declarations at build time and generates the binders, so binding works under NativeAOT without reflection.

Usage

using Mugi.Schema;

var searchSchema = Schemas.For<SearchInput>()
    .Query(input => input.Limit, rules => rules.Default(20).Range(1, 100));

app.Get("/search/:Page", searchSchema,
    static (c, input) => c.Json(input));

var personSchema = Schemas.For<CreatePersonInput>()
    .Body(input => input.Name, rules => rules.NotEmpty().MaxLength(80))
    .Body(input => input.Age, rules => rules.Range(0, 120))
    .Body(input => input.Note, rules => rules.Optional());

app.Post("/people", personSchema,
    static (c, input) => c.Json(input));

public sealed record SearchInput(int Page, string Query, int Limit);
public sealed record CreatePersonInput(string Name, int Age, string? Note);

An explicit Route, Query, Body, Header, or Form mapping takes precedence. An unmapped field whose name matches a :parameter comes from the route; other unmapped fields come from the JSON body for POST, PUT, and PATCH, and from the query string for other methods.

Rules can be chained: Min, Max, Range, Positive, and NonNegative for numbers; NotEmpty, Length, MinLength, MaxLength, and Pattern for strings; Optional, Default, and Must for every field. A missing required value, parse failure, invalid JSON body, or failed rule returns 400 with a JSON errors array without calling the handler.

Schemas can share parts across input types with Schemas.Part<TPart>() and .Use(part), and share rule chains through static methods.

Full documentation is at github.com/hckaye/Mugi.

Product Compatible and additional computed target framework versions.
.NET 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.

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
0.1.3 101 8/28/2026
0.1.2 91 8/28/2026