Codebelt.Extensions.Carter.AspNetCore.Text.Yaml 1.0.0

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

Codebelt.Extensions.Carter.AspNetCore.Text.Yaml

A YamlDotNet-powered response negotiator for Carter in ASP.NET Core minimal APIs.

About

Codebelt.Extensions.Carter.AspNetCore.Text.Yaml extends the Codebelt.Extensions.Carter package with a dedicated YAML response negotiator for Carter, capable of serializing response models to YAML format using YamlDotNet.

Use this package when your API clients require YAML responses and you want to keep Carter modules and content negotiation clean and explicit.

CSharp Example

Functional-test style sample (same bootstrapping pattern used by this repository):

using System.Net.Http.Headers;
using System.Threading.Tasks;
using Carter;
using Codebelt.Extensions.Carter.Assets;
using Codebelt.Extensions.Carter.AspNetCore.Text.Yaml;
using Codebelt.Extensions.Xunit.Hosting.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

using var response = await MinimalWebHostTestFactory.RunAsync(
    services =>
    {
        services.AddMinimalYamlOptions();
        services.AddCarter(configurator: c => c
            .WithModule<WorldModule>()
            .WithResponseNegotiator<YamlResponseNegotiator>());
        services.AddRouting();
    },
    app =>
    {
        app.UseRouting();
        app.UseEndpoints(endpoints => endpoints.MapCarter());
    },
    _ => { },
    async client =>
    {
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/yaml"));
        return await client.GetAsync("/world/statistical-regions");
    });

Program-style usage for production apps (remember to inherit from ICarterModule for your endpoints and add other services as needed):

using Carter;
using Codebelt.Extensions.AspNetCore.Text.Yaml.Formatters;
using Codebelt.Extensions.Carter.AspNetCore.Text.Yaml;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddMinimalYamlOptions();
builder.Services.AddCarter(c => c
    .WithResponseNegotiator<YamlResponseNegotiator>());

var app = builder.Build();
app.MapCarter();
app.Run();
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
1.0.0 71 3/1/2026

Version: 1.0.0
Availability: .NET 10
 
# New Features
- ADDED YamlResponseNegotiator class in the Codebelt.Extensions.Carter.AspNetCore.Text.Yaml namespace that provides a YAML response negotiator for Carter, capable of serializing response models to YAML format using YamlDotNet