Skip to main content

Major Improvements to the C# v4 SDK (Beta)

· 2 min read

The C# v4 SDK (beta) has picked up a wave of improvements over the past few weeks, spanning streaming, dependency injection, documentation, error handling, and file handling.

What's New?

Here is a roundup of what has landed in the C# v4 SDK:

  • Server-Sent Events (SSE) Streaming: Operations that return a text/event-stream response are generated as streaming methods, so you read events incrementally as they arrive instead of waiting for the full response body.
  • Inline XML Documentation: Endpoints, models, and their properties now carry XML doc comments, so descriptions, parameters, and return types surface as IntelliSense tooltips right in your IDE.
  • License Support: Each SDK ships with a LICENSE file and reflects the chosen license in the generated README, so distribution terms are clear from the start.
  • Parameter Defaults and Constants: Endpoint parameters and model properties carry their spec-defined default values, so you only set what you intend to override. Values fixed by the spec are generated as constants, so they are always sent correctly without any input from you.
  • ASP.NET Core Dependency Injection: A service-collection extension registers the client in a single call with the HttpClient managed by IHttpClientFactory, making the SDK a first-class citizen in ASP.NET Core apps.
  • Status Code Range Error Handling: Error responses can be matched by status-code ranges such as 4XX and 5XX, so the SDK maps responses to the right error type even when the API returns a code that is not individually documented.
  • Tag-Based API Grouping: Endpoints are organized by their OpenAPI tags. With multiple tags, the SDK creates a controller per tag and exposes those controllers from the main client. With a single tag or no tags, the endpoints live directly on the main client.
  • Generated README and API Reference: Every SDK includes a README covering installation, configuration, and quick-start usage, plus a separate API reference documenting each operation's parameters, responses, and errors.
  • File Type Support: Endpoints that accept or return files support uploads and downloads, taking common inputs such as byte arrays, streams, and file info for multipart/form-data requests and handling binary responses.

All of this is available in the C# v4 SDK (beta). Generate it from the APIMatic CLI:

apimatic sdk generate --language=csharp --codegen-version=v4 --stability=beta

For the full set of flags and options, see the APIMatic CLI documentation.