AutoSDK.CLI
0.24.1-dev.27
See the version list below for details.
dotnet tool install --global AutoSDK.CLI --version 0.24.1-dev.27
dotnet new tool-manifest
dotnet tool install --local AutoSDK.CLI --version 0.24.1-dev.27
#tool dotnet:?package=AutoSDK.CLI&version=0.24.1-dev.27&prerelease
nuke :add-package AutoSDK.CLI --version 0.24.1-dev.27
AutoSDK
Allows you to partially (for example, only models) or completely generate a native (without dependencies) C# client sdk according to the OpenAPI specification.
Inspired by NSwag ❤️.
🔥Features🔥
- Uses Incremental Source Generators for efficient generation and caching.
- Detects your TargetFramework and generates optimal code for it (including net6.0/net7.0/net8.0 improvements)
- Supports .Net Framework/.Net Standard
- 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
- 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
- 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" />
</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.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.
📚Examples of use in real SDKs📚
Product | Versions 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 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 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. |
This package has no dependencies.
Version | Downloads | Last Updated |
---|---|---|
0.28.1-dev.75 | 13 | 6/30/2025 |
0.28.1-dev.74 | 252 | 6/25/2025 |
0.28.1-dev.73 | 111 | 6/25/2025 |
0.28.1-dev.72 | 167 | 6/25/2025 |
0.28.1-dev.71 | 101 | 6/25/2025 |
0.28.1-dev.70 | 104 | 6/25/2025 |
0.28.1-dev.67 | 302 | 6/24/2025 |
0.28.1-dev.66 | 130 | 6/24/2025 |
0.28.1-dev.64 | 118 | 6/24/2025 |
0.28.1-dev.63 | 110 | 6/24/2025 |
0.28.1-dev.62 | 169 | 6/23/2025 |
0.28.1-dev.60 | 1,471 | 6/18/2025 |
0.28.1-dev.59 | 118 | 6/18/2025 |
0.28.1-dev.58 | 270 | 6/17/2025 |
0.28.1-dev.57 | 108 | 6/17/2025 |
0.28.1-dev.55 | 108 | 6/17/2025 |
0.28.1-dev.53 | 207 | 6/17/2025 |
0.28.1-dev.50 | 269 | 6/17/2025 |
0.28.1-dev.47 | 3,063 | 6/5/2025 |
0.28.1-dev.46 | 116 | 6/5/2025 |
0.28.1-dev.45 | 120 | 6/5/2025 |
0.28.1-dev.40 | 5,594 | 5/15/2025 |
0.28.1-dev.39 | 890 | 5/13/2025 |
0.28.1-dev.38 | 422 | 5/12/2025 |
0.28.1-dev.36 | 746 | 5/9/2025 |
0.28.1-dev.34 | 385 | 5/8/2025 |
0.28.1-dev.31 | 238 | 5/8/2025 |
0.28.1-dev.30 | 124 | 5/8/2025 |
0.28.1-dev.29 | 295 | 5/7/2025 |
0.28.1-dev.28 | 117 | 5/7/2025 |
0.28.1-dev.27 | 118 | 5/7/2025 |
0.28.1-dev.26 | 125 | 5/7/2025 |
0.28.1-dev.24 | 124 | 5/7/2025 |
0.28.1-dev.23 | 448 | 5/6/2025 |
0.28.1-dev.20 | 5,380 | 4/17/2025 |
0.28.1-dev.18 | 2,177 | 4/10/2025 |
0.28.1-dev.17 | 204 | 4/10/2025 |
0.28.1-dev.16 | 3,292 | 3/30/2025 |
0.28.1-dev.15 | 127 | 3/30/2025 |
0.28.1-dev.8 | 2,414 | 3/21/2025 |
0.28.1-dev.7 | 115 | 3/21/2025 |
0.28.1-dev.4 | 1,930 | 3/14/2025 |
0.28.1-dev.2 | 2,385 | 3/6/2025 |
0.28.0 | 659 | 3/5/2025 |
0.27.1-dev.89 | 1,586 | 2/28/2025 |
0.27.1-dev.88 | 148 | 2/27/2025 |
0.27.1-dev.87 | 486 | 2/26/2025 |
0.27.1-dev.86 | 139 | 2/26/2025 |
0.27.1-dev.85 | 99 | 2/26/2025 |
0.27.1-dev.84 | 101 | 2/26/2025 |
0.27.1-dev.76 | 5,265 | 2/7/2025 |
0.27.1-dev.70 | 8,413 | 1/7/2025 |
0.27.1-dev.69 | 73 | 1/7/2025 |
0.27.1-dev.68 | 176 | 1/7/2025 |
0.27.1-dev.65 | 4,478 | 12/22/2024 |
0.27.1-dev.64 | 1,301 | 12/17/2024 |
0.27.1-dev.59 | 2,485 | 12/9/2024 |
0.27.1-dev.57 | 172 | 12/8/2024 |
0.27.1-dev.53 | 1,216 | 12/4/2024 |
0.27.1-dev.52 | 604 | 12/3/2024 |
0.27.1-dev.44 | 1,569 | 11/27/2024 |
0.27.1-dev.43 | 79 | 11/27/2024 |
0.27.1-dev.37 | 2,274 | 11/19/2024 |
0.27.1-dev.35 | 1,568 | 11/14/2024 |
0.27.1-dev.33 | 194 | 11/13/2024 |
0.27.1-dev.32 | 108 | 11/13/2024 |
0.27.1-dev.30 | 82 | 11/13/2024 |
0.27.1-dev.26 | 105 | 11/13/2024 |
0.27.1-dev.25 | 96 | 11/13/2024 |
0.27.1-dev.22 | 319 | 11/12/2024 |
0.27.1-dev.21 | 65 | 11/12/2024 |
0.27.1-dev.20 | 66 | 11/12/2024 |
0.27.1-dev.9 | 1,564 | 11/6/2024 |
0.27.1-dev.3 | 1,108 | 11/2/2024 |
0.27.1-dev.2 | 105 | 11/2/2024 |
0.27.0 | 994 | 10/30/2024 |
0.26.1-dev.73 | 1,254 | 10/26/2024 |
0.26.1-dev.70 | 338 | 10/24/2024 |
0.26.1-dev.68 | 145 | 10/24/2024 |
0.26.1-dev.67 | 185 | 10/24/2024 |
0.26.1-dev.66 | 89 | 10/24/2024 |
0.26.1-dev.65 | 71 | 10/24/2024 |
0.26.1-dev.64 | 393 | 10/22/2024 |
0.26.1-dev.63 | 62 | 10/22/2024 |
0.26.1-dev.61 | 1,102 | 10/18/2024 |
0.26.1-dev.60 | 234 | 10/18/2024 |
0.26.1-dev.58 | 102 | 10/18/2024 |
0.26.1-dev.53 | 338 | 10/16/2024 |
0.26.1-dev.46 | 791 | 10/13/2024 |
0.26.1-dev.45 | 78 | 10/13/2024 |
0.26.1-dev.44 | 91 | 10/13/2024 |
0.26.1-dev.42 | 322 | 10/12/2024 |
0.26.1-dev.37 | 221 | 10/12/2024 |
0.26.1-dev.36 | 106 | 10/12/2024 |
0.26.1-dev.33 | 104 | 10/11/2024 |
0.26.1-dev.32 | 243 | 10/11/2024 |
0.26.1-dev.29 | 92 | 10/11/2024 |
0.26.1-dev.28 | 72 | 10/11/2024 |
0.26.1-dev.27 | 75 | 10/11/2024 |
0.26.1-dev.25 | 73 | 10/11/2024 |
0.26.1-dev.24 | 68 | 10/11/2024 |
0.26.1-dev.17 | 625 | 10/8/2024 |
0.26.1-dev.13 | 1,137 | 10/3/2024 |
0.26.1-dev.12 | 80 | 10/3/2024 |
0.26.1-dev.11 | 69 | 10/3/2024 |
0.26.1-dev.10 | 104 | 10/3/2024 |
0.26.1-dev.9 | 82 | 10/3/2024 |
0.26.1-dev.4 | 629 | 10/1/2024 |
0.26.1-dev.3 | 85 | 10/1/2024 |
0.26.1-dev.2 | 68 | 10/1/2024 |
0.26.1-dev.1 | 82 | 10/1/2024 |
0.26.0 | 176 | 10/1/2024 |
0.25.0 | 147 | 10/1/2024 |
0.24.1-dev.68 | 79 | 10/1/2024 |
0.24.1-dev.67 | 70 | 10/1/2024 |
0.24.1-dev.66 | 72 | 10/1/2024 |
0.24.1-dev.56 | 1,239 | 9/23/2024 |
0.24.1-dev.54 | 148 | 9/22/2024 |
0.24.1-dev.53 | 67 | 9/22/2024 |
0.24.1-dev.52 | 99 | 9/22/2024 |
0.24.1-dev.51 | 70 | 9/22/2024 |
0.24.1-dev.50 | 77 | 9/22/2024 |
0.24.1-dev.49 | 85 | 9/22/2024 |
0.24.1-dev.47 | 85 | 9/22/2024 |
0.24.1-dev.44 | 102 | 9/21/2024 |
0.24.1-dev.41 | 228 | 9/20/2024 |
0.24.1-dev.40 | 81 | 9/20/2024 |
0.24.1-dev.39 | 73 | 9/20/2024 |
0.24.1-dev.33 | 318 | 9/17/2024 |
0.24.1-dev.31 | 102 | 9/17/2024 |
0.24.1-dev.28 | 242 | 9/15/2024 |
0.24.1-dev.27 | 68 | 9/15/2024 |
0.24.1-dev.26 | 90 | 9/14/2024 |
0.24.1-dev.25 | 74 | 9/14/2024 |
0.24.1-dev.24 | 114 | 9/12/2024 |
0.24.1-dev.23 | 68 | 9/12/2024 |
0.24.1-dev.22 | 92 | 9/11/2024 |
0.24.1-dev.19 | 81 | 9/11/2024 |
0.24.1-dev.18 | 75 | 9/11/2024 |
0.24.1-dev.15 | 84 | 9/11/2024 |
0.24.1-dev.14 | 78 | 9/11/2024 |
0.24.1-dev.13 | 79 | 9/11/2024 |
0.24.1-dev.11 | 78 | 9/11/2024 |
0.24.1-dev.10 | 74 | 9/11/2024 |
0.24.1-dev.9 | 71 | 9/11/2024 |
0.24.1-dev.8 | 88 | 9/11/2024 |
0.24.1-dev.7 | 81 | 9/11/2024 |
0.24.1-dev.2 | 84 | 9/10/2024 |
0.24.1-dev.1 | 82 | 9/10/2024 |
0.24.0 | 141 | 9/10/2024 |
0.23.1-dev.3 | 74 | 9/10/2024 |
0.23.1-dev.2 | 78 | 9/10/2024 |
0.23.1-dev.1 | 78 | 9/9/2024 |
0.23.0 | 133 | 9/9/2024 |
0.22.6-dev.10 | 81 | 9/9/2024 |
⭐ Last 10 features:
- feat: Added interfaces. 2024-09-15
- feat: Added ability to override JsonSerializerContext. 2024-09-14
- feat: Added Summary MethodNamingConvention. 2024-09-12
- feat: Added uuid format support as System.Guid. 2024-09-10
- feat: Renamed to AutoSDK. 2024-09-09
- feat: Updated MinVer/Microsoft.OpenAPI 2024-09-07
- feat: Added OpenApiDocument Simplify extension. 2024-09-06
- feat: Added xml doc for Named AnyOfs. 2024-09-06
- feat: Added Unix timestamp detection. 2024-08-30
- feat: Added partial methods for constructors te set up/validate things. 2024-08-29
🐞 Last 10 bug fixes:
- fix: Removed usage of AutoSDK namespace in generated code. 2024-09-14
- fix: Fixed issue with Summary naming and collisions. 2024-09-12
- fix: Fixed issue with Summary naming and collisions. 2024-09-12
- fix: Fixed some issues with Summary method name generator. 2024-09-12
- fix: Fixed settings binding in cli. 2024-09-12
- fix: Fixed HeyGen xml doc issue. 2024-09-12
- fix: Fixed small issue with warnings in xml doc. 2024-09-11
- fix: Fixed issue with trimming for guid support. 2024-09-11
- fix: Don't use System namespace for AnyOf like types. 2024-09-10
- fix: Fixed CLI tool command name. 2024-09-10