Microsoft.OpenApi 2.13.0

Category overview screenshot

OpenAPI.NET

Package Nuget
Models and Writers nuget
YamlReader 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

Note: we just released a new major version of the library, which brings support for OpenAPI 3.1! You can read more about the changes of this upcoming version in the upgrade guide.

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()
            {
                [HttpMethod.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 (openApiDocument, _) = await OpenApiDocument.LoadAsync("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/refs/heads/main/_archive_/schemas/v3.0/pass/petstore.yaml");

// Write V2 as JSON
var outputString = await openApiDocument.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi2_0);

Validating/Testing OpenAPI descriptions

Microsoft.OpenApi.Hidi is a command line tool for validating and transforming OpenAPI descriptions. The OpenAPI.NET v2-compatible tool is maintained in OpenAPI.NET.OData's support/v2 branch. See its installation guidelines and documentation.

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
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
42
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
39
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
38
Swashbuckle.AspNetCore.SwaggerGen
Swagger Generator for API's built on ASP.NET Core
38
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from API's built on ASP.NET Core
37
Swashbuckle.AspNetCore.SwaggerGen
Swagger Generator for API's built on ASP.NET Core
37
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
37
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
36
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
35
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from API's built on ASP.NET Core
35

.NET 8.0

  • No dependencies.

.NET Standard 2.0

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