OpenAPI in .NET Core

Jawadhasan
4 min readAug 9, 2023
Photo by Annie Spratt on Unsplash

Introduction

Correct API documentation is essential.

Documentation can be generated from an OpenAPI specification.

An OpenAPI specification describes the capabilities of our API, and how to interact with it.

It’s standardized, and in JSON or YAML format.

What is Swagger

OpenAPI specifications and Swagger specifications are the same thing.

Swagger is a set of Open Source tools built around OpenAPI.

Swashbuckle.AspNetCore helps working with OpenAPI in .NET Core.

Swashbuckle.AspNetCore

  • Generates an OpenAPI specification from your API.
  • Wraps Swagger-UI and provides an embedded version of it.
  • NSwag is an alternative for Swashbuckle.

Swashbuckle is used both for OpenAPI generation and for generating a documentation UI.

OpenAPI in .NET Core Web API (New Project)

When creating new Project, we can simple click a check box to enable OpenAPI support in our project.

I simply start by creating a new Web API project in Visual Studio and checked Enable OpenAPI support as follows:

--

--

Jawadhasan

Software Solutions Team Lead | Cloud Architect | Solutions Architect