-
Notifications
You must be signed in to change notification settings - Fork 279
Convert csdl files to openapi #705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
fdbee8f
Update input parameter description
MaggieKimani1 7f88a35
Add OData conversion libraries
MaggieKimani1 e0f0ed6
Add necessary usings
MaggieKimani1 c2ae2dd
Add method for CSDL to OpenAPI conversion
MaggieKimani1 07169a4
Check input file for .xml extension
MaggieKimani1 f23b0a9
Merge remote-tracking branch 'origin/vnext' into mk/feature/convert-c…
MaggieKimani1 581023c
Clean up code
MaggieKimani1 7606916
Refactor code
MaggieKimani1 cb8ef3a
Add check for .csdl files
MaggieKimani1 73339e1
Add a sample csdl file for testing and copy to output directory
MaggieKimani1 7ec682b
Add csdl conversion tests
MaggieKimani1 b13c3ad
Add xml documentation
MaggieKimani1 695eb05
Merge branch 'mk/align-hidi-params-with-kiota' into mk/feature/conver…
MaggieKimani1 66c06b6
Add --csdl input param for converting csdl files
MaggieKimani1 1b40298
Refactor code
MaggieKimani1 ef7640f
Rename test file
MaggieKimani1 51e85a7
Refactor param to be more implicit
MaggieKimani1 761088f
Merge branch 'vnext' into mk/feature/convert-csdl-to-openapi
MaggieKimani1 1d986d1
Resolve merge conflicts
MaggieKimani1 5550f01
Clean up code
MaggieKimani1 b8d0d2b
Default to V3 of OpenApi during document serialization
MaggieKimani1 385e5af
Clean up
MaggieKimani1 53c4e2c
Update package version
MaggieKimani1 528cee2
Merge remote-tracking branch 'origin/vnext' into mk/feature/convert-c…
MaggieKimani1 36a11bb
Add package icon and description
MaggieKimani1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. | ||
|
|
||
| using System; | ||
| using System.IO; | ||
| using Microsoft.OpenApi.Hidi; | ||
| using Microsoft.OpenApi.Services; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.OpenApi.Tests.Services | ||
| { | ||
| public class OpenApiServiceTests | ||
| { | ||
| [Fact] | ||
| public void ReturnConvertedCSDLFile() | ||
| { | ||
| // Arrange | ||
| var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml"); | ||
| var fileInput = new FileInfo(filePath); | ||
| var csdlStream = fileInput.OpenRead(); | ||
|
|
||
| // Act | ||
| var openApiDoc = OpenApiService.ConvertCsdlToOpenApi(csdlStream); | ||
| var expectedPathCount = 5; | ||
|
|
||
| // Assert | ||
| Assert.NotNull(openApiDoc); | ||
| Assert.NotEmpty(openApiDoc.Paths); | ||
| Assert.Equal(openApiDoc.Paths.Count, expectedPathCount); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData("Todos.Todo.UpdateTodo",null, 1)] | ||
| [InlineData("Todos.Todo.ListTodo",null, 1)] | ||
| [InlineData(null, "Todos.Todo", 4)] | ||
| public void ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocument(string operationIds, string tags, int expectedPathCount) | ||
| { | ||
| // Arrange | ||
| var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml"); | ||
| var fileInput = new FileInfo(filePath); | ||
| var csdlStream = fileInput.OpenRead(); | ||
|
|
||
| // Act | ||
| var openApiDoc = OpenApiService.ConvertCsdlToOpenApi(csdlStream); | ||
| var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags); | ||
| var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(openApiDoc, predicate); | ||
|
|
||
| // Assert | ||
| Assert.NotNull(subsetOpenApiDocument); | ||
| Assert.NotEmpty(subsetOpenApiDocument.Paths); | ||
| Assert.Equal(expectedPathCount, subsetOpenApiDocument.Paths.Count); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0"> | ||
| <edmx:DataServices> | ||
| <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="microsoft.graph" > | ||
|
|
||
| <EntityContainer Name="TodoService"> | ||
| <EntitySet Name="Todos" EntityType="microsoft.graph.Todo"> | ||
| </EntitySet> | ||
| </EntityContainer> | ||
|
|
||
| <EntityType Name="Todo" HasStream="true"> | ||
| <Key> | ||
| <PropertyRef Name="Id"/> | ||
| </Key> | ||
| <Property Name="Id" Type="Edm.String"/> | ||
| <Property Name="Logo" Type="Edm.Stream"/> | ||
| <Property Name="Description" Type="Edm.String"/> | ||
| </EntityType> | ||
|
|
||
| </Schema> | ||
| </edmx:DataServices> | ||
| </edmx:Edmx> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.