AutoSDK
Concepts

Project Structure

Standard SDK project layout and conventions used by AutoSDK.

AutoSDK-generated SDKs follow a standard project layout that supports CI/CD, testing, documentation, and auto-updates.

Standard Layout

MyApi/
├── MyApi.slnx                          # Solution file
├── src/
│   ├── key.snk                         # Strong naming key
│   ├── libs/MyApi/
│   │   ├── MyApi.csproj                # Library project
│   │   ├── openapi.yaml               # Source OpenAPI spec
│   │   ├── generate.sh                # Regeneration script
│   │   ├── Generated/                 # Auto-generated code (never edit)
│   │   │   ├── MyApiClient.g.cs
│   │   │   ├── *.Models.g.cs
│   │   │   ├── SourceGenerationContext.g.cs
│   │   │   └── ...
│   │   ├── MyApiClient.Auth.cs        # Hand-written extensions
│   │   └── Extensions/               # MEAI implementations, helpers
│   └── tests/IntegrationTests/
│       ├── IntegrationTests.csproj
│       └── Examples/                  # Test + docs source of truth
│           ├── ChatCompletion.cs
│           └── ...
├── docs/                              # MkDocs Material site
│   ├── index.md
│   ├── guides/
│   └── examples/                      # Auto-generated from Examples/
├── .github/workflows/
│   ├── auto-update.yml               # Fetch latest spec every 3 hours
│   ├── ci.yml                         # Build + test
│   └── mkdocs.yml                     # Deploy docs
└── README.md

Key Conventions

Generated Code

  • Location: Always in Generated/ subdirectory
  • Suffix: All files end with .g.cs
  • Rule: Never manually edit files in Generated/ — they are overwritten on regeneration

Hand-Written Extensions

  • Location: Alongside Generated/ in the library root or Extensions/ subdirectory
  • Pattern: Partial classes that extend generated types
  • Naming: {ClientName}.{Feature}.cs (e.g., MyApiClient.ChatClient.cs)

generate.sh

The single source of truth for SDK regeneration:

#!/bin/bash
set -e

# Download latest spec
curl -s https://api.example.com/openapi.json -o openapi.json

# Optional: patch the spec
cat openapi.json | jq '.security = [{"BearerAuth": []}]' > patched.json

# Generate
autosdk generate patched.json \
  --namespace MyCompany.MyApi \
  --clientClassName MyApiClient \
  --output Generated

Target Framework

  • New SDKs target net10.0 only
  • Legacy infrastructure (Tiktoken, CSharpToJsonSchema) multi-targets

Versioning

  • MinVer with v tag prefix
  • Tags like v7.0.0 trigger version detection
  • Pre-release versions from branch names

Testing

  • Framework: MSTest
  • Assertions: AwesomeAssertions
  • API keys: From environment variables (skip if unset)
  • Examples: Examples/ directory serves as both tests and documentation source

Documentation

  • Engine: MkDocs Material
  • Source: Examples/ test files with //// comment annotations
  • Generation: autosdk docs sync . generates markdown from tests
  • Deployment: GitHub Pages via GitHub Actions

CI/CD Workflows

auto-update.yml

Runs every 3 hours:

  1. Downloads the latest OpenAPI spec
  2. Runs generate.sh
  3. If changes detected, opens a PR

ci.yml

Runs on push/PR:

  1. Build the SDK
  2. Run integration tests
  3. Publish to NuGet (on tag)

mkdocs.yml

Deploys documentation to GitHub Pages on push to main.

Edit on GitHub

Last updated on

On this page