Microsoft.OpenApi.OData
1.6.8
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.OpenApi.OData --version 1.6.8
NuGet\Install-Package Microsoft.OpenApi.OData -Version 1.6.8
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.6.8" />
paket add Microsoft.OpenApi.OData --version 1.6.8
#r "nuget: Microsoft.OpenApi.OData, 1.6.8"
// Install Microsoft.OpenApi.OData as a Cake Addin #addin nuget:?package=Microsoft.OpenApi.OData&version=1.6.8 // Install Microsoft.OpenApi.OData as a Cake Tool #tool nuget:?package=Microsoft.OpenApi.OData&version=1.6.8
Convert OData to OpenAPI.NET
Introduction
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 :
- Capabilities vocabulary annotation
- Authorization vocabulary annotation
- Core vocabulary annotation
- Navigation property path
- Edm operation and operation import path
Overview
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
Sample code
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
Nuget packages
The OpenAPI.OData.reader nuget package is at: https://www.nuget.org/packages/Microsoft.OpenApi.OData/
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.
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 opencode@microsoft.com with any additional questions or comments.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.OData.Edm (>= 7.21.3)
- Microsoft.OpenApi (>= 1.6.15)
NuGet packages (6)
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 |
|
DT-ESA.SecureConnectors
Generates DTO classes and provides wrappers for resource access. |
|
ITP.Helpers
Helper library for ITP |
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on Microsoft.OpenApi.OData:
Repository | Stars |
---|---|
microsoft/OpenAPI.NET
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.
|
|
OData/RESTier
A turn-key library for building RESTful services
|
|
OData/AspNetCoreOData
ASP.NET Core OData: A server library built upon ODataLib and ASP.NET Core
|
|
unchase/Unchase.OpenAPI.Connectedservice
:scroll: Visual Studio extension to generate OpenAPI (Swagger) web service reference.
|
Version | Downloads | Last updated |
---|---|---|
2.0.0-preview.7 | 641 | 10/28/2024 |
2.0.0-preview.6 | 356 | 10/17/2024 |
2.0.0-preview.5 | 153 | 10/11/2024 |
2.0.0-preview.4 | 104 | 10/10/2024 |
2.0.0-preview.3 | 337 | 10/3/2024 |
2.0.0-preview.2 | 894 | 8/23/2024 |
2.0.0-preview.1 | 94 | 8/16/2024 |
1.6.8 | 23,578 | 7/24/2024 |
1.6.7 | 6,400 | 6/26/2024 |
1.6.6 | 6,319 | 6/11/2024 |
1.6.5 | 3,246 | 5/27/2024 |
1.6.4 | 2,280 | 5/21/2024 |
1.6.3 | 3,281 | 4/29/2024 |
1.6.2 | 1,121 | 4/26/2024 |
1.6.1 | 7,231 | 3/28/2024 |
1.6.0 | 7,480 | 3/18/2024 |
1.6.0-preview.10 | 487 | 3/4/2024 |
1.6.0-preview.9 | 117 | 3/1/2024 |
1.6.0-preview.8 | 150 | 2/13/2024 |
1.6.0-preview.7 | 280 | 2/5/2024 |
1.6.0-preview.6 | 65 | 2/2/2024 |
1.6.0-preview.5 | 88 | 2/1/2024 |
1.6.0-preview.4 | 175 | 1/25/2024 |
1.6.0-preview.3 | 91 | 1/23/2024 |
1.6.0-preview.2 | 186 | 1/16/2024 |
1.6.0-preview.1 | 73 | 1/9/2024 |
1.5.0 | 34,497 | 12/8/2023 |
1.5.0-preview9 | 2,022 | 11/13/2023 |
1.5.0-preview8 | 424 | 11/6/2023 |
1.5.0-preview7 | 715 | 10/26/2023 |
1.5.0-preview6 | 231 | 10/24/2023 |
1.5.0-preview5 | 668 | 10/4/2023 |
1.5.0-preview4 | 1,031 | 9/5/2023 |
1.5.0-preview3 | 334 | 9/1/2023 |
1.5.0-preview2 | 942 | 6/14/2023 |
1.5.0-preview1 | 332 | 6/2/2023 |
1.4.0 | 112,288 | 5/3/2023 |
1.4.0-preview7 | 323 | 5/2/2023 |
1.4.0-preview6 | 348 | 4/27/2023 |
1.4.0-preview5 | 815 | 4/20/2023 |
1.4.0-preview4 | 283 | 4/18/2023 |
1.4.0-preview3 | 412 | 4/17/2023 |
1.4.0-preview2 | 875 | 4/13/2023 |
1.4.0-preview1 | 538 | 4/5/2023 |
1.3.0 | 11,292 | 3/29/2023 |
1.3.0-preview4 | 496 | 3/22/2023 |
1.3.0-preview3 | 424 | 3/21/2023 |
1.3.0-preview2 | 885 | 2/28/2023 |
1.3.0-preview1 | 385 | 2/1/2023 |
1.2.0 | 26,701 | 1/20/2023 |
1.2.0-preview9 | 2,290 | 12/15/2022 |
1.2.0-preview8 | 1,026 | 11/17/2022 |
1.2.0-preview7 | 461 | 11/8/2022 |
1.2.0-preview6 | 955 | 11/1/2022 |
1.2.0-preview5 | 505 | 10/24/2022 |
1.2.0-preview4 | 733 | 10/6/2022 |
1.2.0-preview3 | 352 | 10/3/2022 |
1.2.0-preview2 | 376 | 9/28/2022 |
1.2.0-preview1 | 342 | 9/28/2022 |
1.1.0 | 55,582 | 9/14/2022 |
1.0.11 | 31,969 | 7/18/2022 |
1.0.11-preview5 | 652 | 7/8/2022 |
1.0.11-preview4 | 553 | 7/6/2022 |
1.0.11-preview3 | 1,162 | 6/22/2022 |
1.0.11-preview2 | 769 | 6/6/2022 |
1.0.11-preview1 | 398 | 5/30/2022 |
1.0.10 | 18,610 | 5/10/2022 |
1.0.10-preview3 | 1,260 | 3/29/2022 |
1.0.10-preview2 | 1,155 | 3/3/2022 |
1.0.10-preview1 | 591 | 2/25/2022 |
1.0.9 | 72,440 | 10/7/2021 |
1.0.8 | 82,618 | 5/6/2021 |
1.0.7 | 16,314 | 4/13/2021 |
1.0.6 | 25,255 | 2/11/2021 |
1.0.5 | 1,180 | 2/6/2021 |
1.0.4 | 50,882 | 7/21/2020 |
1.0.2 | 7,673 | 5/25/2020 |
1.0.1 | 41,487 | 10/10/2019 |
1.0.0 | 2,166 | 9/25/2019 |
1.0.0-beta9 | 14,842 | 8/13/2019 |
1.0.0-beta8 | 2,914 | 8/6/2019 |
1.0.0-beta7 | 5,583 | 9/24/2018 |
1.0.0-beta6 | 1,039 | 9/19/2018 |
1.0.0-beta5 | 986 | 9/7/2018 |
1.0.0-beta4 | 1,348 | 5/30/2018 |
- Adds support for configuring composable functions generations #551