From 4f83e5dc670c7d28ae6c9615f0163d5bb42bd979 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 21:23:04 +0000 Subject: [PATCH 001/110] Bump github/codeql-action from 2 to 3 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/v2...v3) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 11c90f95b..d9bedc14d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -23,7 +23,7 @@ jobs: - name: Initialize CodeQL id: init_codeql - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: queries: security-and-quality @@ -43,6 +43,6 @@ jobs: - name: Perform CodeQL Analysis id: analyze_codeql - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 # Built with ❤ by [Pipeline Foundation](https://pipeline.foundation) \ No newline at end of file From 3d551de775d28871e0d20033de1ff9bef24ad062 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Dec 2023 21:27:09 +0000 Subject: [PATCH 002/110] Bump Verify.Xunit from 22.8.0 to 22.10.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 22.8.0 to 22.10.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits/22.10.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 ff5c9d1a6..061e8a2af 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 26d3781021a686b91d51ea83e1e30658b4429c96 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Dec 2023 21:57:55 +0000 Subject: [PATCH 003/110] Bump xunit.runner.visualstudio from 2.5.5 to 2.5.6 Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.5.5 to 2.5.6. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/compare/2.5.5...2.5.6) --- updated-dependencies: - dependency-name: xunit.runner.visualstudio dependency-type: direct:production update-type: version-update:semver-patch ... 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 6e0ca4ac2..9c9b03df8 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 @@ - + 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 e0f7e6b32..9a7a70d09 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -22,7 +22,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index a33119ef3..4d31a9490 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -13,7 +13,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 061e8a2af..cae371f1d 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -17,7 +17,7 @@ - + From ae5d32ce40d65f53959d5e500e7f96f757bdf7a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 21:21:59 +0000 Subject: [PATCH 004/110] Bump xunit from 2.6.3 to 2.6.4 Bumps [xunit](https://github.com/xunit/xunit) from 2.6.3 to 2.6.4. - [Commits](https://github.com/xunit/xunit/compare/2.6.3...2.6.4) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... 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 9c9b03df8..6cf6ac218 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -14,7 +14,7 @@ - + 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 9a7a70d09..180cf1d85 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -21,7 +21,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 4d31a9490..1b947425c 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -12,7 +12,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index cae371f1d..b3a8a3c21 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -16,7 +16,7 @@ - + From 09c9a74efaa47c988fafaea7fd15431717d6f1b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 21:28:18 +0000 Subject: [PATCH 005/110] Bump Verify.Xunit from 22.10.0 to 22.10.2 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 22.10.0 to 22.10.2. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/22.10.0...22.10.2) --- 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 b3a8a3c21..8d0482ed6 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 68c98bce5ed4713d0e93dbd522af4d6cdba6852a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Dec 2023 21:17:54 +0000 Subject: [PATCH 006/110] Bump Verify.Xunit from 22.10.2 to 22.11.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 22.10.2 to 22.11.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits) --- 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 8d0482ed6..46061c5a3 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 5b11414d11ea739753125f891936f3a6a563fd79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Dec 2023 21:17:08 +0000 Subject: [PATCH 007/110] Bump Verify.Xunit from 22.11.0 to 22.11.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 22.11.0 to 22.11.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits/22.11.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 46061c5a3..776119fce 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From d3eb93599bde114dfffc76fee339489b9ca85950 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jan 2024 21:41:37 +0000 Subject: [PATCH 008/110] Bump Verify.Xunit from 22.11.1 to 22.11.2 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 22.11.1 to 22.11.2. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits) --- 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 776119fce..0d4fad73a 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From ab3d84f840ea0b417a3d46810cefae2701bfd5dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jan 2024 21:13:40 +0000 Subject: [PATCH 009/110] Bump xunit from 2.6.4 to 2.6.5 Bumps [xunit](https://github.com/xunit/xunit) from 2.6.4 to 2.6.5. - [Commits](https://github.com/xunit/xunit/compare/2.6.4...2.6.5) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... 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 6cf6ac218..c5857909d 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -14,7 +14,7 @@ - + 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 180cf1d85..79a80563a 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -21,7 +21,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 1b947425c..5fe493b42 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -12,7 +12,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 0d4fad73a..cee170fbf 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -16,7 +16,7 @@ - + From fceb79d64a0e8256ca218a029abfe41c19906df1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 Jan 2024 20:55:05 +0000 Subject: [PATCH 010/110] Bump Verify.Xunit from 22.11.2 to 22.11.4 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 22.11.2 to 22.11.4. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/22.11.2...22.11.4) --- 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 cee170fbf..f8add9e9a 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From e3a5c9379a2af789fa4bea52f75f5f95d7975039 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:27:53 +0000 Subject: [PATCH 011/110] Bump Microsoft.Windows.Compatibility from 8.0.0 to 8.0.1 Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/windowsdesktop) from 8.0.0 to 8.0.1. - [Release notes](https://github.com/dotnet/windowsdesktop/releases) - [Commits](https://github.com/dotnet/windowsdesktop/compare/v8.0.0...v8.0.1) --- 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 482fea87f..e6c4dd486 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -9,7 +9,7 @@ - + From 60d26403d873d544f3c41c6e1594e09c47fb5e4d Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 10 Jan 2024 08:57:29 -0500 Subject: [PATCH 012/110] - makes exception more explicit when inserting duplicated tree nodes --- src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs index 9ad9158ea..53a79c8a4 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs @@ -175,7 +175,7 @@ private OpenApiUrlTreeNode Attach(IEnumerable segments, { if (PathItems.ContainsKey(label)) { - throw new ArgumentException("A duplicate label already exists for this node.", nameof(label)); + throw new ArgumentException($"A duplicate label already exists for this node: {label}", nameof(label)); } Path = currentPath; From f1ed2662bd35a6822e6987f78a9c64a2d1406622 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:16:16 +0000 Subject: [PATCH 013/110] Bump Verify.Xunit from 22.11.4 to 22.11.5 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 22.11.4 to 22.11.5. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/22.11.4...22.11.5) --- 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 f8add9e9a..8cbcfd872 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From e036750dc7dadc77019e3e5c59583d727f91a20a Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 18 Dec 2023 15:06:29 -0500 Subject: [PATCH 014/110] - fixes a bug where paths with multiple parameters would be considered conflicting Signed-off-by: Vincent Biret --- .../Validations/Rules/OpenApiPathsRules.cs | 2 +- .../Validations/OpenApiPathsValidationTests.cs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs index c25ca8aff..d94f7a31a 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs @@ -36,7 +36,7 @@ public static class OpenApiPathsRules } }); - private static readonly Regex regexPath = new Regex("\\{([^/]+)\\}", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100)); + private static readonly Regex regexPath = new Regex("\\{([^/}]+)\\}", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100)); /// /// A relative path to an individual endpoint. The field name MUST begin with a slash. /// diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiPathsValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiPathsValidationTests.cs index 23a0a3e0f..9d3e3bb59 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiPathsValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiPathsValidationTests.cs @@ -45,5 +45,22 @@ public void ValidatePathsAreUnique() errors.Should().NotBeEmpty(); errors.Select(e => e.Message).Should().BeEquivalentTo(error); } + [Fact] + public void ValidatePathsAreUniqueDoesNotConsiderMultiParametersAsIdentical() + { + // Arrange + var paths = new OpenApiPaths + { + {"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={height},fittingMode='{fittingMode}')",new OpenApiPathItem() }, + {"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={height})",new OpenApiPathItem() }, + {"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width})", new OpenApiPathItem() }, + }; + + // Act + var errors = paths.Validate(ValidationRuleSet.GetDefaultRuleSet()); + + // Assert + errors.Should().BeEmpty(); + } } } From 670b2595b0b8f248dc2f3befb0c60587f2e290d8 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 18 Dec 2023 15:10:36 -0500 Subject: [PATCH 015/110] - adds additional test Signed-off-by: Vincent Biret --- .../Validations/OpenApiPathsValidationTests.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiPathsValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiPathsValidationTests.cs index 9d3e3bb59..6d0282748 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiPathsValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiPathsValidationTests.cs @@ -62,5 +62,21 @@ public void ValidatePathsAreUniqueDoesNotConsiderMultiParametersAsIdentical() // Assert errors.Should().BeEmpty(); } + [Fact] + public void ValidatePathsAreUniqueConsidersMultiParametersAsIdentical() + { + // Arrange + var paths = new OpenApiPaths + { + {"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={height})",new OpenApiPathItem() }, + {"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={size})",new OpenApiPathItem() }, + }; + + // Act + var errors = paths.Validate(ValidationRuleSet.GetDefaultRuleSet()); + + // Assert + errors.Should().NotBeEmpty(); + } } } From 7e98da45dcc9bf6ada8024c634739c194f77a3f4 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 30 Mar 2023 16:41:43 +0300 Subject: [PATCH 016/110] Update build tasks --- .azure-pipelines/ci-build.yml | 47 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 244797588..66e90d0fd 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -21,7 +21,7 @@ pool: variables: buildPlatform: 'Any CPU' buildConfiguration: 'Release' - ProductBinPath: '$(Build.SourcesDirectory)\src\Microsoft.OpenApi\bin\$(BuildConfiguration)' + ProductBinPath: '$(Build.SourcesDirectory)\src\Microsoft.OpenApi\bin\$(BuildConfiguration)' stages: @@ -31,22 +31,22 @@ stages: - job: build steps: - task: UseDotNet@2 - displayName: 'Use .NET 2' # needed for ESRP signing + displayName: 'Use .NET 6' # needed for ESRP signing inputs: - version: 2.x + version: 6.x - task: UseDotNet@2 displayName: 'Use .NET 7' inputs: version: 7.x - - task: PoliCheck@1 + - task: PoliCheck@2 displayName: 'Run PoliCheck "/src"' inputs: inputType: CmdLine cmdLineArgs: '/F:$(Build.SourcesDirectory)/src /T:9 /Sev:"1|2" /PE:2 /O:poli_result_src.xml' - - task: PoliCheck@1 + - task: PoliCheck@2 displayName: 'Run PoliCheck "/test"' inputs: inputType: CmdLine @@ -75,14 +75,14 @@ stages: arguments: '--configuration $(BuildConfiguration) --no-build' # CredScan - - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 + - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3 displayName: 'Run CredScan - Src' inputs: toolMajorVersion: 'V2' scanFolder: '$(Build.SourcesDirectory)\src' debugMode: false - - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 + - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3 displayName: 'Run CredScan - Test' inputs: toolMajorVersion: 'V2' @@ -95,7 +95,7 @@ stages: FileDirPath: '$(ProductBinPath)' enabled: false - - task: BinSkim@3 + - task: BinSkim@4 displayName: 'Run BinSkim - Product Binaries' inputs: InputType: Basic @@ -105,24 +105,28 @@ stages: AnalyzeHashes: true AnalyzeEnvironment: true - - task: PublishSecurityAnalysisLogs@2 + - task: PublishSecurityAnalysisLogs@3 displayName: 'Publish Security Analysis Logs' inputs: ArtifactName: SecurityLogs - - task: PostAnalysis@1 + - task: PostAnalysis@2 displayName: 'Post Analysis' inputs: BinSkim: true CredScan: true PoliCheck: true - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + - task: EsrpCodeSigning@2 displayName: 'ESRP CodeSigning' inputs: ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)' FolderPath: src signConfigType: inlineSignParams + UseMinimatch: true + Pattern: | + **\*.exe + **\*.dll inlineOperation: | [ { @@ -162,26 +166,27 @@ stages: } ] SessionTimeout: 20 - + # Pack - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg displayName: 'pack OpenAPI' - + # Pack - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg displayName: 'pack Readers' # Pack - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg - displayName: 'pack Hidi' - - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: 'pack Hidi' + + - task: EsrpCodeSigning@2 displayName: 'ESRP CodeSigning Nuget Packages' inputs: ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)' FolderPath: '$(Build.ArtifactStagingDirectory)' Pattern: '*.nupkg' signConfigType: inlineSignParams + UseMinimatch: true inlineOperation: | [ { @@ -209,7 +214,7 @@ stages: $xml = [Xml] (Get-Content .\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj) $version = $xml.Project.PropertyGroup.Version echo $version - echo "##vso[task.setvariable variable=hidiversion]$version" + echo "##vso[task.setvariable variable=hidiversion]$version" # publish hidi as an .exe - task: DotNetCoreCLI@2 @@ -219,7 +224,7 @@ stages: arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion) projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' publishWebProjects: False - zipAfterPublish: false + zipAfterPublish: false - task: CopyFiles@2 displayName: Prepare staging folder for upload @@ -236,7 +241,7 @@ stages: - task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: Hidi' - inputs: + inputs: ArtifactName: Microsoft.OpenApi.Hidi-v$(hidiversion) PathtoPublish: '$(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion)' @@ -295,8 +300,8 @@ stages: { "label" : "enhancement", "V2-Enhancement", "displayName" : "Enhancements", "state" : "closed" }, { "label" : "bug", "bug-fix", "displayName" : "Bugs", "state" : "closed" }, { "label" : "documentation", "doc", "displayName" : "Documentation", "state" : "closed"}, - { "label" : "dependencies", "displayName" : "Package Updates", "state" : "closed" }]' - + { "label" : "dependencies", "displayName" : "Package Updates", "state" : "closed" }]' + - deployment: deploy_lib dependsOn: [] environment: nuget-org From d8b89d9da501bcc7e0af2186bcb4445785ba1e5f Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 30 Mar 2023 16:47:23 +0300 Subject: [PATCH 017/110] Fix indentation --- .azure-pipelines/ci-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 66e90d0fd..2be356791 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -124,9 +124,9 @@ stages: FolderPath: src signConfigType: inlineSignParams UseMinimatch: true - Pattern: | - **\*.exe - **\*.dll + Pattern: | + **\*.exe + **\*.dll inlineOperation: | [ { From 163b7bb6d08641baa6cef566f56611251e228032 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 31 Mar 2023 15:28:56 +0300 Subject: [PATCH 018/110] Fix binskim target argument --- .azure-pipelines/ci-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 2be356791..8b23b8d10 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -99,7 +99,7 @@ stages: displayName: 'Run BinSkim - Product Binaries' inputs: InputType: Basic - AnalyzeTarget: '$(ProductBinPath)\**\Microsoft.OpenApi.dll' + AnalyzeTargetGlob: '$(ProductBinPath)\**\Microsoft.OpenApi.dll' AnalyzeSymPath: '$(ProductBinPath)' AnalyzeVerbose: true AnalyzeHashes: true From a0d1f23190664e95210c8c3c87624c0c453140b5 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 15 Jan 2024 15:48:06 +0300 Subject: [PATCH 019/110] Write out NaN and Infinity primitive values as valid JSON strings --- src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs b/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs index fe15e8887..3ac1b0082 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Globalization; using System.Text; using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Properties; @@ -74,7 +75,19 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) case PrimitiveType.Double: var doubleValue = (OpenApiDouble)(IOpenApiPrimitive)this; - writer.WriteValue(doubleValue.Value); + var actualValue = doubleValue.Value; + if (actualValue.Equals(double.NaN) + || actualValue.Equals(double.NegativeInfinity) + || actualValue.Equals(double.PositiveInfinity)) + { + // Write out NaN, -Infinity, Infinity as strings + writer.WriteValue(actualValue.ToString(CultureInfo.InvariantCulture)); + break; + } + else + { + writer.WriteValue(actualValue); + } break; case PrimitiveType.String: From f72ef895099387a84bb0ff344bc8f8f24cd9d867 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 15 Jan 2024 15:48:17 +0300 Subject: [PATCH 020/110] Add test to validate --- .../Writers/OpenApiJsonWriterTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs index 784750ab6..c770d6b54 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs @@ -7,7 +7,11 @@ using System.Globalization; using System.IO; using System.Linq; +using System.Text; +using System.Text.Json; using FluentAssertions; +using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; using Newtonsoft.Json; using Xunit; @@ -265,5 +269,29 @@ public void WriteDateTimeAsJsonShouldMatchExpected(DateTimeOffset dateTimeOffset // Assert writtenString.Should().Be(expectedString); } + + [Fact] + public void OpenApiJsonWriterOutputsValidJsonValueWhenSchemaHasNanOrInfinityValues() + { + // Arrange + var schema = new OpenApiSchema + { + Enum = new List { + new OpenApiDouble(double.NaN), + new OpenApiDouble(double.PositiveInfinity), + new OpenApiDouble(double.NegativeInfinity) + } + }; + + // Act + var schemaBuilder = new StringBuilder(); + var jsonWriter = new OpenApiJsonWriter(new StringWriter(schemaBuilder)); + schema.SerializeAsV3(jsonWriter); + var jsonString = schemaBuilder.ToString(); + + // Assert + var exception = Record.Exception(() => System.Text.Json.JsonSerializer.Deserialize>(jsonString)); + Assert.Null(exception); + } } } From 46a95c8fc13db18cd76ab48878b4906d61f841dc Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 15 Jan 2024 15:51:15 +0300 Subject: [PATCH 021/110] Remove unnecessary using --- test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs index c770d6b54..f108b950a 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs @@ -8,7 +8,6 @@ using System.IO; using System.Linq; using System.Text; -using System.Text.Json; using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; From a99baf29695128d72874d8c4ccad3e90c90e53be Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Sat, 13 Jan 2024 12:04:14 +0100 Subject: [PATCH 022/110] Replaced RegEx with IndexOf/Substring to avoid RegexMatchTimeoutException --- .../Validations/Rules/OpenApiPathsRules.cs | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs index d94f7a31a..d248edb3c 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Text.RegularExpressions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; @@ -36,7 +35,6 @@ public static class OpenApiPathsRules } }); - private static readonly Regex regexPath = new Regex("\\{([^/}]+)\\}", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100)); /// /// A relative path to an individual endpoint. The field name MUST begin with a slash. /// @@ -50,7 +48,7 @@ public static class OpenApiPathsRules { context.Enter(path); - var pathSignature = regexPath.Replace(path, "{}"); + var pathSignature = GetPathSignature(path); if (!hashSet.Add(pathSignature)) context.CreateError(nameof(PathMustBeUnique), @@ -60,6 +58,28 @@ public static class OpenApiPathsRules } }); + /// + /// Replaces placeholders in the path with {}, e.g. /pets/{petId} becomes /pets/{} . + /// + /// The input path + /// The path signature + private static string GetPathSignature(string path) + { + for (int openBrace = path.IndexOf('{'); openBrace > -1; openBrace = path.IndexOf('{', openBrace + 2)) + { + int closeBrace = path.IndexOf('}', openBrace); + + if (closeBrace < 0) + { + return path; + } + + path = path.Substring(0, openBrace + 1) + path.Substring(closeBrace); + } + + return path; + } + // add more rules } } From d77d40aa0bd1cb56087227e7f20a1820103dc158 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 21:38:25 +0000 Subject: [PATCH 023/110] Bump xunit from 2.6.5 to 2.6.6 Bumps [xunit](https://github.com/xunit/xunit) from 2.6.5 to 2.6.6. - [Commits](https://github.com/xunit/xunit/compare/2.6.5...2.6.6) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... 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 c5857909d..a22b6a7da 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -14,7 +14,7 @@ - + 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 79a80563a..7a89c0044 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -21,7 +21,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 5fe493b42..9d61bcab3 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -12,7 +12,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 8cbcfd872..8fce973d7 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -16,7 +16,7 @@ - + From e3eaf4a63cb4213e3d70ee4f3a8c9e4c22f23eee Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Tue, 16 Jan 2024 10:58:47 +0300 Subject: [PATCH 024/110] Bump up conversion lib. --- 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 81aa85642..e0dc65be8 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -35,7 +35,7 @@ - + From 16e9c7abe0b50c1c7fbf9b7aff934a403ad1db9b Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 16 Jan 2024 12:58:11 +0300 Subject: [PATCH 025/110] Use the TimeOfDay property of a date value to determine whether its a date-only or date-time property --- .../ParseNodes/OpenApiAnyConverter.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs index 4e7e1d08d..e055072e0 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs @@ -63,10 +63,12 @@ public static IOpenApiAny GetSpecificOpenApiAny(IOpenApiAny openApiAny, OpenApiS { // More narrow type detection for explicit strings, only check types that are passed as strings if (schema == null) - { + { if (DateTimeOffset.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTimeValue)) { - return new OpenApiDateTime(dateTimeValue); + // if the time component is exactly midnight(00:00:00) meaning no time has elapsed, return a date-only value + return dateTimeValue.TimeOfDay == TimeSpan.Zero ? new OpenApiDate(dateTimeValue.Date) + : new OpenApiDateTime(dateTimeValue); } } else if (type == "string") From 230a17bb134f68e6df18f6e3f13c23c9b13d3a5e Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 16 Jan 2024 12:58:39 +0300 Subject: [PATCH 026/110] Add a test to validate --- .../V3Tests/OpenApiDocumentTests.cs | 17 ++++++++ .../documentWithDateExampleInSchema.yaml | 42 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/documentWithDateExampleInSchema.yaml diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 1f86ab895..a9401897b 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -1338,5 +1338,22 @@ public void ParseDocumentWithReferencedSecuritySchemeWorks() Assert.False(securityScheme.UnresolvedReference); Assert.NotNull(securityScheme.Flows); } + + [Fact] + public void ValidateExampleShouldNotHaveDataTypeMismatch() + { + // Arrange + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "documentWithDateExampleInSchema.yaml")); + + // Act + var doc = new OpenApiStreamReader(new() + { + ReferenceResolution = ReferenceResolutionSetting.ResolveLocalReferences + }).Read(stream, out var diagnostic); + + // Assert + var warnings = diagnostic.Warnings; + Assert.False(warnings.Any()); + } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/documentWithDateExampleInSchema.yaml b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/documentWithDateExampleInSchema.yaml new file mode 100644 index 000000000..ad8c525cd --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/documentWithDateExampleInSchema.yaml @@ -0,0 +1,42 @@ +openapi: 3.0.0 +info: + title: Sample API + description: Lorem Ipsum + version: 1.0.0 +servers: + - url: http://api.example.com/v1 + description: Lorem Ipsum +paths: + /issues: + get: + summary: Returns a list of issues. + description: Lorem Ipsum + responses: + "200": + description: Lorem Ipsum + content: + application/json: + schema: + type: object + required: + - data + properties: + data: + type: array + items: + $ref: "#/components/schemas/issueData" + example: + data: + - issuedAt: "2023-10-12" +components: + schemas: + issueData: + type: object + title: Issue Data + description: Information about the issue. + properties: + issuedAt: + type: string + format: date + description: Lorem Ipsum + example: "2023-10-12" \ No newline at end of file From ad57d5c620c0dd208c62c0ed0ea5777e2133d325 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 16 Jan 2024 13:02:05 +0300 Subject: [PATCH 027/110] Fix formatting --- src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs index e055072e0..6aefbf947 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs @@ -63,7 +63,7 @@ public static IOpenApiAny GetSpecificOpenApiAny(IOpenApiAny openApiAny, OpenApiS { // More narrow type detection for explicit strings, only check types that are passed as strings if (schema == null) - { + { if (DateTimeOffset.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTimeValue)) { // if the time component is exactly midnight(00:00:00) meaning no time has elapsed, return a date-only value From d26a6d143a75d0c9105cd4bb9de025953a0bef6c Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 16 Jan 2024 17:54:27 +0300 Subject: [PATCH 028/110] 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 81aa85642..7a9ba2aee 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -9,7 +9,7 @@ enable hidi ./../../artifacts - 1.3.6 + 1.3.7 OpenAPI.NET CLI tool for slicing OpenAPI documents true diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index d7d866263..160253eee 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -3,7 +3,7 @@ netstandard2.0 latest true - 1.6.11 + 1.6.12 OpenAPI.NET Readers for JSON and YAML documents true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index d949685c6..b59136dd0 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -3,7 +3,7 @@ netstandard2.0 Latest true - 1.6.11 + 1.6.12 .NET models with JSON and YAML writers for OpenAPI specification true From c84871b235f3b2365a8d3b8ebfd2ecc744d07a14 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 21:34:37 +0000 Subject: [PATCH 029/110] Bump Verify.Xunit from 22.11.5 to 23.0.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 22.11.5 to 23.0.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/22.11.5...23.0.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-major ... 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 8fce973d7..02ce8909d 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From a64342b78f22c8f1fcd93b59d61b73a1bb33741f Mon Sep 17 00:00:00 2001 From: "Andrew Omondi (from Dev Box)" Date: Thu, 18 Jan 2024 10:16:32 +0300 Subject: [PATCH 030/110] Fixes errors/warnings on upgrade --- test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs | 1 - test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs | 1 - test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs | 1 - test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs | 1 - test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs | 1 - test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs | 1 - test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs | 1 - test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs | 1 - test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs | 1 - .../Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs | 1 - test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs | 1 - test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs | 1 - .../Writers/OpenApiWriterAnyExtensionsTests.cs | 1 - 13 files changed, 13 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs index 6b6a8d734..ad26b8288 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs @@ -13,7 +13,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiCallbackTests { public static OpenApiCallback AdvancedCallback = new() diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index ea0b98956..7a7f883f6 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -17,7 +17,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiDocumentTests { public static OpenApiComponents TopLevelReferencingComponents = new() diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs index 14561debd..a847016d0 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs @@ -15,7 +15,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiExampleTests { public static OpenApiExample AdvancedExample = new() diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs index b54c2457e..85316cf3b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs @@ -12,7 +12,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiHeaderTests { public static OpenApiHeader AdvancedHeader = new() diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs index 2f4a532a7..f1a67c330 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs @@ -14,7 +14,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiLinkTests { public static readonly OpenApiLink AdvancedLink = new() diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs index a49f415e3..b26287803 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiParameterTests { public static OpenApiParameter BasicParameter = new() diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs index 08ef42fe7..519c26607 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs @@ -12,7 +12,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiRequestBodyTests { public static OpenApiRequestBody AdvancedRequestBody = new() diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs index ea3a6ee29..fdd1207a6 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs @@ -17,7 +17,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiResponseTests { public static OpenApiResponse BasicResponse = new(); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index c4a9ddd53..5d8320c62 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -20,7 +20,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiSchemaTests { public static OpenApiSchema BasicSchema = new(); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs index 5cc4a19cb..5df97e135 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs @@ -15,7 +15,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiSecuritySchemeTests { public static OpenApiSecurityScheme ApiKeySecurityScheme = new() diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs index fa6690c94..875eb960c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiTagTests { public static OpenApiTag BasicTag = new(); diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index 94164c3cd..511c6c5bd 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -12,7 +12,6 @@ namespace Microsoft.OpenApi.Tests.Services { - [UsesVerify] public class OpenApiUrlTreeNodeTests { private OpenApiDocument OpenApiDocumentSample_1 => new() diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs index 1e632572e..686e3a08a 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.OpenApi.Tests.Writers { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiWriterAnyExtensionsTests { static bool[] shouldProduceTerseOutputValues = new[] { true, false }; From aa97082ec94bc65f7de2a3793876f4d4c454af75 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 22 Jan 2024 14:23:45 -0500 Subject: [PATCH 031/110] - adds permissions to workflows --- .github/workflows/ci-cd.yml | 3 +++ .github/workflows/sonarcloud.yml | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 95f001e1f..bf1aa6a33 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -2,6 +2,9 @@ name: CI/CD Pipeline on: [push, pull_request, workflow_dispatch] +permissions: + contents: write + jobs: ci: name: Continuous Integration diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 5f12a604b..021e0577b 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -9,6 +9,11 @@ on: types: [opened, synchronize, reopened] paths-ignore: ['.vscode/**'] + +permissions: + contents: read + pull-requests: read + env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 39e732e7c03bf43e168fb627566b2b1317bbf768 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 21:14:08 +0000 Subject: [PATCH 032/110] Bump actions/cache from 3 to 4 Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/sonarcloud.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 5f12a604b..4a409185d 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -46,14 +46,14 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Cache SonarCloud packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - name: Cache SonarCloud scanner id: cache-sonar-scanner - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ./.sonar/scanner key: ${{ runner.os }}-sonar-scanner From b004ba6a6dfaeaf35df819d513911ca2182cb1fd Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 23 Jan 2024 14:01:52 +0300 Subject: [PATCH 033/110] Preserve examples in v2 files and write them out as extensions --- .../Models/OpenApiParameter.cs | 16 +++++++++++- .../Models/OpenApiRequestBody.cs | 8 +++--- .../Models/OpenApiResponse.cs | 23 ++++++++++++++++- .../Writers/IOpenApiWriter.cs | 12 ++++++++- .../Writers/OpenApiWriterBase.cs | 25 ++++++++++++++++++- 5 files changed, 77 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 9d1651ad8..2ad433d2f 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -394,6 +394,20 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) } } + //examples + if (Examples != null && Examples.Any()) + { + writer.WritePropertyName("x-examples"); + writer.WriteStartObject(); + + foreach (var example in Examples) + { + writer.WritePropertyName(example.Key); + writer.WriteV2Examples(writer, example.Value, OpenApiSpecVersion.OpenApi2_0); + } + writer.WriteEndObject(); + } + // extensions writer.WriteExtensions(extensionsClone, OpenApiSpecVersion.OpenApi2_0); diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index ff1a70b92..ce0046336 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -152,7 +152,8 @@ internal OpenApiBodyParameter ConvertToBodyParameter() // V2 spec actually allows the body to have custom name. // To allow round-tripping we use an extension to hold the name Name = "body", - Schema = Content.Values.FirstOrDefault()?.Schema ?? new OpenApiSchema(), + Schema = Content.Values.FirstOrDefault()?.Schema ?? new JsonSchemaBuilder().Build(), + Examples = Content.Values.FirstOrDefault()?.Examples, Required = Required, Extensions = Extensions.ToDictionary(static k => k.Key, static v => v.Value) // Clone extensions so we can remove the x-bodyName extensions from the output V2 model. }; @@ -184,7 +185,8 @@ internal IEnumerable ConvertToFormDataParameters() Description = property.Value.Description, Name = property.Key, Schema = property.Value, - Required = Content.First().Value.Schema.Required.Contains(property.Key) + Examples = Content.Values.FirstOrDefault()?.Examples, + Required = Content.First().Value.Schema.GetRequired()?.Contains(property.Key) ?? false }; } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index 320ecc484..f93c323f4 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Collections.Generic; @@ -201,6 +201,27 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) writer.WriteEndObject(); } + if (Content.Values.Any(m => m.Examples != null && m.Examples.Any())) + { + writer.WritePropertyName("x-examples"); + writer.WriteStartObject(); + + foreach (var mediaTypePair in Content) + { + var examples = mediaTypePair.Value.Examples; + if (examples != null && examples.Any()) + { + foreach (var example in examples) + { + writer.WritePropertyName(example.Key); + writer.WriteV2Examples(writer, example.Value, OpenApiSpecVersion.OpenApi2_0); + } + } + } + + writer.WriteEndObject(); + } + writer.WriteExtensions(mediatype.Value.Extensions, OpenApiSpecVersion.OpenApi2_0); foreach (var key in mediatype.Value.Extensions.Keys) diff --git a/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs b/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs index 9ea04b400..d40643bfc 100644 --- a/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs +++ b/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs @@ -1,6 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using Microsoft.OpenApi.Models; + namespace Microsoft.OpenApi.Writers { /// @@ -72,5 +74,13 @@ public interface IOpenApiWriter /// Flush the writer. /// void Flush(); + + /// + /// Writes out existing examples in a mediatype object + /// + /// + /// + /// + void WriteV2Examples(IOpenApiWriter writer, OpenApiExample example, OpenApiSpecVersion version); } } diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs index 5254288f3..06aa469b9 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -405,5 +405,28 @@ protected void VerifyCanWritePropertyName(string name) string.Format(SRResource.ObjectScopeNeededForPropertyNameWriting, name)); } } + + /// + public void WriteV2Examples(IOpenApiWriter writer, OpenApiExample example, OpenApiSpecVersion version) + { + writer.WriteStartObject(); + + // summary + writer.WriteProperty(OpenApiConstants.Summary, example.Summary); + + // description + writer.WriteProperty(OpenApiConstants.Description, example.Description); + + // value + writer.WriteOptionalObject(OpenApiConstants.Value, example.Value, (w, v) => w.WriteAny(v)); + + // externalValue + writer.WriteProperty(OpenApiConstants.ExternalValue, example.ExternalValue); + + // extensions + writer.WriteExtensions(example.Extensions, version); + + writer.WriteEndObject(); + } } } From ef2b99dfcdc2f76acabb138494dbebaf027dae56 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 23 Jan 2024 14:12:00 +0300 Subject: [PATCH 034/110] Update tests and public API interface --- ...V2JsonWorksAsync_produceTerseOutput=False.verified.txt | 8 +++++++- ...sV2JsonWorksAsync_produceTerseOutput=True.verified.txt | 2 +- .../Models/OpenApiParameterTests.cs | 8 +++++++- .../PublicApi/PublicApi.approved.txt | 2 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 0542c58ce..744f8451c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -3,5 +3,11 @@ "name": "name1", "description": "description1", "required": true, - "type": "string" + "type": "string", + "x-examples": { + "test": { + "summary": "summary3", + "description": "description3" + } + } } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index b80b263d3..26b158865 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"in":"header","name":"name1","description":"description1","required":true,"type":"string"} \ No newline at end of file +{"in":"header","name":"name1","description":"description1","required":true,"type":"string","x-examples":{"test":{"summary":"summary3","description":"description3"}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs index b26287803..2f02ff7dd 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs @@ -272,7 +272,13 @@ public void SerializeAdvancedParameterAsV2JsonWorks() "name": "name1", "description": "description1", "required": true, - "format": "double" + "format": "double", + "x-examples": { + "test": { + "summary": "summary3", + "description": "description3" + } + } } """; diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index a5309e46d..36a83b1ed 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1486,6 +1486,7 @@ namespace Microsoft.OpenApi.Writers void WriteRaw(string value); void WriteStartArray(); void WriteStartObject(); + void WriteV2Examples(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.Models.OpenApiExample example, Microsoft.OpenApi.OpenApiSpecVersion version); void WriteValue(bool value); void WriteValue(decimal value); void WriteValue(int value); @@ -1547,6 +1548,7 @@ namespace Microsoft.OpenApi.Writers public abstract void WriteRaw(string value); public abstract void WriteStartArray(); public abstract void WriteStartObject(); + public void WriteV2Examples(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.Models.OpenApiExample example, Microsoft.OpenApi.OpenApiSpecVersion version) { } public virtual void WriteValue(bool value) { } public virtual void WriteValue(System.DateTime value) { } public virtual void WriteValue(System.DateTimeOffset value) { } From cfa49e9a24bce679b722a7ef22566d449b393778 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 10 Jan 2024 11:35:20 +0300 Subject: [PATCH 035/110] Add examples constant to temp storage keys --- src/Microsoft.OpenApi.Readers/V2/TempStorageKeys.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.OpenApi.Readers/V2/TempStorageKeys.cs b/src/Microsoft.OpenApi.Readers/V2/TempStorageKeys.cs index c7b96f6ce..176af8a1e 100644 --- a/src/Microsoft.OpenApi.Readers/V2/TempStorageKeys.cs +++ b/src/Microsoft.OpenApi.Readers/V2/TempStorageKeys.cs @@ -17,5 +17,6 @@ internal static class TempStorageKeys public const string GlobalConsumes = "globalConsumes"; public const string GlobalProduces = "globalProduces"; public const string ParameterIsBodyOrFormData = "parameterIsBodyOrFormData"; + public const string Examples = "examples"; } } From eda97ad2a4bfcbe5b89b5219c67902c5f57e221f Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 23 Jan 2024 14:14:54 +0300 Subject: [PATCH 036/110] Load "x-examples" as Examples; store and retrieve from temp storage and append it to the media type object --- .../V2/OpenApiResponseDeserializer.cs | 55 ++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs index 2fef353ea..8ec4c699d 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Collections.Generic; @@ -28,6 +28,10 @@ internal static partial class OpenApiV2Deserializer "examples", LoadExamples }, + { + "x-examples", + LoadExamplesExtension + }, { "schema", (o, n) => n.Context.SetTempStorage(TempStorageKeys.ResponseSchema, LoadSchema(n), o) @@ -37,7 +41,7 @@ internal static partial class OpenApiV2Deserializer private static readonly PatternFieldMap _responsePatternFields = new() { - {s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} + {s => s.StartsWith("x-") && !s.Equals("x-examples"), (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} }; private static readonly AnyFieldMap _mediaTypeAnyFields = @@ -69,6 +73,7 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P ?? context.DefaultContentType ?? new List { "application/octet-stream" }; var schema = context.GetFromTempStorage(TempStorageKeys.ResponseSchema, response); + var examples = context.GetFromTempStorage>(TempStorageKeys.Examples, response); foreach (var produce in produces) { @@ -84,7 +89,8 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P { var mediaType = new OpenApiMediaType { - Schema = schema + Schema = schema, + Examples = examples }; response.Content.Add(produce, mediaType); @@ -92,12 +98,49 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P } context.SetTempStorage(TempStorageKeys.ResponseSchema, null, response); + context.SetTempStorage(TempStorageKeys.Examples, null, response); context.SetTempStorage(TempStorageKeys.ResponseProducesSet, true, response); } + private static void LoadExamplesExtension(OpenApiResponse response, ParseNode node) + { + var mapNode = node.CheckMapNode("x-examples"); + var examples = new Dictionary(); + + foreach (var examplesNode in mapNode) + { + // Load the media type node as an OpenApiExample object + var example = new OpenApiExample(); + var exampleNode = examplesNode.Value.CheckMapNode(examplesNode.Name); + foreach (var valueNode in exampleNode) + { + switch (valueNode.Name) + { + case "summary": + example.Summary = valueNode.Value.GetScalarValue(); + break; + case "description": + example.Description = valueNode.Value.GetScalarValue(); + break; + case "value": + example.Value = valueNode.Value.CreateAny(); + break; + case "externalValue": + example.ExternalValue = valueNode.Value.GetScalarValue(); + break; + } + } + + examples.Add(examplesNode.Name, example); + } + + node.Context.SetTempStorage(TempStorageKeys.Examples, examples, response); + } + private static void LoadExamples(OpenApiResponse response, ParseNode node) { var mapNode = node.CheckMapNode("examples"); + foreach (var mediaTypeNode in mapNode) { LoadExample(response, mediaTypeNode.Name, mediaTypeNode.Value); @@ -108,10 +151,7 @@ private static void LoadExample(OpenApiResponse response, string mediaType, Pars { var exampleNode = node.CreateAny(); - if (response.Content == null) - { - response.Content = new Dictionary(); - } + response.Content ??= new Dictionary(); OpenApiMediaType mediaTypeObject; if (response.Content.TryGetValue(mediaType, out var value)) @@ -141,6 +181,7 @@ public static OpenApiResponse LoadResponse(ParseNode node) } var response = new OpenApiResponse(); + foreach (var property in mapNode) { property.ParseField(response, _responseFixedFields, _responsePatternFields); From f6001479381ffd69a855eff75e4a1c05e30e3097 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 23 Jan 2024 14:26:57 +0300 Subject: [PATCH 037/110] Default to an empty collection if examples is null --- .../V2/OpenApiResponseDeserializer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs index 8ec4c699d..7d482aec7 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs @@ -73,7 +73,8 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P ?? context.DefaultContentType ?? new List { "application/octet-stream" }; var schema = context.GetFromTempStorage(TempStorageKeys.ResponseSchema, response); - var examples = context.GetFromTempStorage>(TempStorageKeys.Examples, response); + var examples = context.GetFromTempStorage>(TempStorageKeys.Examples, response) + ?? new Dictionary(); foreach (var produce in produces) { From 61d50b5bfdd6323cd4780c64ee55b5d94499094a Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 10 Jan 2024 13:47:47 +0300 Subject: [PATCH 038/110] Add a reference to the OpenApi.Tests project to access the string extension method --- .../Microsoft.OpenApi.Readers.Tests.csproj | 1 + 1 file changed, 1 insertion(+) 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 7a89c0044..0bf7fcc3e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -28,6 +28,7 @@ + \ No newline at end of file From e41b927377a51062808f1610c97a0d2036c3c510 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 10 Jan 2024 13:48:56 +0300 Subject: [PATCH 039/110] Add test to validate that a V2 doc with x-examples gets mapped to MediaType Examples object when upcasting to V3 --- .../V2Tests/OpenApiOperationTests.cs | 52 +++++++++++++++++++ .../opWithResponseExamplesExtension.yaml | 28 ++++++++++ 2 files changed, 80 insertions(+) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/opWithResponseExamplesExtension.yaml diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index 326c16969..c2b3c69ff 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -11,6 +11,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; using Microsoft.OpenApi.Readers.V2; +using Microsoft.OpenApi.Tests; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V2Tests @@ -434,5 +435,56 @@ public void ParseOperationWithBodyAndEmptyConsumesSetsRequestBodySchemaIfExists( // Assert operation.Should().BeEquivalentTo(_operationWithBody); } + + [Fact] + public void ParseV2ResponseWithExamplesExtensionWorks() + { + // Arrange + MapNode node; + using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "opWithResponseExamplesExtension.yaml"))) + { + node = TestHelper.CreateYamlMapNode(stream); + } + + // Act + var operation = OpenApiV2Deserializer.LoadOperation(node); + var actual = operation.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); + + // Assert + var expected = @"summary: Get all pets +responses: + '200': + description: Successful response + content: + application/json: + schema: + type: array + items: + type: object + properties: + name: + type: string + age: + type: integer + examples: + example1: + summary: Example - List of Pets + value: + - name: Buddy + age: 2 + - name: Whiskers + age: 1 + example2: + summary: Example - Playful Cat + value: + name: Whiskers + age: 1"; + + // Assert + actual = actual.MakeLineBreaksEnvironmentNeutral(); + expected = expected.MakeLineBreaksEnvironmentNeutral(); + actual.Should().Be(expected); + //Assert.Equal(expected, actual); + } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/opWithResponseExamplesExtension.yaml b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/opWithResponseExamplesExtension.yaml new file mode 100644 index 000000000..5dcc89d97 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/opWithResponseExamplesExtension.yaml @@ -0,0 +1,28 @@ +summary: Get all pets +produces: +- application/json +responses: + '200': + description: Successful response + schema: + type: array + items: + type: object + properties: + name: + type: string + age: + type: integer + x-examples: + example1: + summary: Example - List of Pets + value: + - name: "Buddy" + age: 2 + - name: "Whiskers" + age: 1 + example2: + summary: Example - Playful Cat + value: + name: "Whiskers" + age: 1 \ No newline at end of file From eb9ba944c12dcce1752cc59ddead9d5a09510d33 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 11 Jan 2024 12:12:42 +0300 Subject: [PATCH 040/110] Add unit tests --- .../V2Tests/OpenApiOperationTests.cs | 52 ++++++++++++++++++- .../v3OperationWithResponseExamples.yaml | 28 ++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/v3OperationWithResponseExamples.yaml diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index c2b3c69ff..fbf157b4c 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -11,6 +11,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; using Microsoft.OpenApi.Readers.V2; +using Microsoft.OpenApi.Readers.V3; using Microsoft.OpenApi.Tests; using Xunit; @@ -484,7 +485,56 @@ public void ParseV2ResponseWithExamplesExtensionWorks() actual = actual.MakeLineBreaksEnvironmentNeutral(); expected = expected.MakeLineBreaksEnvironmentNeutral(); actual.Should().Be(expected); - //Assert.Equal(expected, actual); + } + + [Fact] + public void LoadV3ExamplesInResponseAsExtensionsWorks() + { + // Arrange + MapNode node; + using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "v3OperationWithResponseExamples.yaml"))) + { + node = TestHelper.CreateYamlMapNode(stream); + } + + // Act + var operation = OpenApiV3Deserializer.LoadOperation(node); + var actual = operation.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0); + + // Assert + var expected = @"summary: Get all pets +produces: + - application/json +responses: + '200': + description: Successful response + schema: + type: array + items: + type: object + properties: + name: + type: string + age: + type: integer + x-examples: + example1: + summary: Example - List of Pets + value: + - name: Buddy + age: 2 + - name: Whiskers + age: 1 + example2: + summary: Example - Playful Cat + value: + name: Whiskers + age: 1"; + + // Assert + actual = actual.MakeLineBreaksEnvironmentNeutral(); + expected = expected.MakeLineBreaksEnvironmentNeutral(); + actual.Should().Be(expected); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/v3OperationWithResponseExamples.yaml b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/v3OperationWithResponseExamples.yaml new file mode 100644 index 000000000..c3b124685 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/v3OperationWithResponseExamples.yaml @@ -0,0 +1,28 @@ +summary: Get all pets +responses: + '200': + description: Successful response + content: + application/json: + schema: + type: array + items: + type: object + properties: + name: + type: string + age: + type: integer + examples: + example1: + summary: Example - List of Pets + value: + - name: "Buddy" + age: 2 + - name: "Whiskers" + age: 1 + example2: + summary: Example - Playful Cat + value: + name: "Whiskers" + age: 1 \ No newline at end of file From af5568ca15b84b60bdc87a1b055279eba7908a45 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 23 Jan 2024 14:31:07 +0300 Subject: [PATCH 041/110] Fix CodeQL warnings --- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 9 +-------- src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs | 11 ++--------- src/Microsoft.OpenApi/Models/OpenApiResponse.cs | 9 +-------- 4 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 578c1e34e..8d4526a20 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 2ad433d2f..2185e3aa0 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -204,14 +204,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// OpenApiParameter public OpenApiParameter GetEffective(OpenApiDocument doc) { - if (this.Reference != null) - { - return doc.ResolveReferenceTo(this.Reference); - } - else - { - return this; - } + return Reference != null ? doc.ResolveReferenceTo(Reference) : this; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index ce0046336..ea3c3dcb1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -96,14 +96,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// OpenApiRequestBody public OpenApiRequestBody GetEffective(OpenApiDocument doc) { - if (this.Reference != null) - { - return doc.ResolveReferenceTo(this.Reference); - } - else - { - return this; - } + return Reference != null ? doc.ResolveReferenceTo(Reference) : this; } /// @@ -157,7 +150,7 @@ internal OpenApiBodyParameter ConvertToBodyParameter() Required = Required, Extensions = Extensions.ToDictionary(static k => k.Key, static v => v.Value) // Clone extensions so we can remove the x-bodyName extensions from the output V2 model. }; - if (bodyParameter.Extensions.ContainsKey(OpenApiConstants.BodyName)) + if (bodyParameter.Extensions.TryGetValue(OpenApiConstants.BodyName, out var bodyParameterName)) { bodyParameter.Name = (Extensions[OpenApiConstants.BodyName] as OpenApiString)?.Value ?? "body"; bodyParameter.Extensions.Remove(OpenApiConstants.BodyName); diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index f93c323f4..ec4058100 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -101,14 +101,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// OpenApiResponse public OpenApiResponse GetEffective(OpenApiDocument doc) { - if (this.Reference != null) - { - return doc.ResolveReferenceTo(this.Reference); - } - else - { - return this; - } + return Reference != null ? doc.ResolveReferenceTo(Reference) : this; } /// From dc7cef8a3f529a920f7bbc54517f2222fa5036d2 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 23 Jan 2024 14:33:02 +0300 Subject: [PATCH 042/110] Filter sequence using "Where" --- src/Microsoft.OpenApi/Models/OpenApiResponse.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index ec4058100..ab9428841 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -199,17 +199,12 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) writer.WritePropertyName("x-examples"); writer.WriteStartObject(); - foreach (var mediaTypePair in Content) + foreach (var example in Content + .Where(mediaTypePair => mediaTypePair.Value.Examples != null && mediaTypePair.Value.Examples.Any()) + .SelectMany(mediaTypePair => mediaTypePair.Value.Examples)) { - var examples = mediaTypePair.Value.Examples; - if (examples != null && examples.Any()) - { - foreach (var example in examples) - { - writer.WritePropertyName(example.Key); - writer.WriteV2Examples(writer, example.Value, OpenApiSpecVersion.OpenApi2_0); - } - } + writer.WritePropertyName(example.Key); + writer.WriteV2Examples(writer, example.Value, OpenApiSpecVersion.OpenApi2_0); } writer.WriteEndObject(); From 840c591d11b242a886dca689198a8cf5b431a615 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 11 Jan 2024 17:34:44 +0300 Subject: [PATCH 043/110] Update src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs Co-authored-by: Vincent Biret --- src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs index 7d482aec7..3b84a1a19 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs @@ -41,7 +41,7 @@ internal static partial class OpenApiV2Deserializer private static readonly PatternFieldMap _responsePatternFields = new() { - {s => s.StartsWith("x-") && !s.Equals("x-examples"), (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} + {s => s.StartsWith("x-") && !s.Equals("x-examples", StringComparison.OrdinalIgnoreCase), (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} }; private static readonly AnyFieldMap _mediaTypeAnyFields = From 9d226dfae8d84b03704dbe01e0296bc4b70bd484 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 11 Jan 2024 09:45:23 -0500 Subject: [PATCH 044/110] - adds missing using --- src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs index 3b84a1a19..1eef8c559 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Collections.Generic; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; From 3f11c6175107d27a3ce279f29b4866c3f22a1665 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 23 Jan 2024 14:36:19 +0300 Subject: [PATCH 045/110] Add normalization; use constant for Examples extension --- .../V2/OpenApiResponseDeserializer.cs | 6 +++--- src/Microsoft.OpenApi/Models/OpenApiConstants.cs | 5 +++++ src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiResponse.cs | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs index 1eef8c559..b1fc26f85 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs @@ -42,7 +42,7 @@ internal static partial class OpenApiV2Deserializer private static readonly PatternFieldMap _responsePatternFields = new() { - {s => s.StartsWith("x-") && !s.Equals("x-examples", StringComparison.OrdinalIgnoreCase), (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} + {s => s.StartsWith("x-") && !s.Equals(OpenApiConstants.ExamplesExtension), (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} }; private static readonly AnyFieldMap _mediaTypeAnyFields = @@ -106,7 +106,7 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P private static void LoadExamplesExtension(OpenApiResponse response, ParseNode node) { - var mapNode = node.CheckMapNode("x-examples"); + var mapNode = node.CheckMapNode(OpenApiConstants.ExamplesExtension); var examples = new Dictionary(); foreach (var examplesNode in mapNode) @@ -116,7 +116,7 @@ private static void LoadExamplesExtension(OpenApiResponse response, ParseNode no var exampleNode = examplesNode.Value.CheckMapNode(examplesNode.Name); foreach (var valueNode in exampleNode) { - switch (valueNode.Name) + switch (valueNode.Name.ToLowerInvariant()) { case "summary": example.Summary = valueNode.Value.GetScalarValue(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiConstants.cs b/src/Microsoft.OpenApi/Models/OpenApiConstants.cs index 40867d7e0..73de74228 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiConstants.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiConstants.cs @@ -565,6 +565,11 @@ public static class OpenApiConstants /// public const string BodyName = "x-bodyName"; + /// + /// Field: Examples Extension + /// + public const string ExamplesExtension = "x-examples"; + /// /// Field: version3_0_0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 2185e3aa0..57c4b3649 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -390,7 +390,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) //examples if (Examples != null && Examples.Any()) { - writer.WritePropertyName("x-examples"); + writer.WritePropertyName(OpenApiConstants.ExamplesExtension); writer.WriteStartObject(); foreach (var example in Examples) diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index ab9428841..369f09761 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -196,7 +196,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) if (Content.Values.Any(m => m.Examples != null && m.Examples.Any())) { - writer.WritePropertyName("x-examples"); + writer.WritePropertyName(OpenApiConstants.ExamplesExtension); writer.WriteStartObject(); foreach (var example in Content From 5d69edae1dbd6d261db1146ee89092e989bdddf6 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 11 Jan 2024 17:55:51 +0300 Subject: [PATCH 046/110] Update API interface --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 36a83b1ed..256832e42 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -480,6 +480,7 @@ namespace Microsoft.OpenApi.Models public const string Enum = "enum"; public const string Example = "example"; public const string Examples = "examples"; + public const string ExamplesExtension = "x-examples"; public const string ExclusiveMaximum = "exclusiveMaximum"; public const string ExclusiveMinimum = "exclusiveMinimum"; public const string Explode = "explode"; From 6cd8a82503449f77c4b054ca122e13df33fddf6d Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 23 Jan 2024 15:25:01 +0300 Subject: [PATCH 047/110] Code cleanup and refactoring --- .../V2/OpenApiResponseDeserializer.cs | 6 +++--- src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 3 ++- src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs | 6 +++--- src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs | 3 ++- ...V2JsonWorksAsync_produceTerseOutput=False.verified.txt | 8 +++++++- ...sV2JsonWorksAsync_produceTerseOutput=True.verified.txt | 2 +- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs index b1fc26f85..b624f1b3a 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -42,7 +42,7 @@ internal static partial class OpenApiV2Deserializer private static readonly PatternFieldMap _responsePatternFields = new() { - {s => s.StartsWith("x-") && !s.Equals(OpenApiConstants.ExamplesExtension), (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} + {s => s.StartsWith("x-") && !s.Equals(OpenApiConstants.ExamplesExtension, StringComparison.OrdinalIgnoreCase), (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} }; private static readonly AnyFieldMap _mediaTypeAnyFields = @@ -125,7 +125,7 @@ private static void LoadExamplesExtension(OpenApiResponse response, ParseNode no example.Description = valueNode.Value.GetScalarValue(); break; case "value": - example.Value = valueNode.Value.CreateAny(); + example.Value = OpenApiAnyConverter.GetSpecificOpenApiAny(valueNode.Value.CreateAny()); break; case "externalValue": example.ExternalValue = valueNode.Value.GetScalarValue(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 57c4b3649..6608025a9 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -1,8 +1,9 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; using System.Collections.Generic; +using System.Linq; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index ea3c3dcb1..7fa58be5f 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -145,7 +145,7 @@ internal OpenApiBodyParameter ConvertToBodyParameter() // V2 spec actually allows the body to have custom name. // To allow round-tripping we use an extension to hold the name Name = "body", - Schema = Content.Values.FirstOrDefault()?.Schema ?? new JsonSchemaBuilder().Build(), + Schema = Content.Values.FirstOrDefault()?.Schema ?? new OpenApiSchema(), Examples = Content.Values.FirstOrDefault()?.Examples, Required = Required, Extensions = Extensions.ToDictionary(static k => k.Key, static v => v.Value) // Clone extensions so we can remove the x-bodyName extensions from the output V2 model. @@ -179,7 +179,7 @@ internal IEnumerable ConvertToFormDataParameters() Name = property.Key, Schema = property.Value, Examples = Content.Values.FirstOrDefault()?.Examples, - Required = Content.First().Value.Schema.GetRequired()?.Contains(property.Key) ?? false + Required = Content.First().Value.Schema.Required?.Contains(property.Key) ?? false }; } } diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs index 06aa469b9..1edab6392 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; using System.Collections.Generic; using System.IO; using Microsoft.OpenApi.Exceptions; +using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; namespace Microsoft.OpenApi.Writers diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 0542c58ce..744f8451c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -3,5 +3,11 @@ "name": "name1", "description": "description1", "required": true, - "type": "string" + "type": "string", + "x-examples": { + "test": { + "summary": "summary3", + "description": "description3" + } + } } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index b80b263d3..26b158865 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"in":"header","name":"name1","description":"description1","required":true,"type":"string"} \ No newline at end of file +{"in":"header","name":"name1","description":"description1","required":true,"type":"string","x-examples":{"test":{"summary":"summary3","description":"description3"}}} \ No newline at end of file From d4d70959c9f33da2f0cc0cd9b27bf431bd0adb51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 21:33:50 +0000 Subject: [PATCH 048/110] Bump Microsoft.OpenApi.OData from 1.6.0-preview.2 to 1.6.0-preview.3 Bumps [Microsoft.OpenApi.OData](https://github.com/Microsoft/OpenAPI.NET.OData) from 1.6.0-preview.2 to 1.6.0-preview.3. - [Release notes](https://github.com/Microsoft/OpenAPI.NET.OData/releases) - [Commits](https://github.com/Microsoft/OpenAPI.NET.OData/commits) --- updated-dependencies: - dependency-name: Microsoft.OpenApi.OData dependency-type: direct:production update-type: version-update:semver-patch ... 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 84a64182b..505d50ef8 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -35,7 +35,7 @@ - + From de74419ed9679c0c6ecc4c70a0b0ff140931881b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 21:34:09 +0000 Subject: [PATCH 049/110] Bump Verify.Xunit from 23.0.0 to 23.0.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.0.0 to 23.0.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/23.0.0...23.0.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 02ce8909d..6f68a8cee 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 51d7b3041f145713e0adedbbd398c16fb1e98d09 Mon Sep 17 00:00:00 2001 From: Luc Genetier <69138830+LucGenetier@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:29:58 +0100 Subject: [PATCH 050/110] Add ValidationRuleSet.Remove (#1535) * Add ValidationRuleSet.Remove * Updates following Vincent's comments * Updates following Vincent's comments Add ValidationRuleSet.Remove * Update * Apply suggestions from code review --------- Co-authored-by: Vincent Biret Co-authored-by: Eastman Co-authored-by: Darrel Co-authored-by: Maggie Kimani Co-authored-by: Irvine Sunday <40403681+irvinesunday@users.noreply.github.com> Co-authored-by: Vincent Biret --- .../Rules/OpenApiComponentsRules.cs | 2 +- .../Validations/Rules/OpenApiContactRules.cs | 2 +- .../Validations/Rules/OpenApiDocumentRules.cs | 2 +- .../Rules/OpenApiExtensionRules.cs | 2 +- .../Rules/OpenApiExternalDocsRules.cs | 2 +- .../Validations/Rules/OpenApiHeaderRules.cs | 2 +- .../Validations/Rules/OpenApiInfoRules.cs | 2 +- .../Validations/Rules/OpenApiLicenseRules.cs | 2 +- .../Rules/OpenApiMediaTypeRules.cs | 2 +- .../Rules/OpenApiOAuthFlowRules.cs | 2 +- .../Rules/OpenApiParameterRules.cs | 8 ++-- .../Validations/Rules/OpenApiPathsRules.cs | 4 +- .../Validations/Rules/OpenApiResponseRules.cs | 2 +- .../Rules/OpenApiResponsesRules.cs | 6 +-- .../Validations/Rules/OpenApiSchemaRules.cs | 4 +- .../Validations/Rules/OpenApiServerRules.cs | 2 +- .../Validations/Rules/OpenApiTagRules.cs | 2 +- .../Validations/ValidationRule.cs | 28 +++++++++++-- .../Validations/ValidationRuleSet.cs | 24 +++++++++++ .../PublicApi/PublicApi.approved.txt | 6 ++- .../Services/OpenApiValidatorTests.cs | 41 ++++++++++++++++++- .../OpenApiReferenceValidationTests.cs | 2 +- 22 files changed, 119 insertions(+), 30 deletions(-) diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs index f2f3a649c..93eba5c71 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs @@ -24,7 +24,7 @@ public static class OpenApiComponentsRules /// that MUST use keys that match the regular expression: ^[a-zA-Z0-9\.\-_]+$. /// public static ValidationRule KeyMustBeRegularExpression => - new( + new(nameof(KeyMustBeRegularExpression), (context, components) => { ValidateKeys(context, components.Schemas?.Keys, "schemas"); diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs index cfa8d9927..e31dc1e07 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs @@ -17,7 +17,7 @@ public static class OpenApiContactRules /// Email field MUST be email address. /// public static ValidationRule EmailMustBeEmailFormat => - new( + new(nameof(EmailMustBeEmailFormat), (context, item) => { context.Enter("email"); diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiDocumentRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiDocumentRules.cs index be0dc1538..f38e2530f 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiDocumentRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiDocumentRules.cs @@ -17,7 +17,7 @@ public static class OpenApiDocumentRules /// The Info field is required. /// public static ValidationRule OpenApiDocumentFieldIsMissing => - new( + new(nameof(OpenApiDocumentFieldIsMissing), (context, item) => { // info diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs index 5d124e8de..890be82d7 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs @@ -17,7 +17,7 @@ public static class OpenApiExtensibleRules /// Extension name MUST start with "x-". /// public static ValidationRule ExtensionNameMustStartWithXDash => - new( + new(nameof(ExtensionNameMustStartWithXDash), (context, item) => { context.Enter("extensions"); diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExternalDocsRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExternalDocsRules.cs index ff4fde4a2..1754dbee2 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExternalDocsRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExternalDocsRules.cs @@ -17,7 +17,7 @@ public static class OpenApiExternalDocsRules /// Validate the field is required. /// public static ValidationRule UrlIsRequired => - new( + new(nameof(UrlIsRequired), (context, item) => { // url diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs index c446a7b56..194e426cc 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs @@ -16,7 +16,7 @@ public static class OpenApiHeaderRules /// Validate the data matches with the given data type. /// public static ValidationRule HeaderMismatchedDataType => - new( + new(nameof(HeaderMismatchedDataType), (context, header) => { // example diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiInfoRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiInfoRules.cs index 88b534c02..337bf8687 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiInfoRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiInfoRules.cs @@ -17,7 +17,7 @@ public static class OpenApiInfoRules /// Validate the field is required. /// public static ValidationRule InfoRequiredFields => - new( + new(nameof(InfoRequiredFields), (context, item) => { // title diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiLicenseRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiLicenseRules.cs index edbf19bf5..08f67d209 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiLicenseRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiLicenseRules.cs @@ -17,7 +17,7 @@ public static class OpenApiLicenseRules /// REQUIRED. /// public static ValidationRule LicenseRequiredFields => - new( + new(nameof(LicenseRequiredFields), (context, license) => { context.Enter("name"); diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs index 6f7b65a6c..7ac09cbbf 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs @@ -24,7 +24,7 @@ public static class OpenApiMediaTypeRules /// Validate the data matches with the given data type. /// public static ValidationRule MediaTypeMismatchedDataType => - new( + new(nameof(MediaTypeMismatchedDataType), (context, mediaType) => { // example diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiOAuthFlowRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiOAuthFlowRules.cs index de31d933d..c6db49d7c 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiOAuthFlowRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiOAuthFlowRules.cs @@ -17,7 +17,7 @@ public static class OpenApiOAuthFlowRules /// Validate the field is required. /// public static ValidationRule OAuthFlowRequiredFields => - new( + new(nameof(OAuthFlowRequiredFields), (context, flow) => { // authorizationUrl diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs index 5c19ce1d9..a1a228134 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs @@ -17,7 +17,7 @@ public static class OpenApiParameterRules /// Validate the field is required. /// public static ValidationRule ParameterRequiredFields => - new( + new(nameof(ParameterRequiredFields), (context, item) => { // name @@ -43,7 +43,7 @@ public static class OpenApiParameterRules /// Validate the "required" field is true when "in" is path. /// public static ValidationRule RequiredMustBeTrueWhenInIsPath => - new( + new(nameof(RequiredMustBeTrueWhenInIsPath), (context, item) => { // required @@ -62,7 +62,7 @@ public static class OpenApiParameterRules /// Validate the data matches with the given data type. /// public static ValidationRule ParameterMismatchedDataType => - new( + new(nameof(ParameterMismatchedDataType), (context, parameter) => { // example @@ -100,7 +100,7 @@ public static class OpenApiParameterRules /// Validate that a path parameter should always appear in the path /// public static ValidationRule PathParameterShouldBeInThePath => - new( + new(nameof(PathParameterShouldBeInThePath), (context, parameter) => { if (parameter.In == ParameterLocation.Path && diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs index d248edb3c..9c23f7220 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs @@ -18,7 +18,7 @@ public static class OpenApiPathsRules /// A relative path to an individual endpoint. The field name MUST begin with a slash. /// public static ValidationRule PathNameMustBeginWithSlash => - new( + new(nameof(PathNameMustBeginWithSlash), (context, item) => { foreach (var pathName in item.Keys) @@ -39,7 +39,7 @@ public static class OpenApiPathsRules /// A relative path to an individual endpoint. The field name MUST begin with a slash. /// public static ValidationRule PathMustBeUnique => - new ValidationRule( + new ValidationRule(nameof(PathMustBeUnique), (context, item) => { var hashSet = new HashSet(); diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponseRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponseRules.cs index 0f725c90e..f30b49ea0 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponseRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponseRules.cs @@ -17,7 +17,7 @@ public static class OpenApiResponseRules /// Validate the field is required. /// public static ValidationRule ResponseRequiredFields => - new( + new(nameof(ResponseRequiredFields), (context, response) => { // description diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponsesRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponsesRules.cs index 1afe9a388..a2b91dc31 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponsesRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponsesRules.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Linq; @@ -17,7 +17,7 @@ public static class OpenApiResponsesRules /// An OpenAPI operation must contain at least one response /// public static ValidationRule ResponsesMustContainAtLeastOneResponse => - new( + new(nameof(ResponsesMustContainAtLeastOneResponse), (context, responses) => { if (!responses.Keys.Any()) @@ -31,7 +31,7 @@ public static class OpenApiResponsesRules /// The response key must either be "default" or an HTTP status code (1xx, 2xx, 3xx, 4xx, 5xx). /// public static ValidationRule ResponsesMustBeIdentifiedByDefaultOrStatusCode => - new( + new(nameof(ResponsesMustBeIdentifiedByDefaultOrStatusCode), (context, responses) => { foreach (var key in responses.Keys) diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs index a936766c8..411f26fd0 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs @@ -17,7 +17,7 @@ public static class OpenApiSchemaRules /// Validate the data matches with the given data type. /// public static ValidationRule SchemaMismatchedDataType => - new( + new(nameof(SchemaMismatchedDataType), (context, schema) => { // default @@ -60,7 +60,7 @@ public static class OpenApiSchemaRules /// Validates Schema Discriminator /// public static ValidationRule ValidateSchemaDiscriminator => - new( + new(nameof(ValidateSchemaDiscriminator), (context, schema) => { // discriminator diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs index 292fd1fd0..dd11a661d 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs @@ -17,7 +17,7 @@ public static class OpenApiServerRules /// Validate the field is required. /// public static ValidationRule ServerRequiredFields => - new( + new(nameof(ServerRequiredFields), (context, server) => { context.Enter("url"); diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiTagRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiTagRules.cs index f28732e1e..cc006f971 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiTagRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiTagRules.cs @@ -17,7 +17,7 @@ public static class OpenApiTagRules /// Validate the field is required. /// public static ValidationRule TagRequiredFields => - new( + new(nameof(TagRequiredFields), (context, tag) => { context.Enter("name"); diff --git a/src/Microsoft.OpenApi/Validations/ValidationRule.cs b/src/Microsoft.OpenApi/Validations/ValidationRule.cs index 48907635d..4f0f00383 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRule.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRule.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. using System; -using System.Globalization; +using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Properties; @@ -18,12 +18,22 @@ public abstract class ValidationRule /// internal abstract Type ElementType { get; } + /// + /// Validation rule Name. + /// + public string Name { get; } + /// /// Validate the object. /// /// The context. /// The object item. internal abstract void Evaluate(IValidationContext context, object item); + + internal ValidationRule(string name) + { + Name = !string.IsNullOrEmpty(name) ? name : throw new ArgumentNullException(nameof(name)); + } } /// @@ -33,14 +43,26 @@ public abstract class ValidationRule public class ValidationRule : ValidationRule where T : IOpenApiElement { private readonly Action _validate; + + /// + /// Initializes a new instance of the class. + /// + /// Action to perform the validation. + [Obsolete("Please use the other constructor and specify a name")] + public ValidationRule(Action validate) + : this (Guid.NewGuid().ToString("D"), validate) + { + } /// /// Initializes a new instance of the class. /// + /// Validation rule name. /// Action to perform the validation. - public ValidationRule(Action validate) + public ValidationRule(string name, Action validate) + : base(name) { - _validate = Utils.CheckArgumentNull(validate); + _validate = Utils.CheckArgumentNull(validate); } internal override Type ElementType diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs index a5c6fee83..3dd916755 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs @@ -134,6 +134,30 @@ public void Add(ValidationRule rule) item.Add(rule); } + /// + /// Remove a rule by its name from all types it is used by. + /// + /// Name of the rule. + public void Remove(string ruleName) + { + foreach (KeyValuePair> rule in _rules) + { + _rules[rule.Key] = rule.Value.Where(vr => !vr.Name.Equals(ruleName, StringComparison.Ordinal)).ToList(); + } + + // Remove types with no rule + _rules = _rules.Where(r => r.Value.Any()).ToDictionary(r => r.Key, r => r.Value); + } + + /// + /// Remove a rule by element type. + /// + /// Type of the rule. + public void Remove(Type type) + { + _rules.Remove(type); + } + /// /// Get the enumerator. /// diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index a5309e46d..e0abf365a 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1347,7 +1347,7 @@ namespace Microsoft.OpenApi.Validations } public abstract class ValidationRule { - protected ValidationRule() { } + public string Name { get; } } public sealed class ValidationRuleSet : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { @@ -1358,13 +1358,17 @@ namespace Microsoft.OpenApi.Validations public void Add(Microsoft.OpenApi.Validations.ValidationRule rule) { } public System.Collections.Generic.IList FindRules(System.Type type) { } public System.Collections.Generic.IEnumerator GetEnumerator() { } + public void Remove(string ruleName) { } + public void Remove(System.Type type) { } public static Microsoft.OpenApi.Validations.ValidationRuleSet GetDefaultRuleSet() { } public static Microsoft.OpenApi.Validations.ValidationRuleSet GetEmptyRuleSet() { } } public class ValidationRule : Microsoft.OpenApi.Validations.ValidationRule where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { + [System.Obsolete("Please use the other constructor and specify a name")] public ValidationRule(System.Action validate) { } + public ValidationRule(string name, System.Action validate) { } } } namespace Microsoft.OpenApi.Validations.Rules diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs index 02eba9347..d027f40b8 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using FluentAssertions; +using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; @@ -96,7 +97,7 @@ public void ValidateCustomExtension() var ruleset = ValidationRuleSet.GetDefaultRuleSet(); ruleset.Add( - new ValidationRule( + new ValidationRule("FooExtensionRule", (context, item) => { if (item.Bar == "hey") @@ -133,6 +134,44 @@ public void ValidateCustomExtension() new OpenApiValidatorError("FooExtensionRule", "#/info/x-foo", "Don't say hey") }); } + + [Fact] + public void RemoveRuleByName_Invalid() + { + Assert.Throws(() => new ValidationRule(null, (vc, oaa) => { })); + Assert.Throws(() => new ValidationRule(string.Empty, (vc, oaa) => { })); + } + + [Fact] + public void RemoveRuleByName() + { + var ruleset = ValidationRuleSet.GetDefaultRuleSet(); + int expected = ruleset.Rules.Count - 1; + ruleset.Remove("KeyMustBeRegularExpression"); + + Assert.Equal(expected, ruleset.Rules.Count); + + ruleset.Remove("KeyMustBeRegularExpression"); + ruleset.Remove("UnknownName"); + + Assert.Equal(expected, ruleset.Rules.Count); + } + + [Fact] + public void RemoveRuleByType() + { + var ruleset = ValidationRuleSet.GetDefaultRuleSet(); + int expected = ruleset.Rules.Count - 1; + + ruleset.Remove(typeof(OpenApiComponents)); + + Assert.Equal(expected, ruleset.Rules.Count); + + ruleset.Remove(typeof(OpenApiComponents)); + ruleset.Remove(typeof(int)); + + Assert.Equal(expected, ruleset.Rules.Count); + } } internal class FooExtension : IOpenApiExtension, IOpenApiElement diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs index 4c252716f..11e5edc9e 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs @@ -152,7 +152,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() public class AlwaysFailRule : ValidationRule where T : IOpenApiElement { - public AlwaysFailRule() : base((c, _) => c.CreateError("x", "y")) + public AlwaysFailRule() : base("AlwaysFailRule", (c, _) => c.CreateError("x", "y")) { } } From 7c17a099e276fb90a03f9791b140906966b15d5d Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 25 Jan 2024 13:03:03 +0300 Subject: [PATCH 051/110] Refactor the LoadExtensions method for reuse --- .../V2/OpenApiParameterDeserializer.cs | 15 +++++++++++++-- .../V2/OpenApiResponseDeserializer.cs | 17 ++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs index f74600e66..f9bdda48e 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -95,12 +95,17 @@ internal static partial class OpenApiV2Deserializer "schema", (o, n) => o.Schema = LoadSchema(n) }, + { + "x-examples", + LoadParameterExamplesExtension + }, }; private static readonly PatternFieldMap _parameterPatternFields = new() { - {s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} + {s => s.StartsWith("x-") && !s.Equals(OpenApiConstants.ExamplesExtension, StringComparison.OrdinalIgnoreCase), + (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} }; private static readonly AnyFieldMap _parameterAnyFields = @@ -166,6 +171,12 @@ private static void LoadStyle(OpenApiParameter p, string v) } } + private static void LoadParameterExamplesExtension(OpenApiParameter parameter, ParseNode node) + { + var examples = LoadExamplesExtension(node); + node.Context.SetTempStorage(TempStorageKeys.Examples, examples, parameter); + } + private static OpenApiSchema GetOrCreateSchema(OpenApiParameter p) { if (p.Schema == null) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs index b624f1b3a..03691d14b 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs @@ -31,7 +31,7 @@ internal static partial class OpenApiV2Deserializer }, { "x-examples", - LoadExamplesExtension + LoadResponseExamplesExtension }, { "schema", @@ -42,7 +42,8 @@ internal static partial class OpenApiV2Deserializer private static readonly PatternFieldMap _responsePatternFields = new() { - {s => s.StartsWith("x-") && !s.Equals(OpenApiConstants.ExamplesExtension, StringComparison.OrdinalIgnoreCase), (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} + {s => s.StartsWith("x-") && !s.Equals(OpenApiConstants.ExamplesExtension, StringComparison.OrdinalIgnoreCase), + (o, p, n) => o.AddExtension(p, LoadExtension(p, n))} }; private static readonly AnyFieldMap _mediaTypeAnyFields = @@ -104,7 +105,13 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P context.SetTempStorage(TempStorageKeys.ResponseProducesSet, true, response); } - private static void LoadExamplesExtension(OpenApiResponse response, ParseNode node) + private static void LoadResponseExamplesExtension(OpenApiResponse response, ParseNode node) + { + var examples = LoadExamplesExtension(node); + node.Context.SetTempStorage(TempStorageKeys.Examples, examples, response); + } + + private static Dictionary LoadExamplesExtension(ParseNode node) { var mapNode = node.CheckMapNode(OpenApiConstants.ExamplesExtension); var examples = new Dictionary(); @@ -131,12 +138,12 @@ private static void LoadExamplesExtension(OpenApiResponse response, ParseNode no example.ExternalValue = valueNode.Value.GetScalarValue(); break; } - } + } examples.Add(examplesNode.Name, example); } - node.Context.SetTempStorage(TempStorageKeys.Examples, examples, response); + return examples; } private static void LoadExamples(OpenApiResponse response, ParseNode node) From 37c097e358e2aff66b5451f57807ac8e8a11fa87 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 25 Jan 2024 13:03:51 +0300 Subject: [PATCH 052/110] Fetch the examples from storage and append them to the resulting body parameter object --- .../V2/OpenApiOperationDeserializer.cs | 4 +++- .../V2/OpenApiParameterDeserializer.cs | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs index f47ca1c6c..fa91f913a 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Security.Cryptography.X509Certificates; +using System.Xml.Linq; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; @@ -194,7 +195,8 @@ internal static OpenApiRequestBody CreateRequestBody( k => k, _ => new OpenApiMediaType { - Schema = bodyParameter.Schema + Schema = bodyParameter.Schema, + Examples = bodyParameter.Examples }), Extensions = bodyParameter.Extensions }; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs index f9bdda48e..a7d9f93d4 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -261,6 +261,14 @@ public static OpenApiParameter LoadParameter(ParseNode node, bool loadRequestBod node.Context.SetTempStorage("schema", null); } + // load examples from storage and add them to the parameter + var examples = node.Context.GetFromTempStorage>(TempStorageKeys.Examples, parameter); + if (examples != null) + { + parameter.Examples = examples; + node.Context.SetTempStorage("examples", null); + } + var isBodyOrFormData = (bool)node.Context.GetFromTempStorage(TempStorageKeys.ParameterIsBodyOrFormData); if (isBodyOrFormData && !loadRequestBody) { From 73cb87e053aa06042dcc1b5614e2c34dbb5f2847 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 25 Jan 2024 13:04:07 +0300 Subject: [PATCH 053/110] Revert change --- src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index 7fa58be5f..5e5edc576 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -150,7 +150,7 @@ internal OpenApiBodyParameter ConvertToBodyParameter() Required = Required, Extensions = Extensions.ToDictionary(static k => k.Key, static v => v.Value) // Clone extensions so we can remove the x-bodyName extensions from the output V2 model. }; - if (bodyParameter.Extensions.TryGetValue(OpenApiConstants.BodyName, out var bodyParameterName)) + if (bodyParameter.Extensions.ContainsKey(OpenApiConstants.BodyName)) { bodyParameter.Name = (Extensions[OpenApiConstants.BodyName] as OpenApiString)?.Value ?? "body"; bodyParameter.Extensions.Remove(OpenApiConstants.BodyName); From c8a4a00a7150347483c6e52068a81e3e5f9dcff7 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 25 Jan 2024 13:05:32 +0300 Subject: [PATCH 054/110] Add tests to validate processing multiple examples in a body parameter as extensions --- .../V2Tests/OpenApiOperationTests.cs | 103 ++++++++++++++++++ .../opWithBodyParameterExamples.yaml | 29 +++++ .../v3OperationWithBodyParameterExamples.yaml | 27 +++++ 3 files changed, 159 insertions(+) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/opWithBodyParameterExamples.yaml create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/v3OperationWithBodyParameterExamples.yaml diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index fbf157b4c..86d22f8a5 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -536,5 +536,108 @@ public void LoadV3ExamplesInResponseAsExtensionsWorks() expected = expected.MakeLineBreaksEnvironmentNeutral(); actual.Should().Be(expected); } + + [Fact] + public void LoadV2OperationWithBodyParameterExamplesWorks() + { + // Arrange + MapNode node; + using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "opWithBodyParameterExamples.yaml"))) + { + node = TestHelper.CreateYamlMapNode(stream); + } + + // Act + var operation = OpenApiV2Deserializer.LoadOperation(node); + var actual = operation.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); + + // Assert + var expected = @"summary: Get all pets +requestBody: + content: + application/json: + schema: + type: array + items: + type: object + properties: + name: + type: string + age: + type: integer + examples: + example1: + summary: Example - List of Pets + value: + - name: Buddy + age: 2 + - name: Whiskers + age: 1 + example2: + summary: Example - Playful Cat + value: + name: Whiskers + age: 1 + required: true + x-bodyName: body +responses: { }"; + + // Assert + actual = actual.MakeLineBreaksEnvironmentNeutral(); + expected = expected.MakeLineBreaksEnvironmentNeutral(); + actual.Should().Be(expected); + } + + [Fact] + public void LoadV3ExamplesInRequestBodyParameterAsExtensionsWorks() + { + // Arrange + MapNode node; + using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "v3OperationWithBodyParameterExamples.yaml"))) + { + node = TestHelper.CreateYamlMapNode(stream); + } + + // Act + var operation = OpenApiV3Deserializer.LoadOperation(node); + var actual = operation.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0); + + // Assert + var expected = @"summary: Get all pets +consumes: + - application/json +parameters: + - in: body + name: body + required: true + schema: + type: array + items: + type: object + properties: + name: + type: string + age: + type: integer + x-examples: + example1: + summary: Example - List of Pets + value: + - name: Buddy + age: 2 + - name: Whiskers + age: 1 + example2: + summary: Example - Playful Cat + value: + name: Whiskers + age: 1 +responses: { }"; + + // Assert + actual = actual.MakeLineBreaksEnvironmentNeutral(); + expected = expected.MakeLineBreaksEnvironmentNeutral(); + actual.Should().Be(expected); + } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/opWithBodyParameterExamples.yaml b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/opWithBodyParameterExamples.yaml new file mode 100644 index 000000000..e2ffcc7df --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/opWithBodyParameterExamples.yaml @@ -0,0 +1,29 @@ +summary: Get all pets +consumes: + - application/json +parameters: + - in: body + name: body + required: true + schema: + type: array + items: + type: object + properties: + name: + type: string + age: + type: integer + x-examples: + example1: + summary: Example - List of Pets + value: + - name: Buddy + age: 2 + - name: Whiskers + age: 1 + example2: + summary: Example - Playful Cat + value: + name: Whiskers + age: 1 \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/v3OperationWithBodyParameterExamples.yaml b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/v3OperationWithBodyParameterExamples.yaml new file mode 100644 index 000000000..a0358125a --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/Samples/OpenApiOperation/v3OperationWithBodyParameterExamples.yaml @@ -0,0 +1,27 @@ +summary: Get all pets +requestBody: + required: true + content: + application/json: + schema: + type: array + items: + type: object + properties: + name: + type: string + age: + type: integer + examples: + example1: + summary: Example - List of Pets + value: + - name: "Buddy" + age: 2 + - name: "Whiskers" + age: 1 + example2: + summary: Example - Playful Cat + value: + name: "Whiskers" + age: 1 \ No newline at end of file From e3e8fc73e1d99e979b6fac7af60ef4d36a708436 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 25 Jan 2024 15:15:30 +0300 Subject: [PATCH 055/110] Refactor code for reuse --- src/Microsoft.OpenApi/Models/OpenApiExample.cs | 12 +++++++++++- src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiResponse.cs | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index d70bab01d..1b9d31022 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs @@ -118,6 +118,16 @@ public OpenApiExample GetEffective(OpenApiDocument doc) /// Serialize to OpenAPI V3 document without using reference. /// public void SerializeAsV3WithoutReference(IOpenApiWriter writer) + { + Serialize(writer, OpenApiSpecVersion.OpenApi3_0); + } + + /// + /// Writes out existing examples in a mediatype object + /// + /// + /// + public void Serialize(IOpenApiWriter writer, OpenApiSpecVersion version) { writer.WriteStartObject(); @@ -134,7 +144,7 @@ public void SerializeAsV3WithoutReference(IOpenApiWriter writer) writer.WriteProperty(OpenApiConstants.ExternalValue, ExternalValue); // extensions - writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0); + writer.WriteExtensions(Extensions, version); writer.WriteEndObject(); } diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 6608025a9..fc1eaf8cc 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -397,7 +397,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) foreach (var example in Examples) { writer.WritePropertyName(example.Key); - writer.WriteV2Examples(writer, example.Value, OpenApiSpecVersion.OpenApi2_0); + example.Value.Serialize(writer, OpenApiSpecVersion.OpenApi2_0); } writer.WriteEndObject(); } diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index 369f09761..e300cd33d 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -204,7 +204,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) .SelectMany(mediaTypePair => mediaTypePair.Value.Examples)) { writer.WritePropertyName(example.Key); - writer.WriteV2Examples(writer, example.Value, OpenApiSpecVersion.OpenApi2_0); + example.Value.Serialize(writer, OpenApiSpecVersion.OpenApi2_0); } writer.WriteEndObject(); From fa9306ff720d04d214ba0e3bb194fabeb1fdee39 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 25 Jan 2024 15:16:13 +0300 Subject: [PATCH 056/110] Remove method from interface to prevent a breaking change --- .../Writers/IOpenApiWriter.cs | 12 +--------- .../Writers/OpenApiWriterBase.cs | 24 ------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs b/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs index d40643bfc..9ea04b400 100644 --- a/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs +++ b/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs @@ -1,8 +1,6 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using Microsoft.OpenApi.Models; - namespace Microsoft.OpenApi.Writers { /// @@ -74,13 +72,5 @@ public interface IOpenApiWriter /// Flush the writer. /// void Flush(); - - /// - /// Writes out existing examples in a mediatype object - /// - /// - /// - /// - void WriteV2Examples(IOpenApiWriter writer, OpenApiExample example, OpenApiSpecVersion version); } } diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs index 1edab6392..5254288f3 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IO; using Microsoft.OpenApi.Exceptions; -using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; namespace Microsoft.OpenApi.Writers @@ -406,28 +405,5 @@ protected void VerifyCanWritePropertyName(string name) string.Format(SRResource.ObjectScopeNeededForPropertyNameWriting, name)); } } - - /// - public void WriteV2Examples(IOpenApiWriter writer, OpenApiExample example, OpenApiSpecVersion version) - { - writer.WriteStartObject(); - - // summary - writer.WriteProperty(OpenApiConstants.Summary, example.Summary); - - // description - writer.WriteProperty(OpenApiConstants.Description, example.Description); - - // value - writer.WriteOptionalObject(OpenApiConstants.Value, example.Value, (w, v) => w.WriteAny(v)); - - // externalValue - writer.WriteProperty(OpenApiConstants.ExternalValue, example.ExternalValue); - - // extensions - writer.WriteExtensions(example.Extensions, version); - - writer.WriteEndObject(); - } } } From 7882fdde69e60e9073eab23db3363d09e440f9b6 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 25 Jan 2024 15:16:27 +0300 Subject: [PATCH 057/110] Update public API interface --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 256832e42..701d74741 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -643,6 +643,7 @@ namespace Microsoft.OpenApi.Models public bool UnresolvedReference { get; set; } public Microsoft.OpenApi.Any.IOpenApiAny Value { get; set; } public Microsoft.OpenApi.Models.OpenApiExample GetEffective(Microsoft.OpenApi.Models.OpenApiDocument doc) { } + public void Serialize(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion version) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1487,7 +1488,6 @@ namespace Microsoft.OpenApi.Writers void WriteRaw(string value); void WriteStartArray(); void WriteStartObject(); - void WriteV2Examples(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.Models.OpenApiExample example, Microsoft.OpenApi.OpenApiSpecVersion version); void WriteValue(bool value); void WriteValue(decimal value); void WriteValue(int value); @@ -1549,7 +1549,6 @@ namespace Microsoft.OpenApi.Writers public abstract void WriteRaw(string value); public abstract void WriteStartArray(); public abstract void WriteStartObject(); - public void WriteV2Examples(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.Models.OpenApiExample example, Microsoft.OpenApi.OpenApiSpecVersion version) { } public virtual void WriteValue(bool value) { } public virtual void WriteValue(System.DateTime value) { } public virtual void WriteValue(System.DateTimeOffset value) { } From 7fd69b92c2be5f689a3b93460a7e51f3b715c72e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 21:43:51 +0000 Subject: [PATCH 058/110] Bump Microsoft.OpenApi.OData from 1.6.0-preview.3 to 1.6.0-preview.4 Bumps [Microsoft.OpenApi.OData](https://github.com/Microsoft/OpenAPI.NET.OData) from 1.6.0-preview.3 to 1.6.0-preview.4. - [Release notes](https://github.com/Microsoft/OpenAPI.NET.OData/releases) - [Commits](https://github.com/Microsoft/OpenAPI.NET.OData/commits) --- updated-dependencies: - dependency-name: Microsoft.OpenApi.OData dependency-type: direct:production update-type: version-update:semver-patch ... 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 505d50ef8..6b038a298 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -35,7 +35,7 @@ - + From b277208b65e84d47031866c8ccaa2d62cbcd3fd9 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 29 Jan 2024 11:08:15 +0300 Subject: [PATCH 059/110] Bump lib versions --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ++-- .../Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 6b038a298..70e04e54b 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -1,4 +1,4 @@ - + Exe @@ -9,7 +9,7 @@ enable hidi ./../../artifacts - 1.3.7 + 1.3.8 OpenAPI.NET CLI tool for slicing OpenAPI documents true diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 160253eee..c36efb50f 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -3,7 +3,7 @@ netstandard2.0 latest true - 1.6.12 + 1.6.13 OpenAPI.NET Readers for JSON and YAML documents true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index b59136dd0..8f17fae72 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -3,7 +3,7 @@ netstandard2.0 Latest true - 1.6.12 + 1.6.13 .NET models with JSON and YAML writers for OpenAPI specification true From e82576acdbb0eb2aa82d5f2e71dc1b4b732e9f35 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 21:04:53 +0000 Subject: [PATCH 060/110] Bump Microsoft.OpenApi.OData from 1.6.0-preview.4 to 1.6.0-preview.5 Bumps [Microsoft.OpenApi.OData](https://github.com/Microsoft/OpenAPI.NET.OData) from 1.6.0-preview.4 to 1.6.0-preview.5. - [Release notes](https://github.com/Microsoft/OpenAPI.NET.OData/releases) - [Commits](https://github.com/Microsoft/OpenAPI.NET.OData/commits) --- updated-dependencies: - dependency-name: Microsoft.OpenApi.OData dependency-type: direct:production update-type: version-update:semver-patch ... 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 70e04e54b..175daa3f7 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -35,7 +35,7 @@ - + From ca777514f728fd8cceae9aca2a93bf14c58b187b Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 5 Feb 2024 16:36:13 +0300 Subject: [PATCH 061/110] Update readme.md --- src/Microsoft.OpenApi.Hidi/readme.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/readme.md b/src/Microsoft.OpenApi.Hidi/readme.md index 111ee704b..faa2c2244 100644 --- a/src/Microsoft.OpenApi.Hidi/readme.md +++ b/src/Microsoft.OpenApi.Hidi/readme.md @@ -68,24 +68,28 @@ Used to convert file formats from JSON to YAML and vice versa and performs slici This command accepts the following parameters: • --openapi(-d) - OpenAPI description file path in the local filesystem or a valid URL hosted on a HTTPS server - • --csdl(-cs) - CSDL file path in the local filesystem or a valid URL hosted on a HTTPS server - • --csdlfilter(-csf) - a filter parameter that a user can use to select a subset of a large CSDL file. They do so by providing a comma delimited list of EntitySet and Singleton names that appear in the EntityContainer. - • --output(-o) - Output directory path for the transformed document - • --clean-ouput(-co) - an optional param that allows a user to overwrite an existing file. - • --version(-v) - OpenAPI specification version + • --csdl(--cs) - CSDL file path in the local filesystem or a valid URL hosted on a HTTPS server + • --csdlfilter(--csf) - a filter parameter that a user can use to select a subset of a large CSDL file. They do so by providing a comma delimited list of EntitySet and Singleton names that appear in the EntityContainer. + • --output(-o) - Output directory path for the transformed document. + • --output-folder(--of) - The output directory path for the generated files. + • --clean-ouput(--co) - an optional param that allows a user to overwrite an existing file. + • --version(-v) - OpenAPI specification version. + • --metadata-version(--mv) - Graph metadata version to use. • --format(-f) - File format - • --loglevel(-ll) - The log level to use when logging messages to the main output - • --inline(-i) - Inline $ref instances - • --resolveExternal(-ex) - Resolve external $refs - • --filterByOperationIds(-op) - Slice document based on OperationId(s) provided. Accepts a comma delimited list of operation ids. + • --terse-output(--to) - Produce terse json output + • --settings-path(--sp) - The configuration file with CSDL conversion settings. + • --loglevel(--ll) - The log level to use when logging messages to the main output + • --inline-local - Inline local $ref instances + • --inline-external(--ex) - Inline external $refs + • --filterByOperationIds(--op) - Slice document based on OperationId(s) provided. Accepts a comma delimited list of operation ids. • --filterByTags(-t) - Slice document based on tag(s) provided. Accepts a comma delimited list of tags. • --filterByCollection(-c) - Slices the OpenAPI document based on the Postman Collection file generated by Resource Explorer - • --filterByManifest (-m) - Slices the OpenAPI document based on the requests defined in the API Manifest file referenced by the provided URI. For API manifests with multiple API Dependenties, use a fragment identifier to select the desired one. e.g ./apimanifest.json#example + • --manifest (-m) - Slices the OpenAPI document based on the requests defined in the API Manifest file referenced by the provided URI. For API manifests with multiple API Dependenties, use a fragment identifier to select the desired one. e.g ./apimanifest.json#example **Examples:** 1. Filtering by OperationIds - hidi transform -d files\People.yml -f yaml -o files\People.yml -v OpenApi3_0 -op users_UpdateInsights -co + hidi transform -d files\People.yml -f yaml -o files\People.yml -v OpenApi3_0 --op users_UpdateInsights --co 2. Filtering by Postman collection hidi transform --openapi files\People.yml --format yaml --output files\People2.yml --version OpenApi3_0 --filterByCollection Graph-Collection-0017059134807617005.postman_collection.json @@ -94,7 +98,7 @@ This command accepts the following parameters: hidi transform --input Files/Todo.xml --output Files/Todo-subset.yml --format yaml --version OpenApi3_0 --filterByOperationIds Todos.Todo.UpdateTodo 4. CSDL Filtering by EntitySets and Singletons - hidi transform -cs dataverse.csdl --csdlFilter "appointments,opportunities" -o appointmentsAndOpportunities.yaml -ll trace + hidi transform --cs dataverse.csdl --csdlFilter "appointments,opportunities" -o appointmentsAndOpportunities.yaml --ll trace Run transform -h to see all the available usage options. From 001f1a0b50693bd9c6e3ba7c2d0d9429bea0c21b Mon Sep 17 00:00:00 2001 From: Irvine Sunday <40403681+irvinesunday@users.noreply.github.com> Date: Mon, 5 Feb 2024 23:43:15 +0300 Subject: [PATCH 062/110] Bump conversion lib. (#1548) * Bump up OData lib. * Bump up hidi --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 175daa3f7..3d9f435ea 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -9,7 +9,7 @@ enable hidi ./../../artifacts - 1.3.8 + 1.3.9 OpenAPI.NET CLI tool for slicing OpenAPI documents true @@ -35,7 +35,7 @@ - + From fccda23ae6d946ea525483960672407cd8e621c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 21:35:07 +0000 Subject: [PATCH 063/110] Bump Verify.Xunit from 23.0.1 to 23.1.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.0.1 to 23.1.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/23.0.1...23.1.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 6f68a8cee..4f6f96232 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From b195c6a64e99bf675fab5afb98ea7fd0811fa041 Mon Sep 17 00:00:00 2001 From: Irvine Sunday <40403681+irvinesunday@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:57:58 +0300 Subject: [PATCH 064/110] Add missing codeql permissions (#1551) --- .github/workflows/codeql-analysis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d9bedc14d..c3b9424f6 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -7,6 +7,11 @@ on: schedule: - cron: '0 8 * * *' +permissions: + contents: read # these permissions are required to run the codeql analysis + actions: read + security-events: write + jobs: analyze: name: CodeQL Analysis From ebfc2baae3fd08d73214b40430497cf327a08f32 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 21:08:50 +0000 Subject: [PATCH 065/110] Bump Microsoft.NET.Test.Sdk from 17.8.0 to 17.9.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.8.0 to 17.9.0. - [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.8.0...v17.9.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk 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 a22b6a7da..fb9e6d148 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -12,7 +12,7 @@ - + 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 0bf7fcc3e..8d6836d74 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 9d61bcab3..7e01b2cb3 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -10,7 +10,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 4f6f96232..563d0edbb 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -11,7 +11,7 @@ - + From 3c987ad8aa7b0d816a7b9be37348505319b9ad16 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 7 Feb 2024 10:36:00 +0300 Subject: [PATCH 066/110] Update command option description --- src/Microsoft.OpenApi.Hidi/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/readme.md b/src/Microsoft.OpenApi.Hidi/readme.md index faa2c2244..8e89e2a87 100644 --- a/src/Microsoft.OpenApi.Hidi/readme.md +++ b/src/Microsoft.OpenApi.Hidi/readme.md @@ -74,7 +74,7 @@ This command accepts the following parameters: • --output-folder(--of) - The output directory path for the generated files. • --clean-ouput(--co) - an optional param that allows a user to overwrite an existing file. • --version(-v) - OpenAPI specification version. - • --metadata-version(--mv) - Graph metadata version to use. + • --metadata-version(--mv) - the metadata version to use. • --format(-f) - File format • --terse-output(--to) - Produce terse json output • --settings-path(--sp) - The configuration file with CSDL conversion settings. From 58cfb225f402282ed6bc0758cacbd68c3294b181 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 21:51:34 +0000 Subject: [PATCH 067/110] Bump SharpYaml from 2.1.0 to 2.1.1 Bumps [SharpYaml](https://github.com/xoofx/SharpYaml) from 2.1.0 to 2.1.1. - [Release notes](https://github.com/xoofx/SharpYaml/releases) - [Changelog](https://github.com/xoofx/SharpYaml/blob/master/changelog.md) - [Commits](https://github.com/xoofx/SharpYaml/compare/2.1.0...2.1.1) --- updated-dependencies: - dependency-name: SharpYaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 8d6836d74..30d34ca57 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -20,7 +20,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 563d0edbb..b1a66f558 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -14,7 +14,7 @@ - + From e3c387ce32eb125adc1c24e5598d77a291d0082a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 21:52:31 +0000 Subject: [PATCH 068/110] Bump Microsoft.Windows.Compatibility from 8.0.1 to 8.0.2 Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/windowsdesktop) from 8.0.1 to 8.0.2. - [Release notes](https://github.com/dotnet/windowsdesktop/releases) - [Commits](https://github.com/dotnet/windowsdesktop/compare/v8.0.1...v8.0.2) --- 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 e6c4dd486..0357b9747 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -9,7 +9,7 @@ - + From c66ea77125dad751a24c3347f50a49796b4e6523 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:09:34 +0000 Subject: [PATCH 069/110] Bump Verify.Xunit from 23.1.0 to 23.2.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.1.0 to 23.2.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/23.1.0...23.2.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 b1a66f558..f2f738a91 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From cac62203a346e47d6512454fa19cd8201dbd81d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 21:15:04 +0000 Subject: [PATCH 070/110] Bump xunit.runner.visualstudio from 2.5.6 to 2.5.7 Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.5.6 to 2.5.7. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/compare/2.5.6...2.5.7) --- updated-dependencies: - dependency-name: xunit.runner.visualstudio dependency-type: direct:production update-type: version-update:semver-patch ... 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 fb9e6d148..99c4b2074 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 @@ - + 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 30d34ca57..c4409a944 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -22,7 +22,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 7e01b2cb3..3ac259f0a 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -13,7 +13,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index f2f738a91..85dc21575 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -17,7 +17,7 @@ - + From 11608ef8a3c5742ad6f4ad614adac958884c32aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 17 Feb 2024 02:03:36 +0000 Subject: [PATCH 071/110] Bump xunit from 2.6.6 to 2.7.0 Bumps [xunit](https://github.com/xunit/xunit) from 2.6.6 to 2.7.0. - [Commits](https://github.com/xunit/xunit/compare/2.6.6...2.7.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 99c4b2074..6a000952a 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -14,7 +14,7 @@ - + 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 c4409a944..4acc551b5 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -21,7 +21,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 3ac259f0a..e6f12a61b 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -12,7 +12,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 85dc21575..5651ad4fb 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -16,7 +16,7 @@ - + From b1d24f0d9f67ec7616aa38b9824d0c30f9f55e6c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:35:31 +0000 Subject: [PATCH 072/110] Bump coverlet.collector from 6.0.0 to 6.0.1 Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.0...v6.0.1) --- updated-dependencies: - dependency-name: coverlet.collector dependency-type: direct:production update-type: version-update:semver-patch ... 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 6a000952a..de8205ed7 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 @@ - + 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 4acc551b5..c0a25cbe8 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -15,7 +15,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index e6f12a61b..adf5402da 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -8,7 +8,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 5651ad4fb..a2da386ba 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -8,7 +8,7 @@ - + From be59a4f6fc5943babefb8322173dfd97957a8d37 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:36:30 +0000 Subject: [PATCH 073/110] Bump Verify.Xunit from 23.2.0 to 23.2.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.2.0 to 23.2.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/23.2.0...23.2.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 5651ad4fb..92317ea99 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 783c1227c3857d91cd00412bdb2c32f3c8e7f7e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:41:39 +0000 Subject: [PATCH 074/110] Bump coverlet.msbuild from 6.0.0 to 6.0.1 Bumps [coverlet.msbuild](https://github.com/coverlet-coverage/coverlet) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.0...v6.0.1) --- updated-dependencies: - dependency-name: coverlet.msbuild dependency-type: direct:production update-type: version-update:semver-patch ... 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 de8205ed7..8789f2769 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -11,7 +11,7 @@ - + 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 c0a25cbe8..1d2bcc376 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -16,7 +16,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index adf5402da..88254243c 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -9,7 +9,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 57c2e4167..0cf18be01 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -9,7 +9,7 @@ - + From 11b71b47a41f600d2fa022064a3e59507e9fb402 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Feb 2024 21:53:47 +0000 Subject: [PATCH 075/110] Bump SharpYaml from 2.1.0 to 2.1.1 Bumps [SharpYaml](https://github.com/xoofx/SharpYaml) from 2.1.0 to 2.1.1. - [Release notes](https://github.com/xoofx/SharpYaml/releases) - [Changelog](https://github.com/xoofx/SharpYaml/blob/master/changelog.md) - [Commits](https://github.com/xoofx/SharpYaml/compare/2.1.0...2.1.1) --- updated-dependencies: - dependency-name: SharpYaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index c36efb50f..a018892d6 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -18,7 +18,7 @@ - + From 942b6ca8df65b737af158698163e736160c523fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Feb 2024 21:54:32 +0000 Subject: [PATCH 076/110] Bump Microsoft.OpenApi.OData from 1.6.0-preview.7 to 1.6.0-preview.8 Bumps [Microsoft.OpenApi.OData](https://github.com/Microsoft/OpenAPI.NET.OData) from 1.6.0-preview.7 to 1.6.0-preview.8. - [Release notes](https://github.com/Microsoft/OpenAPI.NET.OData/releases) - [Commits](https://github.com/Microsoft/OpenAPI.NET.OData/commits) --- updated-dependencies: - dependency-name: Microsoft.OpenApi.OData dependency-type: direct:production update-type: version-update:semver-patch ... 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 3d9f435ea..7e77ff6cd 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -35,7 +35,7 @@ - + From 4f36bc22bd4f5ae24935eaacfe9e1e89b68470a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 21:44:47 +0000 Subject: [PATCH 077/110] Bump Verify.Xunit from 23.2.1 to 23.2.2 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.2.1 to 23.2.2. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits) --- 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 0cf18be01..6301c86ae 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 7709058fad40c5629cd8697ae3b09a254d8ede9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 21:59:08 +0000 Subject: [PATCH 078/110] Bump Microsoft.OpenApi.OData from 1.6.0-preview.8 to 1.6.0-preview.9 Bumps [Microsoft.OpenApi.OData](https://github.com/Microsoft/OpenAPI.NET.OData) from 1.6.0-preview.8 to 1.6.0-preview.9. - [Release notes](https://github.com/Microsoft/OpenAPI.NET.OData/releases) - [Commits](https://github.com/Microsoft/OpenAPI.NET.OData/commits) --- updated-dependencies: - dependency-name: Microsoft.OpenApi.OData dependency-type: direct:production update-type: version-update:semver-patch ... 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 7e77ff6cd..8a194697e 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -35,7 +35,7 @@ - + From 72c9b7d6d158eef8c8d6b4fa6090d3f7e01660a0 Mon Sep 17 00:00:00 2001 From: Irvine Sunday <40403681+irvinesunday@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:52:32 +0300 Subject: [PATCH 079/110] Bump Hidi (#1574) --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 8a194697e..18d066763 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -1,4 +1,4 @@ - + Exe @@ -9,7 +9,7 @@ enable hidi ./../../artifacts - 1.3.9 + 1.3.10 OpenAPI.NET CLI tool for slicing OpenAPI documents true From 43f6d64f6f3503d2aaf715c55c4fe391993aef46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 21:45:52 +0000 Subject: [PATCH 080/110] Bump Microsoft.OpenApi.OData from 1.6.0-preview.9 to 1.6.0-preview.10 Bumps [Microsoft.OpenApi.OData](https://github.com/Microsoft/OpenAPI.NET.OData) from 1.6.0-preview.9 to 1.6.0-preview.10. - [Release notes](https://github.com/Microsoft/OpenAPI.NET.OData/releases) - [Commits](https://github.com/Microsoft/OpenAPI.NET.OData/commits) --- updated-dependencies: - dependency-name: Microsoft.OpenApi.OData dependency-type: direct:production update-type: version-update:semver-patch ... 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 18d066763..fec0ca12e 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -35,7 +35,7 @@ - + From 5cadbb299a11be4269c72aa17ec66bbd53d5f053 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 5 Mar 2024 08:04:36 -0500 Subject: [PATCH 081/110] - upgrades hidi to net 8 Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 4 ++-- .github/workflows/ci-cd.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/sonarcloud.yml | 6 +----- .vscode/launch.json | 4 ++-- Dockerfile | 6 +++--- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 4 ++-- src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs | 3 ++- .../Microsoft.OpenApi.Workbench.csproj | 2 +- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- 11 files changed, 17 insertions(+), 20 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 8b23b8d10..e343ee342 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -36,9 +36,9 @@ stages: version: 6.x - task: UseDotNet@2 - displayName: 'Use .NET 7' + displayName: 'Use .NET 8' inputs: - version: 7.x + version: 8.x - task: PoliCheck@2 displayName: 'Run PoliCheck "/src"' diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index bf1aa6a33..36a449ed4 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -19,7 +19,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Data gatherer id: data_gatherer diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c3b9424f6..22eb5f8fa 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -24,7 +24,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Initialize CodeQL id: init_codeql diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index fbd2629e9..de89669f4 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -39,14 +39,10 @@ jobs: with: distribution: 'adopt' java-version: 17 - - name: Setup .NET 5 # At the moment the scanner requires dotnet 5 https://www.nuget.org/packages/dotnet-sonarscanner - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 5.0.x - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis diff --git a/.vscode/launch.json b/.vscode/launch.json index acf828db0..c8714e62e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net7.0/Microsoft.OpenApi.Hidi.dll", + "program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net8.0/Microsoft.OpenApi.Hidi.dll", "args": ["plugin", "-m","C:\\Users\\darrmi\\src\\github\\microsoft\\openapi.net\\test\\Microsoft.OpenApi.Hidi.Tests\\UtilityFiles\\exampleapimanifest.json", "--of","./output"], @@ -28,7 +28,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/Microsoft.OpenApi.WorkBench/bin/Debug/net7.0-windows/Microsoft.OpenApi.Workbench.exe", + "program": "${workspaceFolder}/src/Microsoft.OpenApi.WorkBench/bin/Debug/net8.0-windows/Microsoft.OpenApi.Workbench.exe", "args": [], "cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Workbench", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/Dockerfile b/Dockerfile index e67c8c389..fd821e3e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env WORKDIR /app COPY ./src ./hidi/src @@ -7,10 +7,10 @@ COPY ./README.md ./hidi/README.md WORKDIR /app/hidi RUN dotnet publish ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -c Release -FROM mcr.microsoft.com/dotnet/runtime:7.0 AS runtime +FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy-chiseled AS runtime WORKDIR /app -COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net7.0 ./ +COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net8.0 ./ VOLUME /app/output VOLUME /app/openapi.yml diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index fec0ca12e..a1270f0b3 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 latest true true diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index a8740f91a..f33fc61da 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -272,7 +272,7 @@ private static async Task GetOpenApi(HidiOptions options, ILogg predicate = OpenApiFilterService.CreatePredicate(tags: filterByTags); } - if (requestUrls.Any()) + if (requestUrls.Count > 0) { logger.LogTrace("Creating predicate based on the paths and Http methods defined in the Postman collection."); predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: document); @@ -307,7 +307,7 @@ private static XslCompiledTransform GetFilterTransform() return transform; } - private static Stream ApplyFilterToCsdl(Stream csdlStream, string entitySetOrSingleton, XslCompiledTransform transform) + private static MemoryStream ApplyFilterToCsdl(Stream csdlStream, string entitySetOrSingleton, XslCompiledTransform transform) { using StreamReader inputReader = new(csdlStream, leaveOpen: true); using var inputXmlReader = XmlReader.Create(inputReader); diff --git a/src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs b/src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs index f6798287a..2b2e8bfc5 100644 --- a/src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs +++ b/src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.IO; using Microsoft.Extensions.Configuration; using Microsoft.OpenApi.OData; @@ -27,7 +28,7 @@ internal static IConfiguration GetConfiguration(string? settingsFile = null) internal static OpenApiConvertSettings GetOpenApiConvertSettings(IConfiguration config, string? metadataVersion) { - if (config == null) { throw new System.ArgumentNullException(nameof(config)); } + ArgumentNullException.ThrowIfNull(config); var settings = new OpenApiConvertSettings(); if (!string.IsNullOrEmpty(metadataVersion)) settings.SemVerVersion = metadataVersion; diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 0357b9747..5eb5e3ae0 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -1,6 +1,6 @@ - net7.0-windows + net8.0-windows WinExe false true 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 8789f2769..d0cdadb50 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable enable From 77f239481baa666ac7c464762e16b7206be763f5 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 5 Mar 2024 08:05:17 -0500 Subject: [PATCH 082/110] - bumps hidi patch version Signed-off-by: Vincent Biret --- 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 a1270f0b3..18267295c 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -9,7 +9,7 @@ enable hidi ./../../artifacts - 1.3.10 + 1.4.0 OpenAPI.NET CLI tool for slicing OpenAPI documents true From 354c204fa0852d42161417c364dc40f3ca23fda4 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 5 Mar 2024 08:09:33 -0500 Subject: [PATCH 083/110] - upgrades missing test projects Signed-off-by: Vincent Biret --- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.SmokeTests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 1d2bcc376..edd070a14 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -1,6 +1,6 @@ - net7.0 + net8.0 false true ..\..\src\Microsoft.OpenApi.snk diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 88254243c..9387db7df 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 6301c86ae..4eb10d0c8 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -1,6 +1,6 @@ - net7.0 + net8.0 false true Library From 9a47cb2198e2c433f7c4842fa1421c3cb90950c3 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 6 Mar 2024 12:53:50 +0300 Subject: [PATCH 084/110] Pass the leave open setting to the StreamReader constructor to prevent the stream from getting disposed if asked to leave open --- src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs index e96aa4b12..d1515bc56 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs @@ -73,7 +73,7 @@ public async Task ReadAsync(Stream input, CancellationToken cancella bufferedStream.Position = 0; } - using var reader = new StreamReader(bufferedStream); + using var reader = new StreamReader(bufferedStream, default, true, -1, leaveOpen: _settings.LeaveStreamOpen); return await new OpenApiTextReaderReader(_settings).ReadAsync(reader, cancellationToken); } From 9de2aecdd7f7315c29dc2c9b54fba5211bdfc326 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 6 Mar 2024 12:54:05 +0300 Subject: [PATCH 085/110] Add test to validate --- .../OpenApiStreamReaderTests.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs index 91e271549..d3b19eff1 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs @@ -27,5 +27,21 @@ public void StreamShouldNotCloseIfLeaveStreamOpenSettingEqualsTrue() reader.Read(stream, out _); Assert.True(stream.CanRead); } + + [Fact] + public async void StreamShouldNotBeDisposedIfLeaveStreamOpenSettingIsTrue() + { + var memoryStream = new MemoryStream(); + using var fileStream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml")); + + await fileStream.CopyToAsync(memoryStream); + memoryStream.Position = 0; + var stream = memoryStream; + + var reader = new OpenApiStreamReader(new() { LeaveStreamOpen = true }); + _ = await reader.ReadAsync(stream); + stream.Seek(0, SeekOrigin.Begin); // does not throw an object disposed exception + Assert.True(stream.CanRead); + } } } From 9036a21eb1a079b583f0aeeacc906db1c58b5330 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 6 Mar 2024 13:00:48 +0300 Subject: [PATCH 086/110] Remove unnecessary param name --- src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs index d1515bc56..ae01833fb 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs @@ -73,7 +73,7 @@ public async Task ReadAsync(Stream input, CancellationToken cancella bufferedStream.Position = 0; } - using var reader = new StreamReader(bufferedStream, default, true, -1, leaveOpen: _settings.LeaveStreamOpen); + using var reader = new StreamReader(bufferedStream, default, true, -1, _settings.LeaveStreamOpen); return await new OpenApiTextReaderReader(_settings).ReadAsync(reader, cancellationToken); } From d763e535092e21656f827d591c7d5ec6c826326c Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 6 Mar 2024 14:20:47 +0300 Subject: [PATCH 087/110] Update the Read and ReadFragment method to be consistent with the change --- src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs index ae01833fb..c9431de98 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs @@ -41,14 +41,8 @@ public OpenApiStreamReader(OpenApiReaderSettings settings = null) /// Instance of newly created OpenApiDocument. public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic) { - var reader = new StreamReader(input); - var result = new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic); - if (!_settings.LeaveStreamOpen) - { - reader.Dispose(); - } - - return result; + using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen); + return new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic); } /// @@ -86,7 +80,7 @@ public async Task ReadAsync(Stream input, CancellationToken cancella /// Instance of newly created OpenApiDocument public T ReadFragment(Stream input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic) where T : IOpenApiReferenceable { - using var reader = new StreamReader(input); + using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen); return new OpenApiTextReaderReader(_settings).ReadFragment(reader, version, out diagnostic); } } From 8f8cd5e1d0e76a38f848452e922c8dd2ae6417a1 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 6 Mar 2024 16:48:58 +0300 Subject: [PATCH 088/110] Release libs --- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index a018892d6..d73767375 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -3,7 +3,7 @@ netstandard2.0 latest true - 1.6.13 + 1.6.14 OpenAPI.NET Readers for JSON and YAML documents true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 8f17fae72..45b707c96 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -3,7 +3,7 @@ netstandard2.0 Latest true - 1.6.13 + 1.6.14 .NET models with JSON and YAML writers for OpenAPI specification true From 274174068f22d217bf52949409a2d32670b93d8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 21:22:01 +0000 Subject: [PATCH 089/110] Bump Verify.Xunit from 23.2.2 to 23.2.3 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.2.2 to 23.2.3. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits/23.2.3) --- 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 4eb10d0c8..6873508d5 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From efe807164bfb4df884c4a39950aec6f548949bcb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Mar 2024 21:20:12 +0000 Subject: [PATCH 090/110] Bump Verify.Xunit from 23.2.3 to 23.3.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.2.3 to 23.3.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/23.2.3...23.3.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 6873508d5..eb512cdaf 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 41febcd03fada49c0b1f197bd1eeacca56b9a1a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 21:02:19 +0000 Subject: [PATCH 091/110] Bump docker/build-push-action from 5.1.0 to 5.2.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5.1.0 to 5.2.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v5.1.0...v5.2.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... 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 6241be83e..176ce2f18 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@v5.1.0 + uses: docker/build-push-action@v5.2.0 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@v5.1.0 + uses: docker/build-push-action@v5.2.0 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }} From c78cbf0eda388ce9f4962a5ec4d970dda0e836a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 21:02:23 +0000 Subject: [PATCH 092/110] Bump mathieudutour/github-tag-action from 6.1 to 6.2 Bumps [mathieudutour/github-tag-action](https://github.com/mathieudutour/github-tag-action) from 6.1 to 6.2. - [Release notes](https://github.com/mathieudutour/github-tag-action/releases) - [Commits](https://github.com/mathieudutour/github-tag-action/compare/v6.1...v6.2) --- updated-dependencies: - dependency-name: mathieudutour/github-tag-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 36a449ed4..01861ee2d 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -52,7 +52,7 @@ jobs: - if: steps.conditionals_handler.outputs.is_default_branch == 'true' name: Bump GH tag id: tag_generator - uses: mathieudutour/github-tag-action@v6.1 + uses: mathieudutour/github-tag-action@v6.2 with: github_token: ${{ secrets.GITHUB_TOKEN }} default_bump: false From 2cb8f0538898dcacff1e369541634ac94d6aa6a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 21:36:34 +0000 Subject: [PATCH 093/110] Bump Verify.Xunit from 23.3.0 to 23.4.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.3.0 to 23.4.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/23.3.0...23.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 eb512cdaf..455fd0632 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From f2b302a518179bb0ea5d80160ba194d97c721701 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:01:02 +0000 Subject: [PATCH 094/110] Bump Microsoft.Windows.Compatibility from 8.0.2 to 8.0.3 Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/windowsdesktop) from 8.0.2 to 8.0.3. - [Release notes](https://github.com/dotnet/windowsdesktop/releases) - [Commits](https://github.com/dotnet/windowsdesktop/compare/v8.0.2...v8.0.3) --- 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 5eb5e3ae0..aa443d89b 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -9,7 +9,7 @@ - + From 30ca593e5b588a9ec73f85db5f9598ad7a956de2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:02:04 +0000 Subject: [PATCH 095/110] Bump Verify.Xunit from 23.4.0 to 23.5.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.4.0 to 23.5.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/23.4.0...23.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 455fd0632..f67c288e0 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From d3d571e7194663fb6c7167b022f1d91de6f5e806 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:02:56 +0000 Subject: [PATCH 096/110] Bump Microsoft.Extensions.Logging.Abstractions from 8.0.0 to 8.0.1 Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) from 8.0.0 to 8.0.1. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v8.0.0...v8.0.1) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Logging.Abstractions dependency-type: direct:production update-type: version-update:semver-patch ... 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 18267295c..b0b7fd2e8 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -30,7 +30,7 @@ - + From b4883eedc07e599f8b6cfd7aeb131b039e9a8f03 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 21:54:50 +0000 Subject: [PATCH 097/110] Bump coverlet.msbuild from 6.0.1 to 6.0.2 Bumps [coverlet.msbuild](https://github.com/coverlet-coverage/coverlet) from 6.0.1 to 6.0.2. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.1...v6.0.2) --- updated-dependencies: - dependency-name: coverlet.msbuild dependency-type: direct:production update-type: version-update:semver-patch ... 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 d0cdadb50..866127241 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -11,7 +11,7 @@ - + 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 edd070a14..5c9633000 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -16,7 +16,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 9387db7df..d47f51fd9 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -9,7 +9,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index f67c288e0..f6b702c41 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -9,7 +9,7 @@ - + From c753a9b5a252e4937a582e87deb59bd196f8d58c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 06:20:50 +0000 Subject: [PATCH 098/110] Bump coverlet.collector from 6.0.1 to 6.0.2 Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 6.0.1 to 6.0.2. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.1...v6.0.2) --- updated-dependencies: - dependency-name: coverlet.collector dependency-type: direct:production update-type: version-update:semver-patch ... 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 866127241..f7cc32948 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 @@ - + 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 5c9633000..c76a9a211 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -15,7 +15,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index d47f51fd9..b878a8faf 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -8,7 +8,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index f6b702c41..1ca8d14a2 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -8,7 +8,7 @@ - + From 041e9e8345c95327c6ffe43953850f59f29c5f18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Mar 2024 21:27:51 +0000 Subject: [PATCH 099/110] Bump Verify.Xunit from 23.5.0 to 23.5.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.5.0 to 23.5.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/23.5.0...23.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 1ca8d14a2..c96bc59bf 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 1b74e110dd2b61678d2c66012e7ac2d5fe071bc9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:28:00 +0000 Subject: [PATCH 100/110] Bump Microsoft.OpenApi.OData from 1.6.0-preview.10 to 1.6.0 Bumps [Microsoft.OpenApi.OData](https://github.com/Microsoft/OpenAPI.NET.OData) from 1.6.0-preview.10 to 1.6.0. - [Release notes](https://github.com/Microsoft/OpenAPI.NET.OData/releases) - [Commits](https://github.com/Microsoft/OpenAPI.NET.OData/commits) --- updated-dependencies: - dependency-name: Microsoft.OpenApi.OData dependency-type: direct:production update-type: version-update:semver-patch ... 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 b0b7fd2e8..f677ff78f 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -35,7 +35,7 @@ - + From 3ae9c5255b63370088cc834a2ffa92ef42ce5da9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:29:26 +0000 Subject: [PATCH 101/110] Bump Verify.Xunit from 23.5.1 to 23.5.2 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.5.1 to 23.5.2. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/23.5.1...23.5.2) --- 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 c96bc59bf..35ece1b8c 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 537af2ef6691666fb2f8b115ff872ee8e1d17906 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:45:30 +0000 Subject: [PATCH 102/110] Bump docker/login-action from 3.0.0 to 3.1.0 Bumps [docker/login-action](https://github.com/docker/login-action) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v3.0.0...v3.1.0) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 176ce2f18..fbfd884e5 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -17,7 +17,7 @@ jobs: - name: Check out the repo uses: actions/checkout@v4 - name: Login to GitHub package feed - uses: docker/login-action@v3.0.0 + uses: docker/login-action@v3.1.0 with: username: ${{ secrets.ACR_USERNAME }} password: ${{ secrets.ACR_PASSWORD }} From ee8027ae0b4f497e09b132e0f19204e80c25419e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:45:34 +0000 Subject: [PATCH 103/110] Bump docker/build-push-action from 5.2.0 to 5.3.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5.2.0 to 5.3.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v5.2.0...v5.3.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... 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 176ce2f18..3767a2200 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@v5.2.0 + uses: docker/build-push-action@v5.3.0 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@v5.2.0 + uses: docker/build-push-action@v5.3.0 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }} From 41d00497e0967cf26abe1365ea6ae72b7f560ded Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 21:43:09 +0000 Subject: [PATCH 104/110] Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0 Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.6.0 to 2.0.0. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.6.0...v2.0.0) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/auto-merge-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge-dependabot.yml b/.github/workflows/auto-merge-dependabot.yml index 6e5953f56..145487dab 100644 --- a/.github/workflows/auto-merge-dependabot.yml +++ b/.github/workflows/auto-merge-dependabot.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v1.6.0 + uses: dependabot/fetch-metadata@v2.0.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" From db6d3b63f327749189b5ddcbd1e89d6775abe01c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 21:31:01 +0000 Subject: [PATCH 105/110] Bump Verify.Xunit from 23.5.2 to 23.6.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 23.5.2 to 23.6.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/23.5.2...23.6.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 35ece1b8c..3ffd26ac2 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 7926dc287fb9ac9e64463e1817e10e6ae1ba83c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 21:10:33 +0000 Subject: [PATCH 106/110] Bump Microsoft.OpenApi.OData from 1.6.0 to 1.6.1 Bumps [Microsoft.OpenApi.OData](https://github.com/Microsoft/OpenAPI.NET.OData) from 1.6.0 to 1.6.1. - [Release notes](https://github.com/Microsoft/OpenAPI.NET.OData/releases) - [Commits](https://github.com/Microsoft/OpenAPI.NET.OData/commits) --- updated-dependencies: - dependency-name: Microsoft.OpenApi.OData dependency-type: direct:production update-type: version-update:semver-patch ... 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 f677ff78f..c92107975 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -35,7 +35,7 @@ - + From 0f5e411db979a8e604610b63301eb8ec84254c13 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 3 Apr 2024 22:50:19 +0300 Subject: [PATCH 107/110] Resolve conflicts and clean up code --- .../Reader/OpenApiModelFactory.cs | 2 +- .../Reader/V2/OpenApiResponseDeserializer.cs | 4 +- .../Validations/OpenApiValidator.cs | 7 +- .../Validations/Rules/JsonSchemaRules.cs | 6 +- .../Validations/ValidationRuleSet.cs | 83 ++++++++---------- .../OpenApiStreamReaderTests.cs | 3 +- .../V2Tests/OpenApiOperationTests.cs | 57 ++++++------- .../V3Tests/OpenApiDocumentTests.cs | 12 ++- .../Services/OpenApiValidatorTests.cs | 25 +++--- .../OpenApiReferenceValidationTests.cs | 11 +-- .../Validations/ValidationRuleSetTests.cs | 85 ++++++++++--------- 11 files changed, 142 insertions(+), 153 deletions(-) diff --git a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs index e2ec7bdc9..d81bedabb 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs @@ -112,7 +112,7 @@ public static async Task LoadAsync(Stream input, string format, Open bufferedStream.Position = 0; } - using var reader = new StreamReader(bufferedStream); + using var reader = new StreamReader(bufferedStream, default, true, -1, settings.LeaveStreamOpen); return await LoadAsync(reader, format, settings, cancellationToken); } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs index f211ded70..ae0afd02e 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -133,7 +133,7 @@ private static Dictionary LoadExamplesExtension(ParseNod example.Description = valueNode.Value.GetScalarValue(); break; case "value": - example.Value = OpenApiAnyConverter.GetSpecificOpenApiAny(valueNode.Value.CreateAny()); + example.Value = valueNode.Value.CreateAny(); break; case "externalValue": example.ExternalValue = valueNode.Value.GetScalarValue(); diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs index db15b9fec..9f9ce91cd 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs @@ -1,3 +1,4 @@ + // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. @@ -293,15 +294,15 @@ private void Validate(object item, Type type) } // Validate unresolved references as references - if (item is IOpenApiReferenceable {UnresolvedReference: true}) + if (item is IOpenApiReferenceable { UnresolvedReference: true }) { type = typeof(IOpenApiReferenceable); } - var rules = _ruleSet.FindRules(type.Name); + var rules = _ruleSet.FindRules(type); foreach (var rule in rules) { - rule.Evaluate(this as IValidationContext, item); + rule.Evaluate(this, item); } } } diff --git a/src/Microsoft.OpenApi/Validations/Rules/JsonSchemaRules.cs b/src/Microsoft.OpenApi/Validations/Rules/JsonSchemaRules.cs index f62998fdd..c362f7334 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/JsonSchemaRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/JsonSchemaRules.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Collections.Generic; @@ -21,7 +21,7 @@ public static class JsonSchemaRules /// Validate the data matches with the given data type. /// public static ValidationRule SchemaMismatchedDataType => - new ValidationRule( + new ValidationRule(nameof(SchemaMismatchedDataType), (context, jsonSchema) => { // default @@ -79,7 +79,7 @@ public static class JsonSchemaRules /// Validates Schema Discriminator /// public static ValidationRule ValidateSchemaDiscriminator => - new ValidationRule( + new ValidationRule(nameof(ValidateSchemaDiscriminator), (context, jsonSchema) => { // discriminator diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs index 444b60d65..e5950c300 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs @@ -1,4 +1,5 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. + +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -8,6 +9,7 @@ using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Properties; using Microsoft.OpenApi.Validations.Rules; +using System.Data; namespace Microsoft.OpenApi.Validations { @@ -16,16 +18,12 @@ namespace Microsoft.OpenApi.Validations /// public sealed class ValidationRuleSet { - private Dictionary> _rulesDictionary = new(); + private Dictionary> _rulesDictionary = new(); private static ValidationRuleSet _defaultRuleSet; private List _emptyRules = new(); - /// - /// Gets the keys in this rule set. - /// - public ICollection Keys => _rulesDictionary.Keys; /// /// Gets the rules in this rule set. @@ -45,13 +43,13 @@ public ValidationRuleSet() } /// - /// Retrieve the rules that are related to a specific key. + /// Retrieve the rules that are related to a specific type /// - /// The key of the rules to search for. - /// Either the rules related to the given key, or an empty list. - public IList FindRules(string key) + /// The type that is to be validated + /// Either the rules related to the type, or an empty list. + public IList FindRules(Type type) { - _rulesDictionary.TryGetValue(key, out var results); + _rulesDictionary.TryGetValue(type, out var results); return results ?? _emptyRules; } @@ -92,7 +90,7 @@ public static ValidationRuleSet GetEmptyRuleSet() /// The rule set to add validation rules to. /// The validation rules to be added to the rules set. /// Throws a null argument exception if the arguments are null. - public static void AddValidationRules(ValidationRuleSet ruleSet, IDictionary> rules) + public static void AddValidationRules(ValidationRuleSet ruleSet, IDictionary> rules) { if (ruleSet == null || rules == null) { @@ -118,7 +116,7 @@ public ValidationRuleSet(ValidationRuleSet ruleSet) foreach (var rule in ruleSet) { - Add(rule.ElementType.Name, rule); + Add(rule.ElementType, rule); } } @@ -126,7 +124,7 @@ public ValidationRuleSet(ValidationRuleSet ruleSet) /// Initializes a new instance of the class. /// /// Rules to be contained in this ruleset. - public ValidationRuleSet(IDictionary> rules) + public ValidationRuleSet(IDictionary> rules) { if (rules == null) { @@ -144,7 +142,7 @@ public ValidationRuleSet(IDictionary> rules) /// /// The key for the rule. /// The list of rules. - public void Add(string key, IList rules) + public void Add(Type key, IList rules) { foreach (var rule in rules) { @@ -158,7 +156,7 @@ public void Add(string key, IList rules) /// The key for the rule. /// The rule. /// Exception thrown when rule already exists. - public void Add(string key, ValidationRule rule) + public void Add(Type key, ValidationRule rule) { if (!_rulesDictionary.ContainsKey(key)) { @@ -180,7 +178,7 @@ public void Add(string key, ValidationRule rule) /// The new rule. /// The old rule. /// true, if the update was successful; otherwise false. - public bool Update(string key, ValidationRule newRule, ValidationRule oldRule) + public bool Update(Type key, ValidationRule newRule, ValidationRule oldRule) { if (_rulesDictionary.TryGetValue(key, out var currentRules)) { @@ -195,18 +193,33 @@ public bool Update(string key, ValidationRule newRule, ValidationRule oldRule) /// /// The key of the collection of rules to be removed. /// true if the collection of rules with the provided key is removed; otherwise, false. - public bool Remove(string key) + public bool Remove(Type key) { return _rulesDictionary.Remove(key); } + /// + /// Remove a rule by its name from all types it is used by. + /// + /// Name of the rule. + public void Remove(string ruleName) + { + foreach (KeyValuePair> rule in _rulesDictionary) + { + _rulesDictionary[rule.Key] = rule.Value.Where(vr => !vr.Name.Equals(ruleName, StringComparison.Ordinal)).ToList(); + } + + // Remove types with no rule + _rulesDictionary = _rulesDictionary.Where(r => r.Value.Any()).ToDictionary(r => r.Key, r => r.Value); + } + /// /// Removes a rule by key. /// /// The key of the rule to be removed. /// The rule to be removed. /// true if the rule is successfully removed; otherwise, false. - public bool Remove(string key, ValidationRule rule) + public bool Remove(Type key, ValidationRule rule) { if (_rulesDictionary.TryGetValue(key, out IList validationRules)) { @@ -239,7 +252,7 @@ public void Clear() /// /// The key to locate in the rule set. /// true if the rule set contains an element with the key; otherwise, false. - public bool ContainsKey(string key) + public bool ContainsKey(Type key) { return _rulesDictionary.ContainsKey(key); } @@ -250,7 +263,7 @@ public bool ContainsKey(string key) /// The key to locate. /// The rule to locate. /// - public bool Contains(string key, ValidationRule rule) + public bool Contains(Type key, ValidationRule rule) { return _rulesDictionary.TryGetValue(key, out IList validationRules) && validationRules.Contains(rule); } @@ -263,35 +276,11 @@ public bool Contains(string key, ValidationRule rule) /// key is found; otherwise, an empty object. /// This parameter is passed uninitialized. /// true if the specified key has rules. - public bool TryGetValue(string key, out IList rules) + public bool TryGetValue(Type key, out IList rules) { return _rulesDictionary.TryGetValue(key, out rules); } - /// - /// Remove a rule by its name from all types it is used by. - /// - /// Name of the rule. - public void Remove(string ruleName) - { - foreach (KeyValuePair> rule in _rules) - { - _rules[rule.Key] = rule.Value.Where(vr => !vr.Name.Equals(ruleName, StringComparison.Ordinal)).ToList(); - } - - // Remove types with no rule - _rules = _rules.Where(r => r.Value.Any()).ToDictionary(r => r.Key, r => r.Value); - } - - /// - /// Remove a rule by element type. - /// - /// Type of the rule. - public void Remove(Type type) - { - _rules.Remove(type); - } - /// /// Get the enumerator. /// @@ -324,7 +313,7 @@ private static ValidationRuleSet BuildDefaultRuleSet() var propertyValue = property.GetValue(null); // static property if (propertyValue is ValidationRule rule) { - ruleSet.Add(rule.ElementType.Name, rule); + ruleSet.Add(rule.ElementType, rule); } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs index 6fd57aee8..e05c9ba9d 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs @@ -45,8 +45,7 @@ public async void StreamShouldNotBeDisposedIfLeaveStreamOpenSettingIsTrue() memoryStream.Position = 0; var stream = memoryStream; - var reader = new OpenApiStreamReader(new() { LeaveStreamOpen = true }); - _ = await reader.ReadAsync(stream); + var result = OpenApiDocument.Load(stream, "yaml", new OpenApiReaderSettings { LeaveStreamOpen = true }); stream.Seek(0, SeekOrigin.Begin); // does not throw an object disposed exception Assert.True(stream.CanRead); } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index eb4012f1f..f264c23f6 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.Collections.Generic; @@ -9,10 +9,13 @@ using Json.Schema; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; +using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader.ParseNodes; using Microsoft.OpenApi.Reader.V2; +using Microsoft.OpenApi.Reader.V3; using Microsoft.OpenApi.Tests; +using Microsoft.OpenApi.Writers; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V2Tests @@ -305,36 +308,30 @@ public void ParseOperationWithEmptyProducesArraySetsResponseSchemaIfExists() // Act var operation = OpenApiV2Deserializer.LoadOperation(node); + var expected = @"{ + ""produces"": [ + ""application/octet-stream"" + ], + ""responses"": { + ""200"": { + ""description"": ""OK"", + ""schema"": { + ""type"": ""string"", + ""description"": ""The content of the file."", + ""format"": ""binary"", + ""x-ms-summary"": ""File Content"" + } + } + } +}"; + + var stringBuilder = new StringBuilder(); + var jsonWriter = new OpenApiJsonWriter(new StringWriter(stringBuilder)); + operation.SerializeAsV2(jsonWriter); // Assert - operation.Should().BeEquivalentTo( - new OpenApiOperation - { - Responses = new() - { - { "200", new() - { - Description = "OK", - Content = - { - ["application/octet-stream"] = new() - { - Schema = new() - { - Format = "binary", - Description = "The content of the file.", - Type = "string", - Extensions = - { - ["x-ms-summary"] = new OpenApiString("File Content") - } - } - } - } - }} - } - } - ); + var actual = stringBuilder.ToString(); + actual.MakeLineBreaksEnvironmentNeutral().Should().BeEquivalentTo(expected.MakeLineBreaksEnvironmentNeutral()); } [Fact] @@ -349,7 +346,7 @@ public void ParseOperationWithBodyAndEmptyConsumesSetsRequestBodySchemaIfExists( var operation = OpenApiV2Deserializer.LoadOperation(node); // Assert - operation.Should().BeEquivalentTo(_operationWithBody); + operation.Should().BeEquivalentTo(_operationWithBody, options => options.IgnoringCyclicReferences()); } [Fact] diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 2acc5a862..05d2ab88b 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -1085,17 +1085,15 @@ public void ParseDocumentWithJsonSchemaReferencesWorks() [Fact] public void ValidateExampleShouldNotHaveDataTypeMismatch() { - // Arrange - using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "documentWithDateExampleInSchema.yaml")); - // Act - var doc = new OpenApiStreamReader(new() + var result = OpenApiDocument.Load(Path.Combine(SampleFolderPath, "documentWithDateExampleInSchema.yaml"), new OpenApiReaderSettings { ReferenceResolution = ReferenceResolutionSetting.ResolveLocalReferences - }).Read(stream, out var diagnostic); + + }); // Assert - var warnings = diagnostic.Warnings; + var warnings = result.OpenApiDiagnostic.Warnings; Assert.False(warnings.Any()); } } diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs index d5f61551c..e5fcc346f 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -30,12 +30,13 @@ public void ResponseMustHaveADescription() Title = "foo", Version = "1.2.2" }; - openApiDocument.Paths = new(); - openApiDocument.Paths.Add( - "/test", - new() + openApiDocument.Paths = new() + { { - Operations = + "/test", + new() + { + Operations = { [OperationType.Get] = new() { @@ -45,7 +46,9 @@ public void ResponseMustHaveADescription() } } } - }); + } + } + }; var validator = new OpenApiValidator(ValidationRuleSet.GetDefaultRuleSet()); var walker = new OpenApiWalker(validator); @@ -98,8 +101,8 @@ public void ValidateCustomExtension() { var ruleset = ValidationRuleSet.GetDefaultRuleSet(); - ruleset.Add(typeof(OpenApiAny).Name, - new ValidationRule( + ruleset.Add(typeof(OpenApiAny), + new ValidationRule("FooExtensionRule", (context, item) => { if (item.Node["Bar"].ToString() == "hey") @@ -142,8 +145,8 @@ public void ValidateCustomExtension() [Fact] public void RemoveRuleByName_Invalid() { - Assert.Throws(() => new ValidationRule(null, (vc, oaa) => { })); - Assert.Throws(() => new ValidationRule(string.Empty, (vc, oaa) => { })); + Assert.Throws(() => new ValidationRule(null, (vc, oaa) => { })); + Assert.Throws(() => new ValidationRule(string.Empty, (vc, oaa) => { })); } [Fact] diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs index 0905e7ab4..e011d80ee 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs @@ -1,6 +1,7 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Collections.Generic; using System.Linq; using Json.Schema; @@ -56,9 +57,9 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() }; // Act - var rules = new Dictionary>() + var rules = new Dictionary>() { - { typeof(JsonSchema).Name, + { typeof(JsonSchema), new List() { new AlwaysFailRule() } } }; @@ -106,9 +107,9 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() }; // Act - var rules = new Dictionary>() + var rules = new Dictionary>() { - { typeof(JsonSchema).Name, + { typeof(JsonSchema), new List() { new AlwaysFailRule() } } }; diff --git a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs index 55ae552d1..4bc7e7cfd 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Collections.Generic; using System.Linq; using Microsoft.OpenApi.Models; @@ -10,24 +11,24 @@ namespace Microsoft.OpenApi.Validations.Tests { public class ValidationRuleSetTests { - private readonly ValidationRule _contactValidationRule = new ValidationRule( + private readonly ValidationRule _contactValidationRule = new ValidationRule(nameof(_contactValidationRule), (context, item) => { }); - private readonly ValidationRule _headerValidationRule = new ValidationRule( + private readonly ValidationRule _headerValidationRule = new ValidationRule(nameof(_headerValidationRule), (context, item) => { }); - private readonly ValidationRule _parameterValidationRule = new ValidationRule( + private readonly ValidationRule _parameterValidationRule = new ValidationRule(nameof(_parameterValidationRule), (context, item) => { }); - private readonly IDictionary> _rulesDictionary; + private readonly IDictionary> _rulesDictionary; public ValidationRuleSetTests() { - _rulesDictionary = new Dictionary>() + _rulesDictionary = new Dictionary>() { - {"contact", new List { _contactValidationRule } }, - {"header", new List { _headerValidationRule } }, - {"parameter", new List { _parameterValidationRule } } + {typeof(OpenApiContact), new List { _contactValidationRule } }, + {typeof(OpenApiHeader), new List { _headerValidationRule } }, + {typeof(OpenApiParameter), new List { _parameterValidationRule } } }; } @@ -41,7 +42,7 @@ public void RuleSetConstructorsReturnsTheCorrectRules() var ruleSet_4 = new ValidationRuleSet(); // Assert - Assert.NotNull(ruleSet_1?.Rules); + Assert.NotNull(ruleSet_1?.Rules); Assert.NotNull(ruleSet_2?.Rules); Assert.NotNull(ruleSet_3?.Rules); Assert.NotNull(ruleSet_4); @@ -62,7 +63,7 @@ public void RemoveValidatioRuleGivenTheValidationRuleWorks() { // Arrange var ruleSet = new ValidationRuleSet(_rulesDictionary); - var responseValidationRule = new ValidationRule((context, item) => { }); + var responseValidationRule = new ValidationRule("ValidateResponses", (context, item) => { }); // Act and Assert Assert.True(ruleSet.Remove(_contactValidationRule)); @@ -77,9 +78,9 @@ public void RemoveValidationRuleGivenTheKeyAndValidationRuleWorks() var ruleSet = new ValidationRuleSet(_rulesDictionary); // Act - ruleSet.Remove("contact", _contactValidationRule); - ruleSet.Remove("parameter", _headerValidationRule); // validation rule not in parameter key; shouldn't remove - ruleSet.Remove("foo", _parameterValidationRule); // key does not exist; shouldn't remove + ruleSet.Remove(typeof(OpenApiContact), _contactValidationRule); + ruleSet.Remove("parameter"); // validation rule not in parameter key; shouldn't remove + ruleSet.Remove("foo"); // key does not exist; shouldn't remove var rules = ruleSet.Rules; @@ -94,16 +95,16 @@ public void RemoveRulesGivenAKeyWorks() { // Arrange var ruleSet = new ValidationRuleSet(_rulesDictionary); - var responseValidationRule = new ValidationRule((context, item) => { }); - ruleSet.Add("response", new List { responseValidationRule }); - Assert.True(ruleSet.ContainsKey("response")); + var responseValidationRule = new ValidationRule("ValidateResponses", (context, item) => { }); + ruleSet.Add(typeof(OpenApiResponse), new List { responseValidationRule }); + Assert.True(ruleSet.ContainsKey(typeof(OpenApiResponse))); Assert.True(ruleSet.Rules.Contains(responseValidationRule)); // guard // Act - ruleSet.Remove("response"); + ruleSet.Remove(typeof(OpenApiResponse)); // Assert - Assert.False(ruleSet.ContainsKey("response")); + Assert.False(ruleSet.ContainsKey(typeof(OpenApiResponse))); } [Fact] @@ -111,24 +112,24 @@ public void AddNewValidationRuleWorks() { // Arrange var ruleSet = new ValidationRuleSet(_rulesDictionary); - var responseValidationRule = new ValidationRule((context, item) => { }); - var tagValidationRule = new ValidationRule((context, item) => { }); - var pathsValidationRule = new ValidationRule((context, item) => { }); + var responseValidationRule = new ValidationRule("ValidateResponses", (context, item) => { }); + var tagValidationRule = new ValidationRule("ValidateTags", (context, item) => { }); + var pathsValidationRule = new ValidationRule("ValidatePaths", (context, item) => { }); // Act - ruleSet.Add("response", new List { responseValidationRule }); - ruleSet.Add("tag", new List { tagValidationRule }); - var rulesDictionary = new Dictionary>() + ruleSet.Add(typeof(OpenApiResponse), new List { responseValidationRule }); + ruleSet.Add(typeof(OpenApiTag), new List { tagValidationRule }); + var rulesDictionary = new Dictionary>() { - {"paths", new List { pathsValidationRule } } + {typeof(OpenApiPaths), new List { pathsValidationRule } } }; ValidationRuleSet.AddValidationRules(ruleSet, rulesDictionary); - + // Assert - Assert.True(ruleSet.ContainsKey("response")); - Assert.True(ruleSet.ContainsKey("tag")); - Assert.True(ruleSet.ContainsKey("paths")); + Assert.True(ruleSet.ContainsKey(typeof(OpenApiResponse))); + Assert.True(ruleSet.ContainsKey(typeof(OpenApiTag))); + Assert.True(ruleSet.ContainsKey(typeof(OpenApiPaths))); Assert.True(ruleSet.Rules.Contains(responseValidationRule)); Assert.True(ruleSet.Rules.Contains(tagValidationRule)); Assert.True(ruleSet.Rules.Contains(pathsValidationRule)); @@ -139,16 +140,16 @@ public void UpdateValidationRuleWorks() { // Arrange var ruleSet = new ValidationRuleSet(_rulesDictionary); - var responseValidationRule = new ValidationRule((context, item) => { }); - ruleSet.Add("response", new List { responseValidationRule }); + var responseValidationRule = new ValidationRule("ValidateResponses", (context, item) => { }); + ruleSet.Add(typeof(OpenApiResponse), new List { responseValidationRule }); // Act - var pathsValidationRule = new ValidationRule((context, item) => { }); - ruleSet.Update("response", pathsValidationRule, responseValidationRule); + var pathsValidationRule = new ValidationRule("ValidatePaths", (context, item) => { }); + ruleSet.Update(typeof(OpenApiResponse), pathsValidationRule, responseValidationRule); // Assert - Assert.True(ruleSet.Contains("response", pathsValidationRule)); - Assert.False(ruleSet.Contains("response", responseValidationRule)); + Assert.True(ruleSet.Contains(typeof(OpenApiResponse), pathsValidationRule)); + Assert.False(ruleSet.Contains(typeof(OpenApiResponse), responseValidationRule)); } [Fact] @@ -158,8 +159,8 @@ public void TryGetValueWorks() var ruleSet = new ValidationRuleSet(_rulesDictionary); // Act - ruleSet.TryGetValue("contact", out var validationRules); - + ruleSet.TryGetValue(typeof(OpenApiContact), out var validationRules); + // Assert Assert.True(validationRules.Any()); Assert.True(validationRules.Contains(_contactValidationRule)); @@ -170,12 +171,12 @@ public void ClearAllRulesWorks() { // Arrange var ruleSet = new ValidationRuleSet(); - var tagValidationRule = new ValidationRule((context, item) => { }); - var pathsValidationRule = new ValidationRule((context, item) => { }); - var rulesDictionary = new Dictionary>() + var tagValidationRule = new ValidationRule("ValidateTags", (context, item) => { }); + var pathsValidationRule = new ValidationRule("ValidatePaths", (context, item) => { }); + var rulesDictionary = new Dictionary>() { - {"paths", new List { pathsValidationRule } }, - {"tag", new List { tagValidationRule } } + {typeof(OpenApiPaths), new List { pathsValidationRule } }, + {typeof(OpenApiTag), new List { tagValidationRule } } }; ValidationRuleSet.AddValidationRules(ruleSet, rulesDictionary); From 928b14645a5451250d25502e0c98146545953bfb Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 3 Apr 2024 22:51:17 +0300 Subject: [PATCH 108/110] Remove obsolete attribute and update API interface --- .../OpenApiCallbackReferenceTests.cs | 1 - .../OpenApiExampleReferenceTests.cs | 1 - .../References/OpenApiHeaderReferenceTests.cs | 1 - .../References/OpenApiLinkReferenceTests.cs | 1 - .../OpenApiParameterReferenceTests.cs | 1 - .../OpenApiPathItemReferenceTests.cs | 1 - .../OpenApiRequestBodyReferenceTests.cs | 1 - .../OpenApiResponseReferenceTest.cs | 1 - .../OpenApiSecuritySchemeReferenceTests.cs | 1 - .../References/OpenApiTagReferenceTest.cs | 1 - .../PublicApi/PublicApi.approved.txt | 24 +++++++++---------- 11 files changed, 12 insertions(+), 22 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs index 02ee501e3..93ffc66d8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiCallbackReferenceTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.OpenApi.Tests.Models.References { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiCallbackReferenceTests { private const string OpenApi = @" diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs index 819c986de..11136ae19 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.OpenApi.Tests.Models.References { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiExampleReferenceTests { private const string OpenApi = @" diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs index 7f699725b..d00687f38 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.OpenApi.Tests.Models.References { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiHeaderReferenceTests { private const string OpenApi= @" diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiLinkReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiLinkReferenceTests.cs index a54a47db1..a2d31bb52 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiLinkReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiLinkReferenceTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.OpenApi.Tests.Models.References { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiLinkReferenceTests { private const string OpenApi = @" diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiParameterReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiParameterReferenceTests.cs index 8568f1c44..8b3314aee 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiParameterReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiParameterReferenceTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.OpenApi.Tests.Models.References { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiParameterReferenceTests { private const string OpenApi = @" diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs index 5d77bde1b..31b1f32a9 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiPathItemReferenceTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.OpenApi.Tests.Models.References { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiPathItemReferenceTests { private const string OpenApi = @" diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiRequestBodyReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiRequestBodyReferenceTests.cs index c0ce9bcef..5f69be0f3 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiRequestBodyReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiRequestBodyReferenceTests.cs @@ -18,7 +18,6 @@ namespace Microsoft.OpenApi.Tests.Models.References { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiRequestBodyReferenceTests { private readonly string OpenApi = @" diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiResponseReferenceTest.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiResponseReferenceTest.cs index 0fed16f31..3ac7e1050 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiResponseReferenceTest.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiResponseReferenceTest.cs @@ -17,7 +17,6 @@ namespace Microsoft.OpenApi.Tests.Models.References { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiResponseReferenceTest { private const string OpenApi = @" diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiSecuritySchemeReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiSecuritySchemeReferenceTests.cs index a74712829..1f74b6f3a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiSecuritySchemeReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiSecuritySchemeReferenceTests.cs @@ -15,7 +15,6 @@ namespace Microsoft.OpenApi.Tests.Models.References { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiSecuritySchemeReferenceTests { private const string OpenApi = @" diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs index 0b2efe1b0..82f1b27a2 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiTagReferenceTest.cs @@ -15,7 +15,6 @@ namespace Microsoft.OpenApi.Tests.Models.References { [Collection("DefaultSettings")] - [UsesVerify] public class OpenApiTagReferenceTest { private const string OpenApi = @"openapi: 3.0.3 diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 0f2fe7dfe..62be8d767 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1503,23 +1503,23 @@ namespace Microsoft.OpenApi.Validations { public ValidationRuleSet() { } public ValidationRuleSet(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet) { } - public ValidationRuleSet(System.Collections.Generic.IDictionary> rules) { } + public ValidationRuleSet(System.Collections.Generic.IDictionary> rules) { } public int Count { get; } - public System.Collections.Generic.ICollection Keys { get; } public System.Collections.Generic.IList Rules { get; } - public void Add(string key, Microsoft.OpenApi.Validations.ValidationRule rule) { } - public void Add(string key, System.Collections.Generic.IList rules) { } + public void Add(System.Type key, Microsoft.OpenApi.Validations.ValidationRule rule) { } + public void Add(System.Type key, System.Collections.Generic.IList rules) { } public void Clear() { } - public bool Contains(string key, Microsoft.OpenApi.Validations.ValidationRule rule) { } - public bool ContainsKey(string key) { } - public System.Collections.Generic.IList FindRules(string key) { } + public bool Contains(System.Type key, Microsoft.OpenApi.Validations.ValidationRule rule) { } + public bool ContainsKey(System.Type key) { } + public System.Collections.Generic.IList FindRules(System.Type type) { } public System.Collections.Generic.IEnumerator GetEnumerator() { } public bool Remove(Microsoft.OpenApi.Validations.ValidationRule rule) { } - public bool Remove(string key) { } - public bool Remove(string key, Microsoft.OpenApi.Validations.ValidationRule rule) { } - public bool TryGetValue(string key, out System.Collections.Generic.IList rules) { } - public bool Update(string key, Microsoft.OpenApi.Validations.ValidationRule newRule, Microsoft.OpenApi.Validations.ValidationRule oldRule) { } - public static void AddValidationRules(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet, System.Collections.Generic.IDictionary> rules) { } + public void Remove(string ruleName) { } + public bool Remove(System.Type key) { } + public bool Remove(System.Type key, Microsoft.OpenApi.Validations.ValidationRule rule) { } + public bool TryGetValue(System.Type key, out System.Collections.Generic.IList rules) { } + public bool Update(System.Type key, Microsoft.OpenApi.Validations.ValidationRule newRule, Microsoft.OpenApi.Validations.ValidationRule oldRule) { } + public static void AddValidationRules(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet, System.Collections.Generic.IDictionary> rules) { } public static Microsoft.OpenApi.Validations.ValidationRuleSet GetDefaultRuleSet() { } public static Microsoft.OpenApi.Validations.ValidationRuleSet GetEmptyRuleSet() { } } From f11170b0207fc2d2512d27088a9cc6d41dde54a1 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 3 Apr 2024 23:09:05 +0300 Subject: [PATCH 109/110] Represent NaN, Infinity and -Infinity as string literals for JSON serialization --- .../Writers/OpenApiJsonWriterTests.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs index f108b950a..11b429300 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Text; using FluentAssertions; +using Json.Schema; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; @@ -273,19 +274,12 @@ public void WriteDateTimeAsJsonShouldMatchExpected(DateTimeOffset dateTimeOffset public void OpenApiJsonWriterOutputsValidJsonValueWhenSchemaHasNanOrInfinityValues() { // Arrange - var schema = new OpenApiSchema - { - Enum = new List { - new OpenApiDouble(double.NaN), - new OpenApiDouble(double.PositiveInfinity), - new OpenApiDouble(double.NegativeInfinity) - } - }; + var schema = new JsonSchemaBuilder().Enum("NaN", "Infinity", "-Infinity"); // Act var schemaBuilder = new StringBuilder(); var jsonWriter = new OpenApiJsonWriter(new StringWriter(schemaBuilder)); - schema.SerializeAsV3(jsonWriter); + jsonWriter.WriteJsonSchema(schema, OpenApiSpecVersion.OpenApi3_0); var jsonString = schemaBuilder.ToString(); // Assert From 60876655e7afe931fb740f83dcc8d5c35469449a Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 3 Apr 2024 23:36:02 +0300 Subject: [PATCH 110/110] Update API interface --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 1380056dd..8cce0b6f5 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -667,6 +667,7 @@ namespace Microsoft.OpenApi.Models public virtual string Summary { get; set; } public virtual bool UnresolvedReference { get; set; } public virtual Microsoft.OpenApi.Any.OpenApiAny Value { get; set; } + public void Serialize(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion version) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public virtual void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }