Loading...
Loading...
Generates .NET/C# SDKs from OpenAPI specifications using the AutoSDK CLI tool (autosdk.cli). Use when the user wants to create a C# client library from an OpenAPI/Swagger spec, scaffold a new SDK project, regenerate existing SDK code, or customize generated .NET API clients.
npx skill4agent add tryagi/autosdk generating-dotnet-sdksapplication/x-ndjsondotnet tool install --global autosdk.cli --prerelease# Download from URL
curl -o openapi.yaml https://example.com/api/openapi.yaml
# Or use a local file
ls openapi.yamlrm -rf Generated
autosdk generate openapi.yaml \
--namespace MyCompany.MyApi \
--clientClassName MyApiClient \
--targetFramework net8.0 \
--output GeneratedGenerated/dotnet buildGenerated/autosdk generate <input>autosdk generate openapi.yaml \
--namespace Anthropic \
--clientClassName AnthropicClient \
--targetFramework net8.0 \
--output Generated \
--exclude-deprecated-operations| Option | Alias | Default | Description |
|---|---|---|---|
| | | Output directory for generated files |
| | | Target framework (e.g., |
| | Derived from filename | C# namespace for generated code |
| | Derived from filename | Name of the generated client class |
| | | How method names are derived |
| | | Output all code in a single .cs file |
| | | Skip deprecated API operations |
| | Continue generation despite spec errors | |
| | Generate model validation methods | |
| | Compute discriminators for polymorphic models | |
| | Generate a CLI wrapper for the client | |
| (none) | Inject auth scheme as | |
| (none) | Server base URL to inject for specs missing |
autosdk init <solution-name> <client-name> <openapi-spec> <company>autosdk init MyApi MyApiClient https://example.com/openapi.yaml MyCompany.slnxgenerate.shREADME.mdLICENSE.gitignore--output-o--add-mkdocs-m--add-tests-tautosdk http <input>.httpautosdk http openapi.yaml --output TestingMyApi/
├── MyApi.sln
├── src/
│ ├── libs/MyApi/
│ │ ├── MyApi.csproj
│ │ ├── openapi.yaml # Source OpenAPI spec
│ │ ├── generate.sh # Regeneration script
│ │ ├── Generated/ # AUTO-GENERATED -- never edit
│ │ │ ├── MyApiClient.g.cs
│ │ │ ├── Models/*.g.cs
│ │ │ └── ...
│ │ └── *.cs # Hand-written extensions
│ ├── tests/IntegrationTests/
│ └── helpers/
│ ├── GenerateDocs/ # Doc generation
│ └── TrimmingHelper/ # NativeAOT validation
└── .github/workflows/
└── auto-update.ymlGenerated/Generated/generate.shdotnet tool install --global autosdk.cli --prerelease
rm -rf Generated
curl -o openapi.yaml https://example.com/openapi.yaml
autosdk generate openapi.yaml \
--namespace Anthropic \
--clientClassName AnthropicClient \
--targetFramework net8.0 \
--output Generated \
--exclude-deprecated-operationsgenerate.shsecuritySchemes--security-schemeautosdk generate openapi.yaml \
--namespace Anthropic \
--clientClassName AnthropicClient \
--targetFramework net8.0 \
--output Generated \
--security-scheme "ApiKey:Header:x-api-key"servers--base-urlautosdk generate openapi.yaml \
--namespace ElevenLabs \
--clientClassName ElevenLabsClient \
--targetFramework net8.0 \
--output Generated \
--base-url "https://api.elevenlabs.io"public partial class MyApiClient
{
partial void PrepareArguments(/* modify parameters before request */);
partial void PrepareRequest(HttpClient client, HttpRequestMessage request);
partial void ProcessResponse(HttpClient client, HttpResponseMessage response);
partial void ProcessResponseContent(HttpClient client, HttpResponseMessage response, ref string content);
}Generated/MyApiClient.Streaming.csMyApiClient.AdditionalConstructors.csJsonSerializerContextTypes.AdditionalTypes.csExtensions/generate| Flag | Purpose | When to use |
|---|---|---|
| Set target framework | Always set explicitly for your project |
| Set C# namespace | Always set to match your project namespace |
| Set client class name | Always set to a descriptive name |
| Skip deprecated endpoints | Most production SDKs |
| Tolerate spec issues | Specs with minor validation errors |
| One output file | Smaller APIs or embedding in existing projects |
| Polymorphic model support | APIs with oneOf/anyOf discriminators |
| Model validation methods | When input validation is needed |
| Generate CLI wrapper | When you want a CLI for the API |
| Method name style | |
| Inject auth for specs missing | |
generate.shjqyqsedperl--ignore-openapi-errorssecuritySchemes--security-scheme "ApiKey:Header:x-api-key"