AutoSDK.CLI 0.28.1-dev.114

This is a prerelease version of AutoSDK.CLI.
dotnet tool install --global AutoSDK.CLI --version 0.28.1-dev.114
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local AutoSDK.CLI --version 0.28.1-dev.114
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=AutoSDK.CLI&version=0.28.1-dev.114&prerelease
                    
nuke :add-package AutoSDK.CLI --version 0.28.1-dev.114
                    

AutoSDK

The goal of this project is to automate and minimize the effort of maintaining high-quality .NET SDKs generated based on the OpenAPI specification, mainly to strengthen the AI ecosystem within .NET. The code generated by this library is also actively used in dozens of our various SDKs of varying complexity levels and in the LangChain.NET project, which ensures that it is tested in various scenarios and is ready for them.
Inspired by NSwag ❤️.

🔥Features🔥

  • Detects your TargetFramework and generates optimal code for it (including net6.0/net7.0/net8.0 improvements)
  • Supports .Net Framework/.Net Standard
  • Supports OpenAPI 3.1 specs via internal conversion to OpenAPI 3.0 (includes support for nullability, examples, const)
  • Does not contain dependencies for modern versions of dotnet.
  • Only System.Text.Json dependency for .Net Framework/.Net Standard
  • Any generated methods provide the ability to pass a CancellationToken
  • Allows partial generation (models only) or end points filtering
  • Available under MIT license for general users and most organizations
  • Uses https://github.com/microsoft/OpenAPI.NET for parsing OpenAPI specification
  • Supports nullable enable/trimming/native AOT compilation/CLS compliance
  • Tested on GitHub 220k lines OpenAPI specification
  • Supports OneOf/AnyOf/AllOf/Not schemas
  • Supports Enums for System.Text.Json
  • Supports SSE (Server-Sent Events) through the application/x-ndjson content type
  • Uses Incremental Source Generators for efficient generation and caching.
  • Efficient O(n) implementation, fully suitable for large/super large OpenAPI specifications
  • Used in 10+ real SDKs and adapted to solve various problems

🚀Quick start🚀

You can use the CLI to generate the code.

dotnet tool install --global autosdk.cli --prerelease
rm -rf Generated
autosdk generate openapi.yaml \
    --namespace Namespace \
    --clientClassName YourApi \
    --targetFramework net8.0 \
    --output Generated

It will generate the code in the "Generated" subdirectory.
It also will include polyfills for .Net Framework/.Net Standard TargetFrameworks.

Source generator

  • Install the package
dotnet add package AutoSDK.SourceGenerators
  • Add the following optional settings to your csproj file to customize generation. You can check all settings here:
<ItemGroup Label="AutoSDK">
    <AdditionalFiles Include="$(MSBuildThisFileDirectory)../../../docs/openapi.yaml" AutoSDK_OpenApiSpecification="true" />
</ItemGroup>


<PropertyGroup Label="AutoSDK">
    <AutoSDK_Namespace>Ollama</AutoSDK_Namespace>
    <AutoSDK_ClassName>OllamaApi</AutoSDK_ClassName>

    
    <AutoSDK_GenerateSdk>false</AutoSDK_GenerateSdk>
    <AutoSDK_GenerateModels>true</AutoSDK_GenerateModels>
    <AutoSDK_GenerateMethods>true</AutoSDK_GenerateMethods>
    <AutoSDK_GenerateConstructors>true</AutoSDK_GenerateConstructors>
    <AutoSDK_IncludeOperationIds>getPet;deletePet</AutoSDK_IncludeOperationIds>
    <AutoSDK_ExcludeOperationIds>getPet;deletePet</AutoSDK_ExcludeOperationIds>
    <AutoSDK_IncludeModels>Pet;Model</AutoSDK_IncludeModels>
    <AutoSDK_ExcludeModels>Pet;Model</AutoSDK_ExcludeModels>
</PropertyGroup>
  • It's all! Now you can build your project and use the generated code. You also can use IDE to see the generated code in any moment, this is a example for Rider:
    rider_show_generated_code.png

