Go to file
2018-09-24 14:31:53 -07:00
docs add the response example for operation and remove unused the json/yaml files 2018-09-21 12:39:58 -07:00
src Modify the ODataPathProvider 2018-09-24 11:05:55 -07:00
test Modify the ODataPathProvider 2018-09-24 11:05:55 -07:00
tool Move the update docs to tool subfolder 2018-09-24 14:31:53 -07:00
.gitignore Initial commit 2017-10-19 09:39:14 -07:00
build.cmd modify the output, add the build script and skip strong name 2017-12-20 16:15:17 -08:00
build.ps1 modify the output, add the build script and skip strong name 2017-12-20 16:15:17 -08:00
LICENSE Initial commit 2017-10-19 09:39:17 -07:00
Microsoft.OpenApi.OData.sln Move the update docs to tool subfolder 2018-09-24 14:31:53 -07:00
README.md Update README.md 2018-09-19 12:19:41 -07:00

VSTS Build Status
Rolling
Nightly

Convert OData to OpenAPI.NET [Preview]

[Be noted:This repository is in a preview state. Feedback and contribution is welcome!]

Introduction

The Microsoft.OpenAPI.OData.Reader SDK contains APIs to convert OData CSDL, the XML represetntation of the Entity Data Model (EDM) to Open API based on OpenAPI.NET object model.

The converting is based on the mapping doc from OASIS OData OpenAPI v1.0 and the following contents:

  1. Capabilites annotation
  2. Authorization annotation
  3. HttpRequest annotation
  4. Navigation property path
  5. Edm operation and operation import path
  6. Others

Overview

In general, the below image describes the general concept of how this SDK can convert the EDM model to an OpenAPI.NET document object.

Convert OData CSDL to OpenAPI

For detail information about the CSDL and Entity Data model, please refer to http://www.odata.org/documentation. For detail information about the Open API object of model, please refer to http://github.com/microsoft/OpenAPI.NET

Simple Example Code

Here's a simple example codes illustrating how to use the APIs in this SDK

IEdmModel model = GetEdmModel();
OpenApiDocument document = model.ConvertToOpenApi();

Or with the convert settings:

IEdmModel model = GetEdmModel();
OpenApiConvertSettings settings = new OpenApiConvertSettings
{
   // configuration
};
OpenApiDocument document = model.ConvertToOpenApi(settings);

Where, GetEdmModel() is a method to return the IEdmModel object. You can:

  1. Create the Edm model from scratch, see detail here
  2. Load the Edm model from CSDL file, see sample codes below
string csdlFile = @"c:\csdl.xml";
string csdl = System.IO.File.ReadAllText(csdlFile);
IEdmModel model = CsdlReader.Parse(XElement.Parse(csdl).CreateReader());
  1. Create the Edm model using Web API OData model builder, see detail here

Nightly builds

The nightly build process will upload a Nuget package for OpenAPI.OData.reader to OpenAPIOData MyGet gallery.

To connect to OpenAPI.OData.reader feed, use this URL source.

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.

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.