Microsoft.OpenApi 2.0.0-preview2

Category overview screenshot

OpenAPI.NET

Package Nuget
Models and Writers nuget
Readers nuget
Hidi nuget

The OpenAPI.NET SDK contains a useful object model for OpenAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.

See more information on the OpenAPI specification and its history here: OpenAPI Initiative

Project Objectives

  • Provide a single shared object model in .NET for OpenAPI descriptions.
  • Include the most primitive Reader for ingesting OpenAPI JSON and YAML documents in both V2 and V3 formats.
  • Provide OpenAPI description writers for both V2 and V3 specification formats.
  • Enable developers to create Readers that translate different data formats into OpenAPI descriptions.

Installation

Processors

The OpenAPI.NET project holds the base object model for representing OpenAPI documents as .NET objects. Some developers have found the need to write processors that convert other data formats into this OpenAPI.NET object model. We'd like to curate that list of processors in this section of the readme.

The base JSON and YAML processors are built into this project. Below is the list of the other supported processor projects.

  • C# Comment / Annotation Processor : Converts standard .NET annotations ( /// comments ) emitted from your build (MSBuild.exe) into OpenAPI.NET document object.

  • OData CSDL Processor : Converts the XML representation of the Entity Data Model (EDM) describing an OData Service into OpenAPI.NET document object.

Example Usage

Creating an OpenAPI Document

var document = new OpenApiDocument
{
    Info = new OpenApiInfo
    {
        Version = "1.0.0",
        Title = "Swagger Petstore (Simple)",
    },
    Servers = new List<OpenApiServer>
    {
        new OpenApiServer { Url = "http://petstore.swagger.io/api" }
    },
    Paths = new OpenApiPaths
    {
        ["/pets"] = new OpenApiPathItem
        {
            Operations = new Dictionary<OperationType, OpenApiOperation>
            {
                [OperationType.Get] = new OpenApiOperation
                {
                    Description = "Returns all pets from the system that the user has access to",
                    Responses = new OpenApiResponses
                    {
                        ["200"] = new OpenApiResponse
                        {
                            Description = "OK"
                        }
                    }
                }
            }
        }
    }
};

Reading and writing an OpenAPI description

var httpClient = new HttpClient
{
    BaseAddress = new Uri("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/")
};

var stream = await httpClient.GetStreamAsync("master/examples/v3.0/petstore.yaml");

// Read V3 as YAML
var openApiDocument = new OpenApiStreamReader().Read(stream, out var diagnostic);

// Write V2 as JSON
var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json);

Validating/Testing OpenAPI descriptions

In order to test the validity of an OpenApi document, we avail the following tools:

  • Microsoft.OpenApi.Hidi

    A commandline tool for validating and transforming OpenAPI descriptions. Installation guidelines and documentation

  • Microsoft.OpenApi.Workbench

    A workbench tool consisting of a GUI where you can test and convert OpenAPI descriptions in both JSON and YAML from v2-->v3 and vice versa.

    Installation guidelines:

    1. Clone the repo locally by running this command: git clone https://github.com/microsoft/OpenAPI.NET.git
    2. Open the solution file (.sln) in the root of the project with Visual Studio
    3. Navigate to the src/Microsoft.OpenApi.Workbench directory and set it as the startup project
    4. Run the project and you'll see a GUI pop up resembling the one below:
    1. Copy and paste your OpenAPI descriptions in the Input Content window or paste the path to the descriptions file in the Input File textbox and click on Convert to render the results.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

To provide feedback and ask questions you can use Stack Overflow with the OpenAPI.NET tag.

Showing the top 20 packages that depend on Microsoft.OpenApi.

