AutoSDK 0.30.1-dev.90
See the version list below for details.
dotnet add package AutoSDK --version 0.30.1-dev.90
NuGet\Install-Package AutoSDK -Version 0.30.1-dev.90
<PackageReference Include="AutoSDK" Version="0.30.1-dev.90" />
<PackageVersion Include="AutoSDK" Version="0.30.1-dev.90" />
<PackageReference Include="AutoSDK" />
paket add AutoSDK --version 0.30.1-dev.90
#r "nuget: AutoSDK, 0.30.1-dev.90"
#:package AutoSDK@0.30.1-dev.90
#addin nuget:?package=AutoSDK&version=0.30.1-dev.90&prerelease
#tool nuget:?package=AutoSDK&version=0.30.1-dev.90&prerelease
AutoSDK
The goal of this project is to automate and minimize the effort of maintaining high-quality .NET SDKs generated based on OpenAPI and AsyncAPI specifications, 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 AsyncAPI specs for WebSocket client generation (send/receive methods, cross-namespace schema referencing)
- Supports SSE (Server-Sent Events) through the
application/x-ndjsoncontent 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🚀
CLI (Recommended)
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:
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.csfile 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
AsyncAPI / WebSocket Support
AutoSDK can generate typed WebSocket clients from AsyncAPI 3.0 specifications, producing send/receive methods for each channel operation.
Basic Usage
autosdk generate asyncapi.yaml \
--namespace MyApi.Realtime \
--websocket-class-name MyRealtimeClient \
--output Generated
This generates:
- A WebSocket client class with connect/disconnect lifecycle
- Typed
Send*methods for publish operations - Typed
Receive*methods (via event callbacks) for subscribe operations - All associated models, enums, and JSON converters
Cross-Namespace Schema Referencing
When an API has both REST (OpenAPI) and WebSocket (AsyncAPI) specs that share model types, you can generate them into separate namespaces while avoiding model duplication:
# Step 1: Generate REST API (models + HTTP client) in main namespace
autosdk generate openapi.yaml \
--namespace MyApi \
--clientClassName MyApiClient \
--output Generated
# Step 2: Generate WebSocket client referencing existing REST types
autosdk generate asyncapi.yaml \
--namespace MyApi.Realtime \
--websocket-class-name MyRealtimeClient \
--types-namespace MyApi \
--generate-models false \
--json-serializer-context MyApi.SourceGenerationContext \
--output Generated
Key options:
--types-namespace <ns>— Generated WebSocket client usesglobal::<ns>.{TypeName}references instead of its own namespace--generate-models false— Skips model/enum/converter generation (they already exist in the types namespace)--json-serializer-context <ctx>— References an existingJsonSerializerContextfrom the types namespace--websocket-class-name <name>— Overrides the generated WebSocket client class name
Note: AsyncAPI schema names must match the target namespace's type names. If they differ (e.g., OpenAI where AsyncAPI uses different names), use separate namespaces with full model generation instead.
Real-world examples
- tryAGI/OpenAI — REST API + Realtime WebSocket API
- tryAGI/ElevenLabs — REST API + Realtime Speech-to-Text WebSocket API
- tryAGI/Xai — REST API + Realtime Voice Agent WebSocket API
🤖 Claude Code Skill
AutoSDK is available as a Claude Code skill via skills.sh, enabling AI-assisted SDK generation directly from your terminal.
Install
npx skills add tryAGI/AutoSDK@generating-dotnet-sdks
Usage
Once installed, you can use natural language prompts in Claude Code like:
- "Generate a C# SDK from this OpenAPI spec"
- "Scaffold a new AutoSDK project for the Stripe API"
- "Help me customize the generated client with streaming support"
Claude Code will use the skill's knowledge of AutoSDK CLI options, project conventions, and customization patterns to produce correct commands and code.
What's included
The skill provides Claude Code with detailed knowledge of:
- CLI commands and all their options (
generate,init,http,ai spec-from-docs) - Standard project structure and the
generate.shregeneration pattern - AsyncAPI / WebSocket client generation and cross-namespace schema referencing
- Post-generation customization (partial classes, client hooks, trimming support)
- Troubleshooting common issues
Skill source: skills/generating-dotnet-sdks/
📚Examples of use in real SDKs📚
- https://github.com/tryAGI/OpenAI — REST + WebSocket (AsyncAPI)
- https://github.com/tryAGI/ElevenLabs — REST + WebSocket (AsyncAPI)
- https://github.com/tryAGI/Xai — REST + WebSocket (AsyncAPI)
- https://github.com/tryAGI/Ollama
- https://github.com/tryAGI/Anthropic
- https://github.com/tryAGI/LangSmith
- https://github.com/tryAGI/Replicate
- https://github.com/tryAGI/DeepInfra
- https://github.com/tryAGI/Leonardo
- https://github.com/HavenDV/GitHub.NET
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.OpenApi (>= 3.4.0)
- Microsoft.OpenApi.YamlReader (>= 3.4.0)
- System.Collections.Immutable (>= 10.0.5)
- System.Text.Json (>= 10.0.5)
-
.NETStandard 2.0
- Microsoft.OpenApi (>= 3.4.0)
- Microsoft.OpenApi.YamlReader (>= 3.4.0)
- System.Collections.Immutable (>= 10.0.5)
- System.Text.Json (>= 10.0.5)
-
net10.0
- Microsoft.OpenApi (>= 3.4.0)
- Microsoft.OpenApi.YamlReader (>= 3.4.0)
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.30.1-dev.107 | 0 | 3/21/2026 |
| 0.30.1-dev.106 | 0 | 3/21/2026 |
| 0.30.1-dev.105 | 0 | 3/21/2026 |
| 0.30.1-dev.104 | 0 | 3/21/2026 |
| 0.30.1-dev.102 | 0 | 3/21/2026 |
| 0.30.1-dev.101 | 0 | 3/21/2026 |
| 0.30.1-dev.100 | 0 | 3/21/2026 |
| 0.30.1-dev.99 | 0 | 3/21/2026 |
| 0.30.1-dev.98 | 0 | 3/21/2026 |
| 0.30.1-dev.97 | 0 | 3/21/2026 |
| 0.30.1-dev.96 | 0 | 3/21/2026 |
| 0.30.1-dev.95 | 0 | 3/21/2026 |
| 0.30.1-dev.94 | 0 | 3/21/2026 |
| 0.30.1-dev.93 | 0 | 3/21/2026 |
| 0.30.1-dev.92 | 0 | 3/21/2026 |
| 0.30.1-dev.91 | 0 | 3/21/2026 |
| 0.30.1-dev.90 | 0 | 3/21/2026 |
| 0.30.1-dev.89 | 0 | 3/21/2026 |
| 0.30.1-dev.82 | 0 | 3/21/2026 |
| 0.30.0 | 143 | 3/15/2026 |
⭐ Last 10 features:
- docs: Add AsyncAPI / WebSocket support documentation to README 2026-03-21
- feat: Enable UseExtensionNaming by default with proper sub-client generation 2026-03-21
- feat: Support 14 OpenAPI x- extensions for improved SDK generation 2026-03-20
- feat: Add discriminated union support for WebSocket receive events 2026-03-20
- feat: Add AsyncAPI spec support for WebSocket client code generation 2026-03-19
- feat: Add EXAMPLES markers to README.md template 2026-03-19
- feat: Generate autosdk.docs.json in init command 2026-03-19
- feat: Standardize docs on single metadata example pattern 2026-03-19
- feat: add workflow_dispatch trigger to mkdocs workflow template 2026-03-19
- feat: Fixed duplicated Tags issue #155 2026-03-13
🐞 Last 10 bug fixes:
- perf: Extract keyword escape dictionary, fix CA warnings, add benchmark test 2026-03-21
- perf: Replace remaining LINQ, fix ComputeEnum ToUpperInvariant, pre-size operation lists 2026-03-21
- perf: Replace LINQ in GetCSharpTypeCore, fix IsUnixTimestamp allocation, pre-build operation schema lookup 2026-03-21
- perf: Optimize ComputeEnum, ResolveCollisions, and add primitive TypeData fast path 2026-03-21
- perf: Replace LINQ chains in AnyOfData and GetSchemas with explicit loops 2026-03-21
- test: Add tag filtering, CLI collision tests and BenchmarkDotNet project 2026-03-21
- feat: Enable UseExtensionNaming by default with proper sub-client generation 2026-03-21
- fix: Restore trailing spaces in Sources template strings 2026-03-20
- feat: Support 14 OpenAPI x- extensions for improved SDK generation 2026-03-20
- fix: Fix multi-spec generation issues for CLI 2026-03-20