DotNET web projects with REST APIs can provide typed API client libraries automatically using OpenAPI and related tooling. If you have an HTTP API that is used by a frontend, other services internally, or is a public API consider generating SDK clients. In this tutorial we will demonstrate how to use Autorest, OpenAPI (Swagger) and SwashBuckle with .NET projects to scaffold and publish development kits.

Setup a .NET project

To use OpenAPi with DotNET create a new project. Add the Swashbuckle package references shown to your to enable annotations and the CLI for generation of the open api spec:

Annotate controller endpoints

For each web controller endpoint that your wish to expose in your library add a annotation.

Add post build generation step

In your and a post build step to generate the swagger JSON file from the project dll.

Create a devops pipeline to build and publish

To build your project in Azure Devops and publish a client to an Artifact Repository create an file and add the following:

Then include the steps below to install autorest and generate a client in Typescript