![]() |
VOOZH | about |
dotnet add package Microsoft.OpenApi.OData --version 3.2.1
NuGet\Install-Package Microsoft.OpenApi.OData -Version 3.2.1
<PackageReference Include="Microsoft.OpenApi.OData" Version="3.2.1" />
<PackageVersion Include="Microsoft.OpenApi.OData" Version="3.2.1" />Directory.Packages.props
<PackageReference Include="Microsoft.OpenApi.OData" />Project file
paket add Microsoft.OpenApi.OData --version 3.2.1
#r "nuget: Microsoft.OpenApi.OData, 3.2.1"
#:package Microsoft.OpenApi.OData@3.2.1
#addin nuget:?package=Microsoft.OpenApi.OData&version=3.2.1Install as a Cake Addin
#tool nuget:?package=Microsoft.OpenApi.OData&version=3.2.1Install as a Cake Tool
The Microsoft.OpenAPI.OData.Reader library helps represent an OData service metadata as an OpenApi description. It converts OData CSDL, the XML representation of the Entity Data Model (EDM) describing an OData service into Open API based on OpenAPI.NET object model.
The conversion is based on the mapping doc from OASIS OData OpenAPI v1.0 and uses the following :
The image below is generic overview of how this library can convert the EDM model to an OpenAPI.NET document object.
For more information on the CSDL and Entity Data model, please refer to http://www.odata.org/documentation. For more information about the Open API object of model, please refer to http://github.com/microsoft/OpenAPI.NET
The following sample code illustrates the use of the library
public static void GenerateOpenApiDescription()
{
IEdmModel model = GetEdmModel();
OpenApiDocument document = model.ConvertToOpenApi();
var outputJSON = document.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
var outputYAML = document.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
}
public static IEdmModel GetEdmModel()
{
// load EDM model here...
}
Or with the convert settings:
public static void GenerateOpenApiDescription()
{
IEdmModel model = GetEdmModel();
OpenApiConvertSettings settings = new OpenApiConvertSettings
{
// configuration
};
OpenApiDocument document = model.ConvertToOpenApi(settings);
var outputJSON = document.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
var outputYAML = document.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
}
public static IEdmModel GetEdmModel()
{
// load EDM model here...
}
The GetEdmModel() method can load a model in 3 ways:
Create the Edm model from scratch. For details refer building a basic model
Load the Edm model from CSDL file. The following shows a code sample that loads a model from a csdl file.
public static IEdmModel GetEdmModel()
{
string csdlFilePath = @"c:\csdl.xml";
string csdl = System.IO.File.ReadAllText(csdlFilePath);
IEdmModel model = CsdlReader.Parse(XElement.Parse(csdl).CreateReader());
return model;
}
Create the Edm model using Web API OData model builder. For details refer to the web api model builder article
The OpenAPI.OData.reader nuget package is at: https://www.nuget.org/packages/Microsoft.OpenApi.OData/
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.
You can also open an issue directly on this repo via this link.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 5 NuGet packages that depend on Microsoft.OpenApi.OData:
| Package | Downloads |
|---|---|
|
DT-ESA.Elevate.SecureConnectors
Generates DTO classes and provides wrappers for resource access. |
|
|
Swashbuckle.AspNetCore.Community.OData
Provides support for Microsoft.AspNetCore.OData in Swashbuckle |
|
|
Microsoft.Restier.AspNetCore.Swagger
Package Description |
|
|
WuicCore
KonvergenceCore runtime and APIs. |
|
|
WuicOData
Package Description |
Showing the top 3 popular GitHub repositories that depend on Microsoft.OpenApi.OData:
| Repository | Stars |
|---|---|
|
OData/AspNetCoreOData
ASP.NET Core OData: A server library built upon ODataLib and ASP.NET Core
|
|
|
OData/RESTier
A turn-key library for building RESTful services
|
|
|
unchase/Unchase.OpenAPI.Connectedservice
:scroll: Visual Studio extension to generate OpenAPI (Swagger) web service reference.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.2.1 | 10,853 | 4/14/2026 |
| 3.2.0 | 11,037 | 3/19/2026 |
| 3.1.0 | 23,738 | 1/16/2026 |
| 3.0.0 | 51,330 | 11/12/2025 |
| 2.2.1 | 3,131 | 4/14/2026 |
| 2.2.0 | 8,670 | 3/20/2026 |
| 2.1.0 | 18,124 | 1/16/2026 |
| 2.0.0 | 58,855 | 7/10/2025 |
| 2.0.0-preview.18 | 825 | 7/2/2025 |
| 2.0.0-preview.17 | 325 | 7/2/2025 |
| 2.0.0-preview.16 | 264 | 7/2/2025 |
| 2.0.0-preview.15 | 1,118 | 6/3/2025 |
| 2.0.0-preview.14 | 1,006 | 5/14/2025 |
| 2.0.0-preview.13 | 951 | 4/17/2025 |
| 2.0.0-preview.12 | 1,157 | 4/2/2025 |
| 2.0.0-preview.11 | 293 | 3/19/2025 |
| 2.0.0-preview.10 | 859 | 3/18/2025 |
| 1.7.6 | 5,002 | 4/14/2026 |
| 1.7.5 | 139,798 | 3/31/2025 |