Packages Downloads
Microsoft.AspNetCore.OpenApi
Provides APIs for annotating route handler endpoints in ASP.NET Core with OpenAPI annotations. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/3dfc6fda80a10797b8c8fda1970e7b377fd8ed8d
32
Microsoft.AspNetCore.OpenApi
Provides APIs for annotating route handler endpoints in ASP.NET Core with OpenAPI annotations. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/7c810658463f35c39c54d5fb8a8dbbfd463bf747
30
Microsoft.AspNetCore.OpenApi
Provides APIs for annotating route handler endpoints in ASP.NET Core with OpenAPI annotations. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/8486d31e24f30e3fa1809a95699a0adc16f448d7
29
Microsoft.AspNetCore.OpenApi
Provides APIs for annotating route handler endpoints in ASP.NET Core with OpenAPI annotations. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/d47e49e9c1e173ac90821f7e89cc38e710274241
29
Microsoft.AspNetCore.OpenApi
Provides APIs for annotating route handler endpoints in ASP.NET Core with OpenAPI annotations. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/e56abc45c4f8adc518abfc11a59849d616431e2c
30
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
28
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
29
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
31
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
32
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
132
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
225
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
444
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from API's built on ASP.NET Core
28
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from API's built on ASP.NET Core
29
Swashbuckle.AspNetCore.SwaggerGen
Swagger Generator for API's built on ASP.NET Core
36

https://github.com/microsoft/OpenAPI.NET/releases

.NET Standard 2.0

