From c5889760b9ef8a46e3a54f98e22f4ca55babb709 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Jun 2023 21:56:50 +0000 Subject: [PATCH 01/13] Bump docker/build-push-action from 4.1.0 to 4.1.1 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4b1bdc116..6b7b81454 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,13 +30,13 @@ jobs: id: getversion - name: Push to GitHub Packages - Nightly if: ${{ github.ref == 'refs/heads/vnext' }} - uses: docker/build-push-action@v4.1.0 + uses: docker/build-push-action@v4.1.1 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly - name: Push to GitHub Packages - Release if: ${{ github.ref == 'refs/heads/master' }} - uses: docker/build-push-action@v4.1.0 + uses: docker/build-push-action@v4.1.1 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }} From 619552b97b0897cc28579ae3c33cd8f40dd49ec6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Jun 2023 21:57:10 +0000 Subject: [PATCH 02/13] Bump Verify.Xunit from 20.3.2 to 20.4.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 20.3.2 to 20.4.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/20.3.2...20.4.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index b46619c0d..ba03f290f 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -28,7 +28,7 @@ - + all From 4e17d060862ecb31279240e02c5035cd8684c62f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Jun 2023 21:57:33 +0000 Subject: [PATCH 03/13] Bump Microsoft.Windows.Compatibility from 7.0.3 to 7.0.4 Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/runtime) from 7.0.3 to 7.0.4. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v7.0.3...v7.0.4) --- updated-dependencies: - dependency-name: Microsoft.Windows.Compatibility dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Workbench.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index d15de65eb..1e0f12603 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -10,7 +10,7 @@ all - + From 4093310eae4d9ae682377de0cf121b5c7087c7ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Jun 2023 21:57:06 +0000 Subject: [PATCH 04/13] Bump Microsoft.OData.Edm from 7.16.0 to 7.17.0 Bumps Microsoft.OData.Edm from 7.16.0 to 7.17.0. --- updated-dependencies: - dependency-name: Microsoft.OData.Edm dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 004aa48cd..3a5ff6880 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -43,7 +43,7 @@ - + From a89ab95ddd11d7aa7ac887f2103c24f56b2cdb99 Mon Sep 17 00:00:00 2001 From: Mike Kistler Date: Mon, 26 Jun 2023 20:30:15 -0500 Subject: [PATCH 05/13] Fix hardcoded non-portable path separators --- .../Microsoft.OpenApi.Workbench.csproj | 1 + .../Services/OpenApiFilterServiceTests.cs | 8 ++--- .../Services/OpenApiServiceTests.cs | 33 ++++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 1e0f12603..70c120ca0 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -5,6 +5,7 @@ false true true + true diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index 3733ad848..3c039b9aa 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -51,7 +51,7 @@ public void ReturnFilteredOpenApiDocumentBasedOnOperationIdsAndTags(string opera public void ReturnFilteredOpenApiDocumentBasedOnPostmanCollection() { // Arrange - var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver2.json"); + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver2.json"); var fileInput = new FileInfo(filePath); var stream = fileInput.OpenRead(); @@ -107,7 +107,7 @@ public void TestPredicateFiltersUsingRelativeRequestUrls() public void ShouldParseNestedPostmanCollection() { // Arrange - var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver3.json"); + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver3.json"); var fileInput = new FileInfo(filePath); var stream = fileInput.OpenRead(); @@ -124,7 +124,7 @@ public void ShouldParseNestedPostmanCollection() public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument() { // Arrange - var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver1.json"); + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver1.json"); var fileInput = new FileInfo(filePath); var stream = fileInput.OpenRead(); @@ -141,7 +141,7 @@ public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument() public void ContinueProcessingWhenUrlsInCollectionAreMissingFromSourceDocument() { // Arrange - var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver4.json"); + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver4.json"); var fileInput = new FileInfo(filePath); var stream = fileInput.OpenRead(); diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index c092da510..49f1bbd96 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -30,7 +30,7 @@ public OpenApiServiceTests() public async Task ReturnConvertedCSDLFile() { // Arrange - var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml"); + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "Todo.xml"); var fileInput = new FileInfo(filePath); var csdlStream = fileInput.OpenRead(); // Act @@ -50,7 +50,7 @@ public async Task ReturnConvertedCSDLFile() public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocument(string operationIds, string tags, int expectedPathCount) { // Arrange - var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml"); + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "Todo.xml"); var fileInput = new FileInfo(filePath); var csdlStream = fileInput.OpenRead(); @@ -137,7 +137,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram() // create a dummy ILogger instance for testing var options = new HidiOptions() { - OpenApi = "UtilityFiles\\SampleOpenApi.yml", + OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"), Output = new FileInfo("sample.md") }; @@ -152,7 +152,7 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagram() { var options = new HidiOptions() { - OpenApi = "UtilityFiles\\SampleOpenApi.yml" + OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml") }; var filePath = await OpenApiService.ShowOpenApiDocument(options, _logger, new CancellationToken()); Assert.True(File.Exists(filePath)); @@ -163,7 +163,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiag { var options = new HidiOptions() { - Csdl = "UtilityFiles\\Todo.xml", + Csdl = Path.Combine("UtilityFiles", "Todo.xml"), CsdlFilter = "todos", Output = new FileInfo("sample.md") }; @@ -201,7 +201,7 @@ await Assert.ThrowsAsync(async () => public async Task ValidateCommandProcessesOpenApi() { // create a dummy ILogger instance for testing - await OpenApiService.ValidateOpenApiDocument("UtilityFiles\\SampleOpenApi.yml", _logger, new CancellationToken()); + await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger, new CancellationToken()); Assert.True(true); } @@ -212,7 +212,7 @@ public async Task TransformCommandConvertsOpenApi() { HidiOptions options = new HidiOptions { - OpenApi = "UtilityFiles\\SampleOpenApi.yml", + OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"), Output = new FileInfo("sample.json"), CleanOutput = true, TerseOutput = false, @@ -232,7 +232,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputname() { HidiOptions options = new HidiOptions { - OpenApi = "UtilityFiles\\SampleOpenApi.yml", + OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"), CleanOutput = true, TerseOutput = false, InlineLocal = false, @@ -250,7 +250,7 @@ public async Task TransformCommandConvertsCsdlWithDefaultOutputname() { HidiOptions options = new HidiOptions { - Csdl = "UtilityFiles\\Todo.xml", + Csdl = Path.Combine("UtilityFiles", "Todo.xml"), CleanOutput = true, TerseOutput = false, InlineLocal = false, @@ -268,7 +268,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputnameAndSwitchF { HidiOptions options = new HidiOptions { - OpenApi = "UtilityFiles\\SampleOpenApi.yml", + OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"), CleanOutput = true, Version = "3.0", OpenApiFormat = OpenApiFormat.Yaml, @@ -301,10 +301,10 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task TransformToPowerShellCompliantOpenApi() { - var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\examplepowershellsettings.json"); + var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "examplepowershellsettings.json"); HidiOptions options = new HidiOptions { - OpenApi = "UtilityFiles\\SampleOpenApi.yml", + OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"), CleanOutput = true, Version = "3.0", OpenApiFormat = OpenApiFormat.Yaml, @@ -324,7 +324,8 @@ public async Task TransformToPowerShellCompliantOpenApi() public void InvokeTransformCommand() { var rootCommand = Program.CreateRootCommand(); - var args = new string[] { "transform", "-d", ".\\UtilityFiles\\SampleOpenApi.yml", "-o", "sample.json", "--co" }; + var openapi = Path.Combine(".", "UtilityFiles", "SampleOpenApi.yml"); + var args = new string[] { "transform", "-d", openapi, "-o", "sample.json", "--co" }; var parseResult = rootCommand.Parse(args); var handler = rootCommand.Subcommands.Where(c => c.Name == "transform").First().Handler; var context = new InvocationContext(parseResult); @@ -340,7 +341,8 @@ public void InvokeTransformCommand() public void InvokeShowCommand() { var rootCommand = Program.CreateRootCommand(); - var args = new string[] { "show", "-d", ".\\UtilityFiles\\SampleOpenApi.yml", "-o", "sample.md" }; + var openapi = Path.Combine(".", "UtilityFiles", "SampleOpenApi.yml"); + var args = new string[] { "show", "-d", openapi, "-o", "sample.md" }; var parseResult = rootCommand.Parse(args); var handler = rootCommand.Subcommands.Where(c => c.Name == "show").First().Handler; var context = new InvocationContext(parseResult); @@ -355,7 +357,8 @@ public void InvokeShowCommand() public void InvokePluginCommand() { var rootCommand = Program.CreateRootCommand(); - var args = new string[] { "plugin", "-m", ".\\UtilityFiles\\exampleapimanifest.json", "--of", AppDomain.CurrentDomain.BaseDirectory }; + var manifest = Path.Combine(".", "UtilityFiles", "exampleapimanifest.json"); + var args = new string[] { "plugin", "-m", manifest, "--of", AppDomain.CurrentDomain.BaseDirectory }; var parseResult = rootCommand.Parse(args); var handler = rootCommand.Subcommands.Where(c => c.Name == "plugin").First().Handler; var context = new InvocationContext(parseResult); From 9276848b006bb033b985f357e841fe40050b8156 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Jun 2023 21:57:18 +0000 Subject: [PATCH 06/13] Bump Microsoft.NET.Test.Sdk from 17.6.2 to 17.6.3 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.6.2 to 17.6.3. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.6.2...v17.6.3) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 4 ++-- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.SmokeTests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index 87fade6cd..deae3d05b 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -1,4 +1,4 @@ - + net7.0 @@ -13,7 +13,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index 97ae2f019..559475304 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -268,7 +268,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 83cf2fc86..b18fe3f93 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -16,7 +16,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index ba03f290f..5f186f4ed 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -24,7 +24,7 @@ all - + From 0560a4a3d3165c7521ac253c1228a752308c1891 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Jul 2023 21:18:02 +0000 Subject: [PATCH 07/13] Bump xunit from 2.4.2 to 2.5.0 Bumps [xunit](https://github.com/xunit/xunit) from 2.4.2 to 2.5.0. - [Commits](https://github.com/xunit/xunit/compare/2.4.2...2.5.0) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.SmokeTests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index deae3d05b..c65467a92 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -15,7 +15,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index 559475304..18c795323 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -275,7 +275,7 @@ - + all diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index b18fe3f93..5366ac4d6 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -18,7 +18,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 5f186f4ed..9059b1f03 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -29,7 +29,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 5eba55841b4c375bbcf51a7830e94e84176c6075 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 8 Jul 2023 01:17:00 +0000 Subject: [PATCH 08/13] Bump xunit.runner.visualstudio from 2.4.5 to 2.5.0 Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.4.5 to 2.5.0. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/compare/v2.4.5...2.5.0) --- updated-dependencies: - dependency-name: xunit.runner.visualstudio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.SmokeTests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index c65467a92..baeed8767 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -16,7 +16,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index 18c795323..458e8e627 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -277,7 +277,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 5366ac4d6..10ce38c55 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -19,7 +19,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 9059b1f03..1856cc254 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -30,7 +30,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From b5c03a2cb55961bfb847e48f77af6b72067feca3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jul 2023 21:13:35 +0000 Subject: [PATCH 09/13] Bump Verify.Xunit from 20.4.0 to 20.5.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 20.4.0 to 20.5.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/20.4.0...20.5.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 1856cc254..1967e01ed 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -28,7 +28,7 @@ - + all From dd7f72bcf5d9510029ca986a198c97eaed509d02 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jul 2023 21:29:57 +0000 Subject: [PATCH 10/13] Bump Verify.Xunit from 20.5.0 to 20.5.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 20.5.0 to 20.5.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/20.5.0...20.5.1) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 1967e01ed..02614f5f2 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -28,7 +28,7 @@ - + all From da0fd1c46ed1d3fe6eeee1839fbfa7481de8b684 Mon Sep 17 00:00:00 2001 From: Tina Liu Date: Tue, 18 Jul 2023 21:30:32 +0800 Subject: [PATCH 11/13] parse server's url with variables when convert openapi 3.0 to 2.0 --- .../Models/OpenApiDocument.cs | 21 +- ...orks_produceTerseOutput=False.verified.txt | 417 ++++++++++++++++++ ...Works_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiDocumentTests.cs | 316 +++++++++++++ 4 files changed, 752 insertions(+), 3 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=True.verified.txt diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index c172d84c7..fcffa471b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -290,6 +290,21 @@ public void SerializeAsV2(IOpenApiWriter writer) writer.WriteEndObject(); } + private static string ParseServerUrl(OpenApiServer server) + { + var parsedUrl = server.Url; + + var variables = server.Variables; + foreach (var variable in variables) + { + if (!string.IsNullOrEmpty(variable.Value.Default)) + { + parsedUrl = parsedUrl.Replace($"{{{variable.Key}}}", variable.Value.Default); + } + } + return parsedUrl; + } + private static void WriteHostInfoV2(IOpenApiWriter writer, IList servers) { if (servers == null || !servers.Any()) @@ -299,11 +314,11 @@ private static void WriteHostInfoV2(IOpenApiWriter writer, IList // Arbitrarily choose the first server given that V2 only allows // one host, port, and base path. - var firstServer = servers.First(); + var serverUrl = ParseServerUrl(servers.First()); // Divide the URL in the Url property into host and basePath required in OpenAPI V2 // The Url property cannotcontain path templating to be valid for V2 serialization. - var firstServerUrl = new Uri(firstServer.Url, UriKind.RelativeOrAbsolute); + var firstServerUrl = new Uri(serverUrl, UriKind.RelativeOrAbsolute); // host if (firstServerUrl.IsAbsoluteUri) @@ -337,7 +352,7 @@ private static void WriteHostInfoV2(IOpenApiWriter writer, IList var schemes = servers.Select( s => { - Uri.TryCreate(s.Url, UriKind.RelativeOrAbsolute, out var url); + Uri.TryCreate(ParseServerUrl(s), UriKind.RelativeOrAbsolute, out var url); return url; }) .Where( diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..1656b2bf7 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,417 @@ +{ + "swagger": "2.0", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "host": "your-resource-name.openai.azure.com", + "basePath": "/openai", + "schemes": [ + "https" + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "query", + "name": "tags", + "description": "tags to filter by", + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" + }, + { + "in": "query", + "name": "limit", + "description": "maximum number of results to return", + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json", + "text/html" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Pet to add to the store", + "required": true, + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to fetch", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "produces": [ + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to delete", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "definitions": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..3670fba11 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"your-resource-name.openai.azure.com","basePath":"/openai","schemes":["https"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 6e3200957..924699bdf 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -981,6 +981,305 @@ public class OpenApiDocumentTests } }; + public OpenApiDocument AdvancedDocumentWithServerVariable = new OpenApiDocument + { + Info = new OpenApiInfo + { + Version = "1.0.0", + Title = "Swagger Petstore (Simple)", + Description = + "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + TermsOfService = new Uri("http://helloreverb.com/terms/"), + Contact = new OpenApiContact + { + Name = "Swagger API team", + Email = "foo@example.com", + Url = new Uri("http://swagger.io") + }, + License = new OpenApiLicense + { + Name = "MIT", + Url = new Uri("http://opensource.org/licenses/MIT") + } + }, + Servers = new List + { + new OpenApiServer + { + Url = "https://{endpoint}/openai", + Variables = new Dictionary + { + ["endpoint"] = new OpenApiServerVariable + { + Default = "your-resource-name.openai.azure.com" + } + } + } + }, + Paths = new OpenApiPaths + { + ["/pets"] = new OpenApiPathItem + { + Operations = new Dictionary + { + [OperationType.Get] = new OpenApiOperation + { + Description = "Returns all pets from the system that the user has access to", + OperationId = "findPets", + Parameters = new List + { + new OpenApiParameter + { + Name = "tags", + In = ParameterLocation.Query, + Description = "tags to filter by", + Required = false, + Schema = new OpenApiSchema + { + Type = "array", + Items = new OpenApiSchema + { + Type = "string" + } + } + }, + new OpenApiParameter + { + Name = "limit", + In = ParameterLocation.Query, + Description = "maximum number of results to return", + Required = false, + Schema = new OpenApiSchema + { + Type = "integer", + Format = "int32" + } + } + }, + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse + { + Description = "pet response", + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = "array", + Items = PetSchema + } + }, + ["application/xml"] = new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = "array", + Items = PetSchema + } + } + } + }, + ["4XX"] = new OpenApiResponse + { + Description = "unexpected client error", + Content = new Dictionary + { + ["text/html"] = new OpenApiMediaType + { + Schema = ErrorModelSchema + } + } + }, + ["5XX"] = new OpenApiResponse + { + Description = "unexpected server error", + Content = new Dictionary + { + ["text/html"] = new OpenApiMediaType + { + Schema = ErrorModelSchema + } + } + } + } + }, + [OperationType.Post] = new OpenApiOperation + { + Description = "Creates a new pet in the store. Duplicates are allowed", + OperationId = "addPet", + RequestBody = new OpenApiRequestBody + { + Description = "Pet to add to the store", + Required = true, + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Schema = NewPetSchema + } + } + }, + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse + { + Description = "pet response", + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Schema = PetSchema + }, + } + }, + ["4XX"] = new OpenApiResponse + { + Description = "unexpected client error", + Content = new Dictionary + { + ["text/html"] = new OpenApiMediaType + { + Schema = ErrorModelSchema + } + } + }, + ["5XX"] = new OpenApiResponse + { + Description = "unexpected server error", + Content = new Dictionary + { + ["text/html"] = new OpenApiMediaType + { + Schema = ErrorModelSchema + } + } + } + } + } + } + }, + ["/pets/{id}"] = new OpenApiPathItem + { + Operations = new Dictionary + { + [OperationType.Get] = new OpenApiOperation + { + Description = + "Returns a user based on a single ID, if the user does not have access to the pet", + OperationId = "findPetById", + Parameters = new List + { + new OpenApiParameter + { + Name = "id", + In = ParameterLocation.Path, + Description = "ID of pet to fetch", + Required = true, + Schema = new OpenApiSchema + { + Type = "integer", + Format = "int64" + } + } + }, + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse + { + Description = "pet response", + Content = new Dictionary + { + ["application/json"] = new OpenApiMediaType + { + Schema = PetSchema + }, + ["application/xml"] = new OpenApiMediaType + { + Schema = PetSchema + } + } + }, + ["4XX"] = new OpenApiResponse + { + Description = "unexpected client error", + Content = new Dictionary + { + ["text/html"] = new OpenApiMediaType + { + Schema = ErrorModelSchema + } + } + }, + ["5XX"] = new OpenApiResponse + { + Description = "unexpected server error", + Content = new Dictionary + { + ["text/html"] = new OpenApiMediaType + { + Schema = ErrorModelSchema + } + } + } + } + }, + [OperationType.Delete] = new OpenApiOperation + { + Description = "deletes a single pet based on the ID supplied", + OperationId = "deletePet", + Parameters = new List + { + new OpenApiParameter + { + Name = "id", + In = ParameterLocation.Path, + Description = "ID of pet to delete", + Required = true, + Schema = new OpenApiSchema + { + Type = "integer", + Format = "int64" + } + } + }, + Responses = new OpenApiResponses + { + ["204"] = new OpenApiResponse + { + Description = "pet deleted" + }, + ["4XX"] = new OpenApiResponse + { + Description = "unexpected client error", + Content = new Dictionary + { + ["text/html"] = new OpenApiMediaType + { + Schema = ErrorModelSchema + } + } + }, + ["5XX"] = new OpenApiResponse + { + Description = "unexpected server error", + Content = new Dictionary + { + ["text/html"] = new OpenApiMediaType + { + Schema = ErrorModelSchema + } + } + } + } + } + } + } + }, + Components = AdvancedComponents + }; + private readonly ITestOutputHelper _output; public OpenApiDocumentTests(ITestOutputHelper output) @@ -1022,6 +1321,23 @@ public async Task SerializeAdvancedDocumentWithReferenceAsV3JsonWorks(bool produ await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks(bool produceTerseOutput) + { + // Arrange + var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); + + // Act + AdvancedDocumentWithServerVariable.SerializeAsV2(writer); + writer.Flush(); + + // Assert + await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput); + } + [Theory] [InlineData(true)] [InlineData(false)] From bd12c69a42aa5569d21efbbdfc208ee1cd35e7de Mon Sep 17 00:00:00 2001 From: TinaLiu <134926504+TinaLiu02@users.noreply.github.com> Date: Wed, 19 Jul 2023 09:03:52 +0800 Subject: [PATCH 12/13] Update src/Microsoft.OpenApi/Models/OpenApiDocument.cs Co-authored-by: Vincent Biret --- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index fcffa471b..d2d9cf893 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -295,12 +295,9 @@ private static string ParseServerUrl(OpenApiServer server) var parsedUrl = server.Url; var variables = server.Variables; - foreach (var variable in variables) + foreach (var variable in variables.Where(static x => !string.IsNullOrEmpty(x.Value.Default))) { - if (!string.IsNullOrEmpty(variable.Value.Default)) - { - parsedUrl = parsedUrl.Replace($"{{{variable.Key}}}", variable.Value.Default); - } + parsedUrl = parsedUrl.Replace($"{{{variable.Key}}}", variable.Value.Default); } return parsedUrl; } From 637ac1d78c73a788bfb3ab82924b4eee60905b1d Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 21 Jul 2023 09:53:04 +0200 Subject: [PATCH 13/13] Bump lib versions --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 3a5ff6880..d595f961b 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -15,7 +15,7 @@ Microsoft.OpenApi.Hidi hidi ./../../artifacts - 1.2.5 + 1.2.6 OpenAPI.NET CLI tool for slicing OpenAPI documents © Microsoft Corporation. All rights reserved. OpenAPI .NET diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 81c08752d..ba2cf568d 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -10,7 +10,7 @@ Microsoft Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers - 1.6.5 + 1.6.6 OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. OpenAPI .NET diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 084742af2..d727c4627 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -11,7 +11,7 @@ Microsoft Microsoft.OpenApi Microsoft.OpenApi - 1.6.5 + 1.6.6 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET