Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Generates OpenAPI document from OData CSDL

License

NotificationsYou must be signed in to change notification settings

microsoft/OpenAPI.NET.OData

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

nuget

Convert OData to OpenAPI.NET

Introduction

TheMicrosoft.OpenAPI.OData.Reader library helps represent an OData service metadata as an OpenApi description. It convertsODataCSDL, the XML representation of the Entity Data Model (EDM) describing an OData service intoOpen API based onOpenAPI.NET object model.

The conversion is based on the mapping doc fromOASIS 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 anOpenAPI.NET document object.

Convert OData CSDL to OpenAPI

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

Sample code

The following sample code illustrates the use of the library

publicstaticvoidGenerateOpenApiDescription(){IEdmModelmodel=GetEdmModel();OpenApiDocumentdocument=model.ConvertToOpenApi();varoutputJSON=document.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);varoutputYAML=document.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);}publicstaticIEdmModelGetEdmModel(){// load EDM model here...}

Or with the convert settings:

publicstaticvoidGenerateOpenApiDescription(){IEdmModelmodel=GetEdmModel();OpenApiConvertSettingssettings=newOpenApiConvertSettings{// configuration};OpenApiDocumentdocument=model.ConvertToOpenApi(settings);varoutputJSON=document.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);varoutputYAML=document.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);}publicstaticIEdmModelGetEdmModel(){// load EDM model here...}

TheGetEdmModel() method can load a model in 3 ways:

  1. Create the Edm model from scratch. For details referbuilding 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.

    publicstaticIEdmModelGetEdmModel(){stringcsdlFilePath=@"c:\csdl.xml";stringcsdl=System.IO.File.ReadAllText(csdlFilePath);IEdmModelmodel=CsdlReader.Parse(XElement.Parse(csdl).CreateReader());returnmodel;}
  3. Create the Edm model using Web API OData model builder. For details refer to theweb 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 aContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant usthe rights to use your contribution. For details, visithttps://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to providea CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructionsprovided 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 thislink.

This project has adopted theMicrosoft Open Source Code of Conduct.For more information see theCode of Conduct FAQ orcontactopencode@microsoft.com with any additional questions or comments.

About

Generates OpenAPI document from OData CSDL

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors31

Languages


[8]ページ先頭

©2009-2025 Movatter.jp