Microsoft.OpenApi 2.13.1

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);

External references are loaded only when OpenApiReaderSettings.LoadExternalRefs is enabled. MaxExternalReferenceDepth defaults to 64 external document hops (the root is depth zero) and can be set to a higher positive value for deeper descriptions. It is independent of JSON/YAML nesting limits. External documents are reused within a load, allowing valid recursive schemas across files without repeated requests. Exceeding the depth limit or encountering an external reference-only loop returns a ReadResult with a null Document and an error in Diagnostic.Errors. Annotation-only siblings, such as description, do not exempt a reference from loop detection.

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
38
Swashbuckle.AspNetCore.Swagger
Middleware to expose Swagger JSON endpoints from API's built on ASP.NET Core
38
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 API's built on ASP.NET Core
37

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

.NET 8.0

  • No dependencies.

.NET Standard 2.0

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