Trimming support

CLI

CLI generates Trimming/NativeAOT compatible code by default.

Source generator

Since there are two source generators involved, we will have to create a second project so that the generator for the JsonSerializerContext will “see” our models

  • Create new project for your models. And disable methods/constructors generation:
<PropertyGroup Label="AutoSDK">
    <AutoSDK_GenerateSdk>false</AutoSDK_GenerateSdk>
    <AutoSDK_GenerateModels>true</AutoSDK_GenerateModels>
    <AutoSDK_GenerateJsonSerializerContextTypes>true</AutoSDK_GenerateJsonSerializerContextTypes>
</PropertyGroup>
  • Reference this project in your main project.
  • Add SourceGenerationContext.cs file to your main project with the following content:
using System.Text.Json.Serialization;

namespace Namespace;

[JsonSourceGenerationOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
[JsonSerializable(typeof(AutoSDKTrimmableSupport))]
internal sealed partial class SourceGenerationContext : JsonSerializerContext;
  • Add the following settings to your main csproj file:
<PropertyGroup Label="AutoSDK">
    <AutoSDK_GenerateSdk>false</AutoSDK_GenerateSdk>
    <AutoSDK_GenerateMethods>true</AutoSDK_GenerateMethods>
    <AutoSDK_GenerateConstructors>true</AutoSDK_GenerateConstructors>
    <AutoSDK_JsonSerializerContext>Namespace.SourceGenerationContext</AutoSDK_JsonSerializerContext>
</PropertyGroup>
  • Add these settings to your new and main csproj file to enable trimming(or use Directory.Build.props file):
<PropertyGroup Label="Trimmable" Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
    <IsAotCompatible>true</IsAotCompatible>
    <EnableTrimAnalyzer>true</EnableTrimAnalyzer>
    <IsTrimmable>true</IsTrimmable>
    <SuppressTrimAnalysisWarnings>false</SuppressTrimAnalysisWarnings>
    <TrimmerSingleWarn>false</TrimmerSingleWarn>
</PropertyGroup>
  • It's all! Now you can build your project and use the generated code with full trimming/nativeAOT support.

Known Errors

Generator error: "Could not write to output file 'Path/to/file'. Could not find part of the path"

This error happens if the generated file path is too long. This happens if you didn't activated long path support on windows. To enable it follow the offical docs: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#registry-setting-to-enable-long-paths

📚Examples of use in real SDKs📚

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.

This package has no dependencies.

Version Downloads Last Updated
0.28.1-dev.114 918 1/21/2026
0.28.1-dev.113 64 1/21/2026
0.28.1-dev.75 35,414 6/30/2025
0.28.1-dev.74 1,365 6/25/2025
0.28.1-dev.73 155 6/25/2025
0.28.1-dev.72 215 6/25/2025
0.28.1-dev.71 146 6/25/2025
0.28.1-dev.70 148 6/25/2025
0.28.1-dev.67 347 6/24/2025
0.28.1-dev.66 176 6/24/2025
0.28.1-dev.64 159 6/24/2025
0.28.1-dev.63 182 6/24/2025
0.28.1-dev.62 213 6/23/2025
0.28.1-dev.60 1,551 6/18/2025
0.28.1-dev.59 176 6/18/2025
0.28.1-dev.58 331 6/17/2025
0.28.1-dev.57 172 6/17/2025
0.28.1-dev.55 154 6/17/2025
0.28.1-dev.53 271 6/17/2025
0.28.1-dev.50 327 6/17/2025
0.28.1-dev.47 3,115 6/5/2025
0.28.1-dev.46 173 6/5/2025
0.28.1-dev.45 176 6/5/2025
0.28.1-dev.40 5,630 5/15/2025
0.28.1-dev.39 929 5/13/2025
0.28.1-dev.38 484 5/12/2025
0.28.1-dev.36 809 5/9/2025
0.28.1-dev.34 442 5/8/2025
0.28.1-dev.31 311 5/8/2025
0.28.1-dev.30 183 5/8/2025
0.28.1-dev.29 349 5/7/2025
0.28.1-dev.28 171 5/7/2025
0.28.1-dev.27 187 5/7/2025
0.28.1-dev.26 177 5/7/2025
0.28.1-dev.24 184 5/7/2025
0.28.1-dev.23 511 5/6/2025
0.28.1-dev.20 5,448 4/17/2025
0.28.1-dev.18 2,243 4/10/2025
0.28.1-dev.17 261 4/10/2025
0.28.1-dev.16 3,340 3/30/2025
0.28.1-dev.15 181 3/30/2025
0.28.1-dev.8 2,463 3/21/2025
0.28.1-dev.7 183 3/21/2025
0.28.1-dev.4 1,986 3/14/2025
0.28.1-dev.2 2,436 3/6/2025
0.28.0 776 3/5/2025
0.27.1-dev.89 1,650 2/28/2025
0.27.1-dev.88 195 2/27/2025
0.27.1-dev.87 550 2/26/2025
0.27.1-dev.86 198 2/26/2025
0.27.1-dev.85 156 2/26/2025
0.27.1-dev.84 158 2/26/2025
0.27.1-dev.76 5,326 2/7/2025
0.27.1-dev.70 8,472 1/7/2025
0.27.1-dev.69 133 1/7/2025
0.27.1-dev.68 230 1/7/2025
0.27.1-dev.65 4,537 12/22/2024
0.27.1-dev.64 1,351 12/17/2024
0.27.1-dev.59 2,534 12/9/2024
0.27.1-dev.57 222 12/8/2024
0.27.1-dev.53 1,267 12/4/2024
0.27.1-dev.52 665 12/3/2024
0.27.1-dev.44 1,625 11/27/2024
0.27.1-dev.43 147 11/27/2024
0.27.1-dev.37 2,334 11/19/2024
0.27.1-dev.35 1,620 11/14/2024
0.27.1-dev.33 252 11/13/2024
0.27.1-dev.32 157 11/13/2024
0.27.1-dev.30 142 11/13/2024
0.27.1-dev.26 176 11/13/2024
0.27.1-dev.25 149 11/13/2024
0.27.1-dev.22 376 11/12/2024
0.27.1-dev.21 126 11/12/2024
0.27.1-dev.20 129 11/12/2024
0.27.1-dev.9 1,629 11/6/2024
0.27.1-dev.3 1,168 11/2/2024
0.27.1-dev.2 156 11/2/2024
0.27.0 1,068 10/30/2024
0.26.1-dev.73 1,306 10/26/2024
0.26.1-dev.70 402 10/24/2024
0.26.1-dev.68 196 10/24/2024
0.26.1-dev.67 244 10/24/2024
0.26.1-dev.66 137 10/24/2024
0.26.1-dev.65 120 10/24/2024
0.26.1-dev.64 458 10/22/2024
0.26.1-dev.63 112 10/22/2024
0.26.1-dev.61 1,153 10/18/2024
0.26.1-dev.60 283 10/18/2024
0.26.1-dev.58 164 10/18/2024
0.26.1-dev.53 395 10/16/2024
0.26.1-dev.46 841 10/13/2024
0.26.1-dev.45 136 10/13/2024
0.26.1-dev.44 146 10/13/2024
0.26.1-dev.42 382 10/12/2024
0.26.1-dev.37 283 10/12/2024
0.26.1-dev.36 170 10/12/2024
0.26.1-dev.33 159 10/11/2024
0.26.1-dev.32 310 10/11/2024
0.26.1-dev.29 161 10/11/2024
0.26.1-dev.28 127 10/11/2024
0.26.1-dev.27 134 10/11/2024
0.26.1-dev.25 132 10/11/2024
0.26.1-dev.24 103 10/11/2024
0.26.1-dev.17 677 10/8/2024
0.26.1-dev.13 1,198 10/3/2024
0.26.1-dev.12 142 10/3/2024
0.26.1-dev.11 123 10/3/2024
0.26.1-dev.10 157 10/3/2024
0.26.1-dev.9 146 10/3/2024
0.26.1-dev.4 681 10/1/2024
0.26.1-dev.3 147 10/1/2024
0.26.1-dev.2 133 10/1/2024
0.26.1-dev.1 149 10/1/2024
0.26.0 257 10/1/2024
0.25.0 228 10/1/2024
0.24.1-dev.68 134 10/1/2024
0.24.1-dev.67 136 10/1/2024
0.24.1-dev.66 125 10/1/2024
0.24.1-dev.56 1,283 9/23/2024
0.24.1-dev.54 205 9/22/2024
0.24.1-dev.53 123 9/22/2024
0.24.1-dev.52 137 9/22/2024
0.24.1-dev.51 128 9/22/2024
0.24.1-dev.50 124 9/22/2024
0.24.1-dev.49 148 9/22/2024
0.24.1-dev.47 137 9/22/2024
0.24.1-dev.44 169 9/21/2024
0.24.1-dev.41 288 9/20/2024
0.24.1-dev.40 139 9/20/2024
0.24.1-dev.39 107 9/20/2024
0.24.1-dev.33 376 9/17/2024
0.24.1-dev.31 158 9/17/2024
0.24.1-dev.28 300 9/15/2024
0.24.1-dev.27 137 9/15/2024
0.24.1-dev.26 151 9/14/2024
0.24.1-dev.25 107 9/14/2024
0.24.1-dev.24 165 9/12/2024
0.24.1-dev.23 132 9/12/2024
0.24.1-dev.22 156 9/11/2024
0.24.1-dev.19 132 9/11/2024
0.24.1-dev.18 135 9/11/2024
0.24.1-dev.15 123 9/11/2024
0.24.1-dev.14 145 9/11/2024
0.24.1-dev.13 137 9/11/2024
0.24.1-dev.11 136 9/11/2024
0.24.1-dev.10 134 9/11/2024
0.24.1-dev.9 107 9/11/2024
0.24.1-dev.8 124 9/11/2024
0.24.1-dev.7 132 9/11/2024
0.24.1-dev.2 131 9/10/2024
0.24.1-dev.1 141 9/10/2024
0.24.0 206 9/10/2024
0.23.1-dev.3 122 9/10/2024
0.23.1-dev.2 134 9/10/2024
0.23.1-dev.1 131 9/9/2024
0.23.0 211 9/9/2024
0.22.6-dev.10 130 9/9/2024

⭐ Last 10 features:
- feat: Enhance ToTypeString method to handle combined types in OpenAPI 3.1 2026-01-21
- feat: Update target framework to net10.0 across multiple project files 2026-01-21
- feat: Update OpenAPI handling with YAML reader support and improve type handling in schema extensions 2026-01-21
- feat: Update CLI commands and project file for improved OpenAPI handling and disable deprecated commands 2026-01-21
- feat: Step 2 migration 2026-01-20
- feat: Initial migration to Microsoft.OpenAPI 3.2 2026-01-19
- feat: Added ServiceProvider to CLI generation. 2025-06-25
- feat: Add AreKeysUnique extension method and validate unique CLI action names 2025-06-25
- feat: Added Description of parameters for CLI generation. 2025-06-25
- feat: Improve CLI generation. 2025-06-25
🐞 Last 10 bug fixes:
- fix: Replace YamlDotNet.dll with SharpYaml.dll in project file 2026-01-21
- fix: Handle null values in OpenAPI schema processing and improve type safety 2026-01-20
- fix: Fixed CLI generation if Group command name same as endpoint Command name. 2025-06-30
- fix: Fixed missing descriptions in CLI generation. 2025-06-25
- fix(cli): Fixed x-cli-action metadata. 2025-06-24
- fix(cli): Allow to specify CLiAction for CLI generation. 2025-06-24
- fix(cli): Simplified command names for CLI 2025-06-24
- fix(cli): Fixed some warnings in generated code for CLI 2025-06-24
- fix: Fixed deprecation warning for AnyOf/OneOf/AllOf types. 2025-06-18
- fix: Fixed ElevenLabs specific bug. 2025-06-18