Version Downloads Last updated
3.9.0 3 07/30/2026
3.8.0 0 07/06/2026
3.7.0 5 06/22/2026
3.6.0 5 06/08/2026
3.5.5 5 06/08/2026
3.5.4 5 06/08/2026
3.5.3 10 04/27/2026
3.5.2 12 04/27/2026
3.5.1 9 04/04/2026
3.5.0 13 03/26/2026
3.4.0 13 03/07/2026
3.3.1 11 01/27/2026
3.3.0 10 01/27/2026
3.2.0 19 01/21/2026
3.1.3 17 01/20/2026
3.1.2 12 01/09/2026
3.1.1 13 12/20/2025
3.0.3 14 12/21/2025
3.0.2 18 12/11/2025
3.0.1 16 11/20/2025
3.0.0 19 11/15/2025
2.11.0 1 07/28/2026
2.10.0 0 07/06/2026
2.9.0 6 06/22/2026
2.8.0 6 06/08/2026
2.7.6 10 06/08/2026
2.7.5 3 06/08/2026
2.7.4 13 04/27/2026
2.7.3 8 04/28/2026
2.7.2 5 04/05/2026
2.7.1 7 03/26/2026
2.7.0 9 03/07/2026
2.6.1 14 01/27/2026
2.6.0 16 01/26/2026
2.5.0 16 01/21/2026
2.4.3 12 01/21/2026
2.4.2 12 01/08/2026
2.4.1 13 12/21/2025
2.4.0 13 12/21/2025
2.3.12 13 12/21/2025
2.3.11 14 12/11/2025
2.3.10 16 11/20/2025
2.3.9 17 11/09/2025
2.3.8 15 11/05/2025
2.3.7 20 10/27/2025
2.3.6 20 10/23/2025
2.3.5 17 10/21/2025
2.3.4 19 10/08/2025
2.3.3 23 10/06/2025
2.3.2 24 09/21/2025
2.3.1 15 09/11/2025
2.3.0 17 08/29/2025
2.2.0 20 08/28/2025
2.1.0 23 08/22/2025
2.0.1 24 08/23/2025
2.0.0 25 07/11/2025
2.0.0-preview9 24 02/26/2025
2.0.0-preview8 26 02/18/2025
2.0.0-preview7 25 02/18/2025
2.0.0-preview6 27 02/18/2025
2.0.0-preview5 22 01/31/2025
2.0.0-preview4 20 01/19/2025
2.0.0-preview3 22 01/19/2025
2.0.0-preview2 20 01/31/2025
2.0.0-preview10 19 03/07/2025
2.0.0-preview1 26 01/19/2025
2.0.0-preview.31 18 07/11/2025
2.0.0-preview.30 20 07/11/2025
2.0.0-preview.29 22 06/27/2025
2.0.0-preview.28 16 06/27/2025
2.0.0-preview.27 17 06/27/2025
2.0.0-preview.26 24 06/27/2025
2.0.0-preview.25 19 06/27/2025
2.0.0-preview.23 18 06/09/2025
2.0.0-preview.22 27 06/09/2025
2.0.0-preview.21 20 06/27/2025
2.0.0-preview.20 23 06/09/2025
2.0.0-preview.19 22 05/18/2025
2.0.0-preview.18 26 05/18/2025
2.0.0-preview.17 22 04/27/2025
2.0.0-preview.16 17 04/04/2025
2.0.0-preview.15 24 04/04/2025
2.0.0-preview.14 23 04/04/2025
2.0.0-preview.13 29 04/04/2025
2.0.0-preview.12 24 03/07/2025
2.0.0-preview.11 22 03/07/2025
1.6.29 11 04/16/2026
1.6.28 21 10/08/2025
1.6.27 22 10/07/2025
1.6.26 17 09/25/2025
1.6.25 18 08/24/2025
1.6.24 29 04/04/2025
1.6.23 21 01/19/2025
1.6.22 27 01/19/2025
1.6.21 29 01/19/2025
1.6.18 20 01/19/2025
1.6.17 23 01/19/2025
1.6.16 24 01/19/2025
1.6.15 22 01/19/2025
1.6.14 133 03/27/2024
1.6.13 32 03/02/2024
1.6.12 24 03/02/2024
1.6.11 23 03/02/2024
1.6.10 33 03/03/2024
1.6.9 29 01/07/2024
1.6.8 27 03/02/2024
1.6.7 31 03/01/2024
1.6.6 27 03/01/2024
1.6.5 26 03/02/2024
1.6.4 27 03/03/2024
1.6.4-preview4 25 03/05/2024
1.6.4-preview3 25 03/05/2024
1.6.4-preview2 26 03/04/2024
1.6.4-preview1 26 03/05/2024
1.6.3 27 03/01/2024
1.6.2 25 02/08/2024
1.6.1 26 01/01/2024
1.6.0 30 03/01/2024
1.5.0 28 03/02/2024
1.4.5 35 03/24/2024
1.4.4 32 03/02/2024
1.4.4-preview1 22 03/06/2024
1.4.3 44 09/20/2023
1.4.2 25 01/02/2024
1.4.1 24 03/02/2024
1.4.0 32 03/03/2024
1.4.0-preview3 31 03/06/2024
1.4.0-preview2 22 03/06/2024
1.4.0-preview1 29 03/06/2024
1.3.2 34 03/12/2024
1.3.1 34 03/13/2024
1.3.1-preview6 24 03/10/2024
1.3.1-preview5 27 02/28/2024
1.3.1-preview4 29 03/09/2024
1.3.1-preview3 27 11/13/2023
1.3.1-preview2 22 03/09/2024
1.3.1-preview 26 03/06/2024
1.3.0-preview 30 03/04/2024
1.2.3 612 08/18/2023
1.2.2 25 03/12/2024
1.2.1 33 03/25/2024
1.2.0 33 12/20/2023
1.2.0-preview.3 26 03/04/2024
1.2.0-preview.2 23 03/04/2024
1.2.0-preview 34 03/04/2024
1.1.4 26 08/18/2023
1.1.3 27 03/02/2024
1.1.2 32 03/02/2024
1.1.1 27 08/18/2023
1.1.0 29 03/01/2024
1.1.0-preview.4 24 03/06/2024
1.1.0-preview.3 28 03/06/2024
1.1.0-preview.2 22 03/06/2024
1.1.0-preview.1 30 03/05/2024
1.0.1 30 03/12/2024
1.0.0 30 03/02/2024
1.0.0-beta017 23 03/02/2024
1.0.0-beta016 26 03/13/2024
1.0.0-beta015 25 03/03/2024
1.0.0-beta014 24 03/03/2024
1.0.0-beta013 31 03/08/2024
1.0.0-beta012 24 03/03/2024
1.0.0-beta011 24 03/13/2024
1.0.0-beta010 22 01/19/2025
1.0.0-beta009 23 03/03/2024
1.0.0-beta008 26 03/06/2024