openapiodata - Microsoft.OpenApi.OData 1.0.9-Nightly202202110009

This package contains the codes you need to convert OData CSDL to Open API Document of Model.

PM> Install-Package Microsoft.OpenApi.OData -Version 1.0.9-Nightly202202110009 -Source https://www.myget.org/F/openapiodata/api/v3/index.json

Copy to clipboard

> nuget.exe install Microsoft.OpenApi.OData -Version 1.0.9-Nightly202202110009 -Source https://www.myget.org/F/openapiodata/api/v3/index.json

Copy to clipboard

> dotnet add package Microsoft.OpenApi.OData --version 1.0.9-Nightly202202110009 --source https://www.myget.org/F/openapiodata/api/v3/index.json

Copy to clipboard
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.9-Nightly202202110009" />
Copy to clipboard
source https://www.myget.org/F/openapiodata/api/v3/index.json

nuget Microsoft.OpenApi.OData  ~> 1.0.9-Nightly202202110009
Copy to clipboard

> choco install Microsoft.OpenApi.OData --version 1.0.9-Nightly202202110009 --source https://www.myget.org/F/openapiodata/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "openapiodata" -SourceLocation "https://www.myget.org/F/openapiodata/api/v2"
Install-Module -Name "Microsoft.OpenApi.OData" -RequiredVersion "1.0.9-Nightly202202110009" -Repository "openapiodata" -AllowPreRelease
Copy to clipboard

nuget

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 :

  1. Capabilities vocabulary annotation
  2. Authorization vocabulary annotation
  3. Core vocabulary annotation
  4. Navigation property path
  5. 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.

Convert OData CSDL to OpenAPI

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:

  1. Create the Edm model from scratch. For details refer building a basic model

  2. 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;
    }
    
  3. 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.

  • Any 0.0
    • Microsoft.OData.Edm (>= 7.10.0 && < 8.0.0)
    • Microsoft.OpenApi (>= 1.2.3 && < 2.0.0)
  • .NETFramework 4.7.2: 4.7.2.0
  • .NETStandard 2.0: 2.0.0.0

Signature validation information

Informational

Signature Hash Algorithm: SHA256

Timestamp: 2/11/2022 12:10:07 AM

Verifying author primary signature's timestamp with timestamping service certificate: 
  Subject Name: CN=Symantec SHA256 TimeStamping Signer - G3, OU=Symantec Trust Network, O=Symantec Corporation, C=US
  SHA1 hash: A9A4121063D71D48E8529A4681DE803E3E7954B0
  SHA256 hash: C474CE76007D02394E0DA5E4DE7C14C680F9E282013CFEF653EF5DB71FDF61F8
  Issued by: CN=Symantec SHA256 TimeStamping CA, OU=Symantec Trust Network, O=Symantec Corporation, C=US
  Valid from: 12/23/2017 12:00:00 AM to 3/22/2029 11:59:59 PM

Signature type: Author

Verifying the author primary signature with certificate: 
  Subject Name: CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
  SHA1 hash: A6E18D21B507879FC7F9C392A5CE355936E3AD2C
  SHA256 hash: AA12DA22A49BCE7D5C1AE64CC1F3D892F150DA76140F210ABD2CBFFCA2C18A27
  Issued by: CN=DigiCert SHA2 Assured ID Code Signing CA, OU=www.digicert.com, O=DigiCert Inc, C=US
  Valid from: 9/30/2020 12:00:00 AM to 10/5/2023 12:00:00 PM

Owners

OData Team

Authors

Microsoft

Project URL

http://github.com/Microsoft/OpenApi.Net.OData

License

MS-EULA

Tags

Microsoft OpenApi OData EDM

Signature

Validation: Valid

Info

21 total downloads
8 downloads for version 1.0.9-Nightly202202110009
Download (232.04 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.0.9-Nightly202202110009 232.04 KB Fri, 11 Feb 2022 00:12:13 GMT 8
1.0.9-Nightly202202100010 231.95 KB Thu, 10 Feb 2022 00:12:32 GMT 0
1.0.9-Nightly202202090012 232.39 KB Wed, 09 Feb 2022 00:15:18 GMT 1
1.0.9-Nightly202202080037 230.15 KB Tue, 08 Feb 2022 00:38:30 GMT 1
1.0.9-Nightly202202070110 229 KB Mon, 07 Feb 2022 01:12:11 GMT 1
1.0.9-Nightly202202010009 228.11 KB Tue, 01 Feb 2022 00:10:47 GMT 1
1.0.9-Nightly202201200011 223.54 KB Thu, 20 Jan 2022 00:13:29 GMT 1
1.0.9-Nightly202201060008 219.35 KB Thu, 06 Jan 2022 00:10:29 GMT 3
1.0.9-Nightly202112170011 207.88 KB Fri, 17 Dec 2021 00:12:44 GMT 2
1.0.9-Nightly202112010010 198.58 KB Wed, 01 Dec 2021 00:12:38 GMT 1
1.0.0-Nightly201801121301 75.72 KB Fri, 12 Jan 2018 13:01:51 GMT 2