From 3046861d4bc9a768f00bd176b7ccaee7f753a3cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 21:05:22 +0000 Subject: [PATCH 01/83] Bump docker/login-action from 2.0.0 to 2.1.0 Bumps [docker/login-action](https://github.com/docker/login-action) from 2.0.0 to 2.1.0. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v2.0.0...v2.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 ec86e0b7f..b9ebfbdb1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -17,7 +17,7 @@ jobs: - name: Check out the repo uses: actions/checkout@v3 - name: Login to GitHub package feed - uses: docker/login-action@v2.0.0 + uses: docker/login-action@v2.1.0 with: username: ${{ secrets.ACR_USERNAME }} password: ${{ secrets.ACR_PASSWORD }} From c54add27f41a9a3a4b865aa54eb2b705edc61901 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 21:05:25 +0000 Subject: [PATCH 02/83] Bump docker/build-push-action from 3.1.1 to 3.2.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 3.1.1 to 3.2.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v3.1.1...v3.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 b9ebfbdb1..a5884fc08 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@v3.1.1 + uses: docker/build-push-action@v3.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@v3.1.1 + uses: docker/build-push-action@v3.2.0 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }} From 319462e7ffd0f73cb05c00211779dd388535345b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Oct 2022 09:20:39 +0300 Subject: [PATCH 03/83] Bump Microsoft.OData.Edm from 7.12.3 to 7.12.4 (#1043) Bumps Microsoft.OData.Edm from 7.12.3 to 7.12.4. --- updated-dependencies: - dependency-name: Microsoft.OData.Edm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- 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 55d529a06..cbff7e937 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -42,7 +42,7 @@ - + From cb80a1e4b993bf5e5226f17928ef67e9671458cd Mon Sep 17 00:00:00 2001 From: Alexey Sosnin Date: Mon, 19 Sep 2022 19:27:16 +0300 Subject: [PATCH 04/83] fix: invariant culture for version field Writing version field depends on current system culture version: '1.13.0' for `en-US` version: 1.13.0 for `en-GB` existing workaround: set DOTNET_SYSTEM_GLOBALIZATION_INVARIANT environment variable https://learn.microsoft.com/en-us/dotnet/core/runtime-config/globalization#invariant-mode --- .../SpecialCharacterStringExtensions.cs | 2 +- .../OpenApiWriterSpecialCharacterTests.cs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs b/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs index d4f78a5c1..6e1ea2beb 100644 --- a/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs @@ -192,7 +192,7 @@ internal static string GetYamlCompatibleString(this string input) if (decimal.TryParse(input, NumberStyles.Float, CultureInfo.InvariantCulture, out var _) || IsHexadecimalNotation(input) || bool.TryParse(input, out var _) || - DateTime.TryParse(input, out var _)) + DateTime.TryParse(input, CultureInfo.InvariantCulture, DateTimeStyles.None, out var _)) { return $"'{input}'"; } diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs index f23cc442a..6ac47d6c3 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs @@ -148,5 +148,26 @@ public void WriteStringWithNewlineCharactersInArrayAsYamlWorks(string input, str // Assert actual.Should().Be(expected); } + + [Theory] + [InlineData("1.8.0", " '1.8.0'", "en-US")] + [InlineData("1.8.0", " '1.8.0'", "en-GB")] + [InlineData("1.13.0", " '1.13.0'", "en-US")] + [InlineData("1.13.0", " '1.13.0'", "en-GB")] + public void WriteStringAsYamlDoesNotDependOnSystemCulture(string input, string expected, string culture) + { + CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(culture); + + // Arrange + var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiYamlWriter(outputStringWriter); + + // Act + writer.WriteValue(input); + var actual = outputStringWriter.GetStringBuilder().ToString(); + + // Assert + actual.Should().Be(expected); + } } } From 5837b3154c7f18c3a7622ae24cec05e49ee58980 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 7 Oct 2022 12:15:34 -0400 Subject: [PATCH 05/83] - renames hidi in accordance to naming policy of MCR Signed-off-by: Vincent Biret --- .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 a5884fc08..b289449cf 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,7 +6,7 @@ on: paths: ['src/Microsoft.OpenApi.Hidi/**', '.github/workflows/**'] env: REGISTRY: msgraphprod.azurecr.io - IMAGE_NAME: public/hidi + IMAGE_NAME: public/openapi/hidi jobs: push_to_registry: environment: From 877465346a98788d47bd2d48439b6d553d29289d Mon Sep 17 00:00:00 2001 From: Irvine Date: Mon, 24 Oct 2022 15:29:16 +0300 Subject: [PATCH 06/83] Upgrade conversion lib. ver.; update Hidi version --- 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 cbff7e937..c77e30194 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -15,7 +15,7 @@ Microsoft.OpenApi.Hidi hidi ./../../artifacts - 1.1.0-preview2 + 1.1.0-preview3 OpenAPI.NET CLI tool for slicing OpenAPI documents © Microsoft Corporation. All rights reserved. OpenAPI .NET @@ -43,7 +43,7 @@ - + From cf34fa392179d061f46face1e5d024a1a4904be6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 21:12:21 +0000 Subject: [PATCH 07/83] Bump Verify.Xunit from 17.10.2 to 18.0.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 17.10.2 to 18.0.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/17.10.2...18.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 b922d72d8..b243c5dd7 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + all From cf7faecd4a514538c9caa1176214d9dc143f2d25 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 21:12:27 +0000 Subject: [PATCH 08/83] Bump FluentAssertions from 6.7.0 to 6.8.0 Bumps [FluentAssertions](https://github.com/fluentassertions/fluentassertions) from 6.7.0 to 6.8.0. - [Release notes](https://github.com/fluentassertions/fluentassertions/releases) - [Changelog](https://github.com/fluentassertions/fluentassertions/blob/develop/AcceptApiChanges.ps1) - [Commits](https://github.com/fluentassertions/fluentassertions/compare/6.7.0...6.8.0) --- updated-dependencies: - dependency-name: FluentAssertions dependency-type: direct:production update-type: version-update:semver-minor ... 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 73aeeac9f..21656e1b7 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -263,7 +263,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index b243c5dd7..d1f97f6f3 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From d14fc9f7c85d8661f56a16c824f2be16e5590edc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Oct 2022 21:12:12 +0000 Subject: [PATCH 09/83] Bump Microsoft.OData.Edm from 7.12.4 to 7.12.5 Bumps Microsoft.OData.Edm from 7.12.4 to 7.12.5. --- updated-dependencies: - dependency-name: Microsoft.OData.Edm 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 c77e30194..37c7d3b42 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -42,7 +42,7 @@ - + From 5b871cf3de1f5f4158197017a989c85cb7c6e62d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 28 Oct 2022 21:10:43 +0000 Subject: [PATCH 10/83] Bump Microsoft.Windows.Compatibility from 6.0.0 to 6.0.1 Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/runtime) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v6.0.0...v6.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 a47b5af48..6b83bdbca 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -10,7 +10,7 @@ all - + From 69e7b85c2dc11c5a4d3f2d971dd74714872f9b9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 28 Oct 2022 21:10:37 +0000 Subject: [PATCH 11/83] Bump Verify.Xunit from 18.0.0 to 18.1.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 18.0.0 to 18.1.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/18.0.0...18.1.1) --- 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 d1f97f6f3..79beda1ad 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + all From 3fc51be3971b3b47d856d26b140881c0ada2e440 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 21:12:01 +0000 Subject: [PATCH 12/83] Bump coverlet.collector from 3.1.2 to 3.2.0 Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 3.1.2 to 3.2.0. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/commits/v3.2.0) --- updated-dependencies: - dependency-name: coverlet.collector dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1a4002daa..2c53d82da 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -16,7 +16,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all From ba9a51fe749fc55e5b00c6efacbd0935ec92384d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 21:12:08 +0000 Subject: [PATCH 13/83] Bump Verify.Xunit from 18.1.1 to 18.2.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 18.1.1 to 18.2.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/18.1.1...18.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 79beda1ad..251fe1a4b 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + all From 200e73597a53a52e2cd12b9c058f57052131c080 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 21:05:58 +0000 Subject: [PATCH 14/83] Bump mathieudutour/github-tag-action from 6.0 to 6.1 Bumps [mathieudutour/github-tag-action](https://github.com/mathieudutour/github-tag-action) from 6.0 to 6.1. - [Release notes](https://github.com/mathieudutour/github-tag-action/releases) - [Commits](https://github.com/mathieudutour/github-tag-action/compare/v6.0...v6.1) --- 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 b972c9848..b394e018b 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -49,7 +49,7 @@ jobs: - if: steps.conditionals_handler.outputs.is_default_branch == 'true' name: Bump GH tag id: tag_generator - uses: mathieudutour/github-tag-action@v6.0 + uses: mathieudutour/github-tag-action@v6.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} default_bump: false From 753f5655a2a31fbbb687fc192a07c32499b39a2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Nov 2022 21:11:32 +0000 Subject: [PATCH 15/83] Bump Verify.Xunit from 18.2.0 to 18.3.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 18.2.0 to 18.3.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/18.2.0...18.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 251fe1a4b..33dd48253 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + all From b9085613b675ae271375fd94a4ca928ee32365fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Nov 2022 21:11:27 +0000 Subject: [PATCH 16/83] Bump Microsoft.OpenApi.OData from 1.2.0-preview5 to 1.2.0-preview6 Bumps [Microsoft.OpenApi.OData](https://github.com/Microsoft/OpenAPI.NET.OData) from 1.2.0-preview5 to 1.2.0-preview6. - [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 37c7d3b42..e133b37cf 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -43,7 +43,7 @@ - + From f44ef7da9046bb7acc6980600a5d3b5be569fe68 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 3 Nov 2022 12:35:53 +0300 Subject: [PATCH 17/83] Remove return statement to eliminate NullReference exception --- src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index 8b454bf68..45cd5afae 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs @@ -114,7 +114,6 @@ public OpenApiReference ConvertToOpenApiReference( catch (OpenApiException ex) { Diagnostic.Errors.Add(new OpenApiError(ex)); - return null; } } // Where fragments point into a non-OpenAPI document, the id will be the complete fragment identifier From 81030e8b9cca364977d362dc422909748d3a2f00 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 21:10:46 +0000 Subject: [PATCH 18/83] Bump Microsoft.NET.Test.Sdk from 17.3.2 to 17.4.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.3.2 to 17.4.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.3.2...v17.4.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 2c53d82da..f4c368024 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -9,7 +9,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 21656e1b7..9eebce978 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -262,7 +262,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 7f41b101f..bb1cf129d 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 33dd48253..3ee1f6322 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -16,7 +16,7 @@ - + From b36dcae6d5aff11290de0e443eb9544694f2c223 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 21:10:59 +0000 Subject: [PATCH 19/83] Bump Microsoft.Extensions.Logging.Abstractions from 6.0.2 to 7.0.0 Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) from 6.0.2 to 7.0.0. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/commits) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Logging.Abstractions dependency-type: direct:production update-type: version-update:semver-major ... 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 e133b37cf..e11d1c315 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -38,7 +38,7 @@ - + From d9de1ece9f4ee697717f56621d41281b37ae710a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 21:10:40 +0000 Subject: [PATCH 20/83] Bump Microsoft.Windows.Compatibility from 6.0.1 to 7.0.0 Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/runtime) from 6.0.1 to 7.0.0. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/commits) --- updated-dependencies: - dependency-name: Microsoft.Windows.Compatibility dependency-type: direct:production update-type: version-update:semver-major ... 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 6b83bdbca..cf3ff2225 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -10,7 +10,7 @@ all - + From 978fa4d9631f6f482ebb772bd3687286bb0418c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 21:10:53 +0000 Subject: [PATCH 21/83] Bump Verify.Xunit from 18.3.0 to 18.4.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 18.3.0 to 18.4.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/18.3.0...18.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 3ee1f6322..666a2b39b 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + all From c724f1105dc5f8dcd14ec10abe1d4c507b1b2f05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 21:51:07 +0000 Subject: [PATCH 22/83] Bump Microsoft.Extensions.Logging from 6.0.0 to 7.0.0 Bumps [Microsoft.Extensions.Logging](https://github.com/dotnet/runtime) from 6.0.0 to 7.0.0. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/commits) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Logging dependency-type: direct:production update-type: version-update:semver-major ... 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 e11d1c315..c19926e38 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -37,7 +37,7 @@ - + From 0270306375cd1345e3162a830643b48dea3ad2d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 22:05:56 +0000 Subject: [PATCH 23/83] Bump Microsoft.Extensions.Logging.Console from 6.0.0 to 7.0.0 Bumps [Microsoft.Extensions.Logging.Console](https://github.com/dotnet/runtime) from 6.0.0 to 7.0.0. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/commits) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Logging.Console dependency-type: direct:production update-type: version-update:semver-major ... 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 c19926e38..c884e91fe 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -39,7 +39,7 @@ - + From 2adce892959de2af3cf65d69f045913f45dd3aa8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 22:17:37 +0000 Subject: [PATCH 24/83] Bump Microsoft.Extensions.Logging.Debug from 6.0.0 to 7.0.0 Bumps [Microsoft.Extensions.Logging.Debug](https://github.com/dotnet/runtime) from 6.0.0 to 7.0.0. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/commits) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Logging.Debug dependency-type: direct:production update-type: version-update:semver-major ... 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 c884e91fe..6c9b54e04 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -40,7 +40,7 @@ - + From 926a606fdcc9e7d5147212bd5596d9cd8dcc4d1c Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Wed, 11 May 2022 16:38:18 -0400 Subject: [PATCH 25/83] Configure CSDL via settings --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 10 ++++++++++ src/Microsoft.OpenApi.Hidi/Program.cs | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 034350f1a..d48be0bf3 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -27,6 +27,7 @@ using System.Xml.Xsl; using System.Xml; using System.Reflection; +using Microsoft.Extensions.Configuration; namespace Microsoft.OpenApi.Hidi { @@ -98,6 +99,7 @@ CancellationToken cancellationToken stream = ApplyFilter(csdl, csdlFilter, transform); stream.Position = 0; } + document = await ConvertCsdlToOpenApi(stream); stopwatch.Stop(); logger.LogTrace("{timestamp}ms: Generated OpenAPI with {paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count); @@ -304,6 +306,14 @@ public static async Task ValidateOpenApiDocument( } } + internal static IConfiguration GetConfiguration() + { + IConfiguration config = new ConfigurationBuilder() + .AddJsonFile("appsettings.json",true) + .Build(); + return config; + } + /// /// Converts CSDL to OpenAPI /// diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 926c58deb..67f4c2974 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -2,8 +2,14 @@ // Licensed under the MIT license. using System.CommandLine; +using System.CommandLine.Builder; +using System.CommandLine.Hosting; +using System.CommandLine.Parsing; + using System.IO; using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Hidi.Handlers; @@ -110,9 +116,20 @@ static async Task Main(string[] args) rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); + // Parse the incoming args and invoke the handler await rootCommand.InvokeAsync(args); + + //await new CommandLineBuilder(rootCommand) + // .UseHost(_ => Host.CreateDefaultBuilder(), + // host => { + // var config = host.Services.GetRequiredService(); + // }) + // .UseDefaults() + // .Build() + // .InvokeAsync(args); + //// Wait for logger to write messages to the console before exiting await Task.Delay(10); } From 7613a72cba0dacf5baae79506d37a639bafc3989 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 7 Nov 2022 11:30:04 +0300 Subject: [PATCH 26/83] Add a settingsFile parameter that allows one to input a path to the settingsfile --- .../Handlers/TransformCommandHandler.cs | 4 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 39 +++++++++++++++++-- src/Microsoft.OpenApi.Hidi/Program.cs | 5 +++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs b/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs index e8d9431de..696837d3f 100644 --- a/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs +++ b/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs @@ -21,6 +21,7 @@ internal class TransformCommandHandler : ICommandHandler public Option VersionOption { get; set; } public Option FormatOption { get; set; } public Option TerseOutputOption { get; set; } + public Option SettingsFileOption { get; set; } public Option LogLevelOption { get; set; } public Option FilterByOperationIdsOption { get; set; } public Option FilterByTagsOption { get; set; } @@ -42,6 +43,7 @@ public async Task InvokeAsync(InvocationContext context) string? version = context.ParseResult.GetValueForOption(VersionOption); OpenApiFormat? format = context.ParseResult.GetValueForOption(FormatOption); bool terseOutput = context.ParseResult.GetValueForOption(TerseOutputOption); + string settingsFile = context.ParseResult.GetValueForOption(SettingsFileOption); LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption); bool inlineLocal = context.ParseResult.GetValueForOption(InlineLocalOption); bool inlineExternal = context.ParseResult.GetValueForOption(InlineExternalOption); @@ -54,7 +56,7 @@ public async Task InvokeAsync(InvocationContext context) var logger = loggerFactory.CreateLogger(); try { - await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, format, terseOutput, logLevel, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, cancellationToken); + await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, format, terseOutput, settingsFile, logLevel, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, cancellationToken); return 0; } diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index d48be0bf3..307b91be1 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -45,6 +45,7 @@ public static async Task TransformOpenApiDocument( string? version, OpenApiFormat? format, bool terseOutput, + string settingsFile, LogLevel logLevel, bool inlineLocal, bool inlineExternal, @@ -100,7 +101,7 @@ CancellationToken cancellationToken stream.Position = 0; } - document = await ConvertCsdlToOpenApi(stream); + document = await ConvertCsdlToOpenApi(stream, settingsFile); stopwatch.Stop(); logger.LogTrace("{timestamp}ms: Generated OpenAPI with {paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count); } @@ -306,11 +307,14 @@ public static async Task ValidateOpenApiDocument( } } - internal static IConfiguration GetConfiguration() + public static IConfiguration GetConfiguration(string settingsFile) { + settingsFile ??= "appsettings.json"; + IConfiguration config = new ConfigurationBuilder() - .AddJsonFile("appsettings.json",true) + .AddJsonFile(settingsFile, true) .Build(); + return config; } @@ -319,12 +323,16 @@ internal static IConfiguration GetConfiguration() /// /// The CSDL stream. /// An OpenAPI document. - public static async Task ConvertCsdlToOpenApi(Stream csdl) + public static async Task ConvertCsdlToOpenApi(Stream csdl, string settingsFile = null) { using var reader = new StreamReader(csdl); var csdlText = await reader.ReadToEndAsync(); var edmModel = CsdlReader.Parse(XElement.Parse(csdlText).CreateReader()); + + var config = GetConfiguration(settingsFile); + var settings = config.GetSection("OpenApiConvertSettings").Get(); +<<<<<<< HEAD var settings = new OpenApiConvertSettings() { AddSingleQuotesForStringParameters = true, @@ -345,6 +353,29 @@ public static async Task ConvertCsdlToOpenApi(Stream csdl) EnableCount = true, UseSuccessStatusCodeRange = true }; +======= + settings ??= new OpenApiConvertSettings() + { + AddSingleQuotesForStringParameters = true, + AddEnumDescriptionExtension = true, + DeclarePathParametersOnPathItem = true, + EnableKeyAsSegment = true, + EnableOperationId = true, + ErrorResponsesAsDefault = false, + PrefixEntityTypeNameBeforeKey = true, + TagDepth = 2, + EnablePagination = true, + EnableDiscriminatorValue = true, + EnableDerivedTypesReferencesForRequestBody = false, + EnableDerivedTypesReferencesForResponses = false, + ShowRootPath = false, + ShowLinks = false, + ExpandDerivedTypesNavigationProperties = false, + EnableCount = true, + UseSuccessStatusCodeRange = true + }; + +>>>>>>> e2101373 (Add a settingsFile parameter that allows one to input a path to the settingsfile) OpenApiDocument document = edmModel.ConvertToOpenApi(settings); document = FixReferences(document); diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 67f4c2974..3af6818da 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -47,6 +47,9 @@ static async Task Main(string[] args) var terseOutputOption = new Option("--terse-output", "Produce terse json output"); terseOutputOption.AddAlias("--to"); + var settingsFileOption = new Option("--settingsFile", "The configuration file with CSDL conversion settings."); + settingsFileOption.AddAlias("--sf"); + var logLevelOption = new Option("--log-level", () => LogLevel.Information, "The log level to use when logging messages to the main output."); logLevelOption.AddAlias("--ll"); @@ -87,6 +90,7 @@ static async Task Main(string[] args) versionOption, formatOption, terseOutputOption, + settingsFileOption, logLevelOption, filterByOperationIdsOption, filterByTagsOption, @@ -105,6 +109,7 @@ static async Task Main(string[] args) VersionOption = versionOption, FormatOption = formatOption, TerseOutputOption = terseOutputOption, + SettingsFileOption = settingsFileOption, LogLevelOption = logLevelOption, FilterByOperationIdsOption = filterByOperationIdsOption, FilterByTagsOption = filterByTagsOption, From d5727227b436eaf40daa76a64505d7e8048eb93e Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 7 Nov 2022 11:31:03 +0300 Subject: [PATCH 27/83] Add test --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 3 +++ .../Services/OpenApiServiceTests.cs | 16 ++++++++++++++++ .../Services/appsettingstest.json | 7 +++++++ 3 files changed, 26 insertions(+) create mode 100644 test/Microsoft.OpenApi.Hidi.Tests/Services/appsettingstest.json 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 f4c368024..b490724e6 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -34,6 +34,9 @@ + + Always + Always diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index af5437aa1..aed9e4889 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -4,7 +4,9 @@ using System; using System.IO; using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; using Microsoft.OpenApi.Hidi; +using Microsoft.OpenApi.OData; using Microsoft.OpenApi.Services; using Xunit; @@ -51,5 +53,19 @@ public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocumen Assert.NotEmpty(subsetOpenApiDocument.Paths); Assert.Equal(expectedPathCount, subsetOpenApiDocument.Paths.Count); } + + [Fact] + public void ReturnOpenApiConvertSettings() + { + // Arrange + var filePath = "C:\\Users\\v-makim\\source\\repos\\OpenAPI.NET\\test\\Microsoft.OpenApi.Hidi.Tests\\Services\\appsettingstest.json"; + var config = OpenApiService.GetConfiguration(filePath); + + // Act + var settings = config.GetSection("OpenApiConvertSettings").Get(); + + // Assert + Assert.NotNull(settings); + } } } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/appsettingstest.json b/test/Microsoft.OpenApi.Hidi.Tests/Services/appsettingstest.json new file mode 100644 index 000000000..2effcaced --- /dev/null +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/appsettingstest.json @@ -0,0 +1,7 @@ +{ + "OpenApiConvertSettings": { + "AddSingleQuotesForStringParameters": "true", + "AddEnumDescriptionExtension": "true", + "DeclarePathParametersOnPathItem": "true" + } +} \ No newline at end of file From fbd8f16d1c006b8a41b917f9bb7c3dfd71d3a4bb Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 7 Nov 2022 13:04:04 +0300 Subject: [PATCH 28/83] Use backslash in filePath --- .../Services/OpenApiServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index aed9e4889..68fefe088 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -58,7 +58,7 @@ public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocumen public void ReturnOpenApiConvertSettings() { // Arrange - var filePath = "C:\\Users\\v-makim\\source\\repos\\OpenAPI.NET\\test\\Microsoft.OpenApi.Hidi.Tests\\Services\\appsettingstest.json"; + var filePath = "C:/Users/v-makim/source/repos/OpenAPI.NET/test/Microsoft.OpenApi.Hidi.Tests/Services/appsettingstest.json"; var config = OpenApiService.GetConfiguration(filePath); // Act From 3dff273db4de3be86f915ccdef5f7d2ba2f9d392 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 7 Nov 2022 14:33:37 +0300 Subject: [PATCH 29/83] Clean up tests --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Services/OpenApiServiceTests.cs | 2 +- .../Services/appsettingstest.json | 7 ------- .../UtilityFiles/appsettingstest.json | 21 +++++++++++++++++++ 4 files changed, 23 insertions(+), 9 deletions(-) delete mode 100644 test/Microsoft.OpenApi.Hidi.Tests/Services/appsettingstest.json create mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/appsettingstest.json 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 b490724e6..d73d8af81 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -34,7 +34,7 @@ - + Always diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 68fefe088..44d0740be 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -58,7 +58,7 @@ public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocumen public void ReturnOpenApiConvertSettings() { // Arrange - var filePath = "C:/Users/v-makim/source/repos/OpenAPI.NET/test/Microsoft.OpenApi.Hidi.Tests/Services/appsettingstest.json"; + var filePath = "C:/Users/v-makim/source/repos/OpenAPI.NET/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/appsettingstest.json"; var config = OpenApiService.GetConfiguration(filePath); // Act diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/appsettingstest.json b/test/Microsoft.OpenApi.Hidi.Tests/Services/appsettingstest.json deleted file mode 100644 index 2effcaced..000000000 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/appsettingstest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "OpenApiConvertSettings": { - "AddSingleQuotesForStringParameters": "true", - "AddEnumDescriptionExtension": "true", - "DeclarePathParametersOnPathItem": "true" - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/appsettingstest.json b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/appsettingstest.json new file mode 100644 index 000000000..a71d0a9fa --- /dev/null +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/appsettingstest.json @@ -0,0 +1,21 @@ +{ + "OpenApiConvertSettings": { + "AddSingleQuotesForStringParameters": "true", + "AddEnumDescriptionExtension": "true", + "DeclarePathParametersOnPathItem": "true", + "EnableKeyAsSegment": "true", + "EnableOperationId": "true", + "ErrorResponsesAsDefault": "false", + "PrefixEntityTypeNameBeforeKey": "true", + "TagDepth": 2, + "EnablePagination": "true", + "EnableDiscriminatorValue": "true", + "EnableDerivedTypesReferencesForRequestBody": "false", + "EnableDerivedTypesReferencesForResponses": "false", + "ShowRootPath": "false", + "ShowLinks": "false", + "ExpandDerivedTypesNavigationProperties": "false", + "EnableCount": "true", + "UseSuccessStatusCodeRange": "true" + } +} \ No newline at end of file From 2f4459bf62b7dca5fa41c6e0e9f4d2948e7dc200 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Nov 2022 12:45:30 +0300 Subject: [PATCH 30/83] Address PR feedback code cleanup and rebase to release/2.0.0 --- .../Handlers/TransformCommandHandler.cs | 4 +- .../Microsoft.OpenApi.Hidi.csproj | 8 ++ src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 75 +++++-------------- src/Microsoft.OpenApi.Hidi/Program.cs | 29 +------ .../Services/OpenApiServiceTests.cs | 24 +++--- 5 files changed, 44 insertions(+), 96 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs b/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs index 696837d3f..e8d9431de 100644 --- a/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs +++ b/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs @@ -21,7 +21,6 @@ internal class TransformCommandHandler : ICommandHandler public Option VersionOption { get; set; } public Option FormatOption { get; set; } public Option TerseOutputOption { get; set; } - public Option SettingsFileOption { get; set; } public Option LogLevelOption { get; set; } public Option FilterByOperationIdsOption { get; set; } public Option FilterByTagsOption { get; set; } @@ -43,7 +42,6 @@ public async Task InvokeAsync(InvocationContext context) string? version = context.ParseResult.GetValueForOption(VersionOption); OpenApiFormat? format = context.ParseResult.GetValueForOption(FormatOption); bool terseOutput = context.ParseResult.GetValueForOption(TerseOutputOption); - string settingsFile = context.ParseResult.GetValueForOption(SettingsFileOption); LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption); bool inlineLocal = context.ParseResult.GetValueForOption(InlineLocalOption); bool inlineExternal = context.ParseResult.GetValueForOption(InlineExternalOption); @@ -56,7 +54,7 @@ public async Task InvokeAsync(InvocationContext context) var logger = loggerFactory.CreateLogger(); try { - await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, format, terseOutput, settingsFile, logLevel, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, cancellationToken); + await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, format, terseOutput, logLevel, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, cancellationToken); return 0; } diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 6c9b54e04..21c5a44f0 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -51,4 +51,12 @@ + + + + <_Parameter1>Microsoft.OpenApi.Hidi.Tests + + + + diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 307b91be1..896c4ca8b 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -27,7 +27,6 @@ using System.Xml.Xsl; using System.Xml; using System.Reflection; -using Microsoft.Extensions.Configuration; namespace Microsoft.OpenApi.Hidi { @@ -45,7 +44,6 @@ public static async Task TransformOpenApiDocument( string? version, OpenApiFormat? format, bool terseOutput, - string settingsFile, LogLevel logLevel, bool inlineLocal, bool inlineExternal, @@ -100,8 +98,7 @@ CancellationToken cancellationToken stream = ApplyFilter(csdl, csdlFilter, transform); stream.Position = 0; } - - document = await ConvertCsdlToOpenApi(stream, settingsFile); + document = await ConvertCsdlToOpenApi(stream); stopwatch.Stop(); logger.LogTrace("{timestamp}ms: Generated OpenAPI with {paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count); } @@ -110,7 +107,7 @@ CancellationToken cancellationToken { stream = await GetStream(openapi, logger, cancellationToken); - using (logger.BeginScope($"Parse OpenAPI: {openapi}",openapi)) + using (logger.BeginScope($"Parse OpenAPI: {openapi}", openapi)) { stopwatch.Restart(); var result = await new OpenApiStreamReader(new OpenApiReaderSettings @@ -248,8 +245,8 @@ private static Stream ApplyFilter(string csdl, string entitySetOrSingleton, XslC /// Implementation of the validate command /// public static async Task ValidateOpenApiDocument( - string openapi, - LogLevel logLevel, + string openapi, + LogLevel logLevel, CancellationToken cancellationToken) { using var loggerFactory = Logger.ConfigureLogger(logLevel); @@ -273,7 +270,7 @@ public static async Task ValidateOpenApiDocument( RuleSet = ValidationRuleSet.GetDefaultRuleSet() } ).ReadAsync(stream); - + logger.LogTrace("{timestamp}ms: Completed parsing.", stopwatch.ElapsedMilliseconds); document = result.OpenApiDocument; @@ -287,7 +284,7 @@ public static async Task ValidateOpenApiDocument( logger.LogError(error.ToString()); } } - } + } stopwatch.Stop(); } @@ -307,32 +304,17 @@ public static async Task ValidateOpenApiDocument( } } - public static IConfiguration GetConfiguration(string settingsFile) - { - settingsFile ??= "appsettings.json"; - - IConfiguration config = new ConfigurationBuilder() - .AddJsonFile(settingsFile, true) - .Build(); - - return config; - } - /// /// Converts CSDL to OpenAPI /// /// The CSDL stream. /// An OpenAPI document. - public static async Task ConvertCsdlToOpenApi(Stream csdl, string settingsFile = null) + public static async Task ConvertCsdlToOpenApi(Stream csdl) { using var reader = new StreamReader(csdl); var csdlText = await reader.ReadToEndAsync(); var edmModel = CsdlReader.Parse(XElement.Parse(csdlText).CreateReader()); - - var config = GetConfiguration(settingsFile); - var settings = config.GetSection("OpenApiConvertSettings").Get(); -<<<<<<< HEAD var settings = new OpenApiConvertSettings() { AddSingleQuotesForStringParameters = true, @@ -340,7 +322,7 @@ public static async Task ConvertCsdlToOpenApi(Stream csdl, stri DeclarePathParametersOnPathItem = true, EnableKeyAsSegment = true, EnableOperationId = true, - ErrorResponsesAsDefault = false, + ErrorResponsesAsDefault = false, PrefixEntityTypeNameBeforeKey = true, TagDepth = 2, EnablePagination = true, @@ -353,29 +335,6 @@ public static async Task ConvertCsdlToOpenApi(Stream csdl, stri EnableCount = true, UseSuccessStatusCodeRange = true }; -======= - settings ??= new OpenApiConvertSettings() - { - AddSingleQuotesForStringParameters = true, - AddEnumDescriptionExtension = true, - DeclarePathParametersOnPathItem = true, - EnableKeyAsSegment = true, - EnableOperationId = true, - ErrorResponsesAsDefault = false, - PrefixEntityTypeNameBeforeKey = true, - TagDepth = 2, - EnablePagination = true, - EnableDiscriminatorValue = true, - EnableDerivedTypesReferencesForRequestBody = false, - EnableDerivedTypesReferencesForResponses = false, - ShowRootPath = false, - ShowLinks = false, - ExpandDerivedTypesNavigationProperties = false, - EnableCount = true, - UseSuccessStatusCodeRange = true - }; - ->>>>>>> e2101373 (Add a settingsFile parameter that allows one to input a path to the settingsfile) OpenApiDocument document = edmModel.ConvertToOpenApi(settings); document = FixReferences(document); @@ -399,7 +358,7 @@ public static OpenApiDocument FixReferences(OpenApiDocument document) return doc; } - + /// /// Takes in a file stream, parses the stream into a JsonDocument and gets a list of paths and Http methods /// @@ -422,13 +381,13 @@ public static Dictionary> ParseJsonCollectionFile(Stream st private static Dictionary> EnumerateJsonDocument(JsonElement itemElement, Dictionary> paths) { var itemsArray = itemElement.GetProperty("item"); - + foreach (var item in itemsArray.EnumerateArray()) { - if(item.ValueKind == JsonValueKind.Object) + if (item.ValueKind == JsonValueKind.Object) { - if(item.TryGetProperty("request", out var request)) - { + if (item.TryGetProperty("request", out var request)) + { // Fetch list of methods and urls from collection, store them in a dictionary var path = request.GetProperty("url").GetProperty("raw").ToString(); var method = request.GetProperty("method").ToString(); @@ -440,11 +399,11 @@ private static Dictionary> EnumerateJsonDocument(JsonElemen { paths[path].Add(method); } - } - else - { + } + else + { EnumerateJsonDocument(item, paths); - } + } } else { diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 3af6818da..dba3abd2d 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -2,14 +2,8 @@ // Licensed under the MIT license. using System.CommandLine; -using System.CommandLine.Builder; -using System.CommandLine.Hosting; -using System.CommandLine.Parsing; - using System.IO; using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Hidi.Handlers; @@ -19,7 +13,8 @@ static class Program { static async Task Main(string[] args) { - var rootCommand = new RootCommand() { + var rootCommand = new RootCommand() + { }; // command option parameters and aliases @@ -47,9 +42,6 @@ static async Task Main(string[] args) var terseOutputOption = new Option("--terse-output", "Produce terse json output"); terseOutputOption.AddAlias("--to"); - var settingsFileOption = new Option("--settingsFile", "The configuration file with CSDL conversion settings."); - settingsFileOption.AddAlias("--sf"); - var logLevelOption = new Option("--log-level", () => LogLevel.Information, "The log level to use when logging messages to the main output."); logLevelOption.AddAlias("--ll"); @@ -74,7 +66,7 @@ static async Task Main(string[] args) logLevelOption }; - validateCommand.Handler = new ValidateCommandHandler + validateCommand.Handler = new ValidateCommandHandler { DescriptionOption = descriptionOption, LogLevelOption = logLevelOption @@ -90,8 +82,7 @@ static async Task Main(string[] args) versionOption, formatOption, terseOutputOption, - settingsFileOption, - logLevelOption, + logLevelOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption, @@ -109,7 +100,6 @@ static async Task Main(string[] args) VersionOption = versionOption, FormatOption = formatOption, TerseOutputOption = terseOutputOption, - SettingsFileOption = settingsFileOption, LogLevelOption = logLevelOption, FilterByOperationIdsOption = filterByOperationIdsOption, FilterByTagsOption = filterByTagsOption, @@ -121,20 +111,9 @@ static async Task Main(string[] args) rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); - // Parse the incoming args and invoke the handler await rootCommand.InvokeAsync(args); - - //await new CommandLineBuilder(rootCommand) - // .UseHost(_ => Host.CreateDefaultBuilder(), - // host => { - // var config = host.Services.GetRequiredService(); - // }) - // .UseDefaults() - // .Build() - // .InvokeAsync(args); - //// Wait for logger to write messages to the console before exiting await Task.Delay(10); } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 44d0740be..c2fb3798f 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; -using System.IO; -using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using Microsoft.OpenApi.Hidi; using Microsoft.OpenApi.OData; @@ -54,18 +51,25 @@ public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocumen Assert.Equal(expectedPathCount, subsetOpenApiDocument.Paths.Count); } - [Fact] - public void ReturnOpenApiConvertSettings() + [Theory] + [InlineData("UtilityFiles/appsettingstest.json")] + [InlineData(null)] + public void ReturnOpenApiConvertSettingsWhenSettingsFileIsProvided(string filePath) { // Arrange - var filePath = "C:/Users/v-makim/source/repos/OpenAPI.NET/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/appsettingstest.json"; var config = OpenApiService.GetConfiguration(filePath); - - // Act + + // Act and Assert var settings = config.GetSection("OpenApiConvertSettings").Get(); - // Assert - Assert.NotNull(settings); + if (filePath == null) + { + Assert.Null(settings); + } + else + { + Assert.NotNull(settings); + } } } } From ed843e6ca3d0b0e447adc5adc7cb7e5af2ada251 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 21 Nov 2022 11:24:44 +0300 Subject: [PATCH 31/83] Add conversion setting --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 896c4ca8b..04887dce6 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -333,7 +333,8 @@ public static async Task ConvertCsdlToOpenApi(Stream csdl) ShowLinks = false, ExpandDerivedTypesNavigationProperties = false, EnableCount = true, - UseSuccessStatusCodeRange = true + UseSuccessStatusCodeRange = true, + EnableTypeDisambiguationForDefaultValueOfOdataTypeProperty = true }; OpenApiDocument document = edmModel.ConvertToOpenApi(settings); From 9e67b914183bd713e39a7cf412baf6f6f71ce3cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:01:49 +0000 Subject: [PATCH 32/83] Bump Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers Bumps [Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers](https://github.com/dotnet/upgrade-assistant) from 0.4.346202 to 0.4.355802. - [Release notes](https://github.com/dotnet/upgrade-assistant/releases) - [Changelog](https://github.com/dotnet/upgrade-assistant/blob/main/CHANGELOG.md) - [Commits](https://github.com/dotnet/upgrade-assistant/commits) --- updated-dependencies: - dependency-name: Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers 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 cf3ff2225..6c6f8cac9 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -7,7 +7,7 @@ true - + all From 33480188e400d2305b6bdc2eb3d649f1231fc2e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:01:40 +0000 Subject: [PATCH 33/83] Bump Verify.Xunit from 18.4.0 to 19.0.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 18.4.0 to 19.0.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-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 666a2b39b..2c3854a74 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + all From 0029813aae746002aff745870676a967b8c85437 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 8 Nov 2022 10:26:15 -0500 Subject: [PATCH 34/83] - upgrades to dotnet 7 Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 4 ++-- .github/workflows/ci-cd.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .vscode/launch.json | 2 +- Dockerfile | 6 +++--- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 7 ++++++- .../Microsoft.OpenApi.Workbench.csproj | 2 +- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 4 ++-- .../Microsoft.OpenApi.SmokeTests.csproj | 4 ++-- .../Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 11 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 2f1b6b9b5..363654179 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -31,9 +31,9 @@ stages: - job: build steps: - task: UseDotNet@2 - displayName: 'Use .NET 6' + displayName: 'Use .NET' inputs: - version: 6.x + version: 7.x - task: PoliCheck@1 displayName: 'Run PoliCheck "/src"' diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b394e018b..097fc3b96 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: 7.0.x - name: Data gatherer id: data_gatherer diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index eb56ea14f..89d7e62c1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,7 +19,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: 7.0.x - name: Initialize CodeQL id: init_codeql diff --git a/.vscode/launch.json b/.vscode/launch.json index b59349979..974002cfe 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/net6.0/Microsoft.OpenApi.Hidi.dll", + "program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net7.0/Microsoft.OpenApi.Hidi.dll", "args": [], "cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/Dockerfile b/Dockerfile index 8326ce3b9..6b3507124 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env WORKDIR /app COPY ./src ./hidi/src WORKDIR /app/hidi RUN dotnet publish ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -c Release -FROM mcr.microsoft.com/dotnet/runtime:6.0 as runtime +FROM mcr.microsoft.com/dotnet/runtime:7.0 as runtime WORKDIR /app -COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net6.0 ./ +COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net7.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 21c5a44f0..3f13d7dee 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 9.0 true http://go.microsoft.com/fwlink/?LinkID=288890 @@ -43,7 +43,12 @@ +<<<<<<< HEAD +======= + + +>>>>>>> 973cd6da (- upgrades to dotnet 7) diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 6c6f8cac9..ad6989d05 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -1,6 +1,6 @@  - net6.0-windows + net7.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 d73d8af81..f450e2ff7 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 @@ - net6.0 + net7.0 enable enable 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 9eebce978..6d2b46c83 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 @@  - net6.0 + net7.0 false Microsoft @@ -265,7 +265,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index bb1cf129d..9c88e8394 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 @@ -9,7 +9,7 @@ - + all diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 2c3854a74..ecd30cfdd 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net7.0 false Microsoft From e3caf21487b0667ce30552e8a5908915d06d8c82 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 10 Nov 2022 09:00:14 -0500 Subject: [PATCH 35/83] - adds dotnet 6 since ESRP requires it Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 363654179..cc34d8e1f 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -31,7 +31,12 @@ stages: - job: build steps: - task: UseDotNet@2 - displayName: 'Use .NET' + displayName: 'Use .NET 6' # needed for ESRP signing + inputs: + version: 6.x + + - task: UseDotNet@2 + displayName: 'Use .NET 7' inputs: version: 7.x From 7b2c65e05e55e7d8cae05a9226ba6a1c9c7847d8 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 10 Nov 2022 09:42:01 -0500 Subject: [PATCH 36/83] - switches to dotnet 2 to fix ESRP Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index cc34d8e1f..4ce92b8e9 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -31,9 +31,9 @@ stages: - job: build steps: - task: UseDotNet@2 - displayName: 'Use .NET 6' # needed for ESRP signing + displayName: 'Use .NET 2' # needed for ESRP signing inputs: - version: 6.x + version: 2.x - task: UseDotNet@2 displayName: 'Use .NET 7' From 2b2f46dfc7ea583f7cf682bdcf02455eb086d1bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Nov 2022 21:02:32 +0000 Subject: [PATCH 37/83] Bump Verify.Xunit from 19.0.0 to 19.1.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 19.0.0 to 19.1.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/19.0.0...19.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 ecd30cfdd..e2a21cc74 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + all From a63499be25bef0bfd21591cd6aba8a1c869f991f Mon Sep 17 00:00:00 2001 From: Afsal Rahman Date: Wed, 14 Dec 2022 11:47:21 +0530 Subject: [PATCH 38/83] merge conflicts --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 3f13d7dee..c7f84666a 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -43,12 +43,8 @@ -<<<<<<< HEAD - -======= ->>>>>>> 973cd6da (- upgrades to dotnet 7) From f495f844f90241e131aab03eb70c863407b3435e Mon Sep 17 00:00:00 2001 From: Afsal Rahman Date: Wed, 14 Dec 2022 11:51:59 +0530 Subject: [PATCH 39/83] merge conflicts --- .../V3/OpenApiV3VersionService.cs | 7 +++++-- src/Microsoft.OpenApi/Models/OpenApiReference.cs | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index 45cd5afae..df8ade3a3 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs @@ -76,6 +76,7 @@ public OpenApiReference ConvertToOpenApiReference( string summary = null, string description = null) { + var openApiReference = new OpenApiReference(); if (!string.IsNullOrWhiteSpace(reference)) { var segments = reference.Split('#'); @@ -136,11 +137,13 @@ public OpenApiReference ConvertToOpenApiReference( } id = localSegments[3]; } + else + { + openApiReference.IsFragrament = true; + } return new OpenApiReference { - Summary = summary, - Description = description, ExternalResource = segments[0], Type = type, Id = id diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index a558e4394..8c47d620d 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -58,6 +58,11 @@ public class OpenApiReference : IOpenApiSerializable /// public bool IsLocal => ExternalResource == null; + /// + /// Gets a flag indicating whether a file is a valid OpenAPI document or a fragment + /// + public bool IsFragrament = false; + /// /// The OpenApiDocument that is hosting the OpenApiReference instance. This is used to enable dereferencing the reference. /// @@ -217,7 +222,12 @@ private string GetExternalReferenceV3() { if (Id != null) { - return ExternalResource + "#/components/" + Type.GetDisplayName() + "/"+ Id; + if (IsFragrament) + { + return ExternalResource + "#" + Id; + } + + return ExternalResource + "#/components/" + Type.GetDisplayName() + "/"+ Id; } return ExternalResource; From afcca139b1433a97139d98026abcb9cbde4984a8 Mon Sep 17 00:00:00 2001 From: Afsal Rahman Date: Wed, 14 Dec 2022 11:54:32 +0530 Subject: [PATCH 40/83] merge conflicts --- .../Microsoft.OpenApi.Readers.Tests.csproj | 3 +++ .../V3Tests/OpenApiDocumentTests.cs | 1 + .../documentWithExternalRefs.yaml | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/documentWithExternalRefs.yaml 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 6d2b46c83..eeb3a97a5 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -158,6 +158,9 @@ Never + + Never + Never diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 15b08166e..ef5d58d5e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.IO; using System.Linq; +using System.Text; using System.Threading; using FluentAssertions; using Microsoft.OpenApi.Any; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/documentWithExternalRefs.yaml b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/documentWithExternalRefs.yaml new file mode 100644 index 000000000..c0b7b3a25 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiDocument/documentWithExternalRefs.yaml @@ -0,0 +1,16 @@ + openapi: 3.0.1 + info: + title: anyOf-oneOf + license: + name: MIT + version: 1.0.0 + paths: { } + components: + schemas: + Nested: + type: object + properties: + AnyOf: + anyOf: + - $ref: file:///C:/MySchemas.json#/definitions/ArrayObject + - $ref: ../foo/schemas.yaml#/components/schemas/Number \ No newline at end of file From bd827ac30b074a6292c9a47382f48972dbc24ef1 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 18 Nov 2022 12:57:52 +0300 Subject: [PATCH 41/83] Update public API --- 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 b42325207..de3b52e0c 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -780,6 +780,7 @@ namespace Microsoft.OpenApi.Models } public class OpenApiReference : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { + public bool IsFragrament; public OpenApiReference() { } public OpenApiReference(Microsoft.OpenApi.Models.OpenApiReference reference) { } public string Description { get; set; } From efd904a34bcb93a829c328385b75885cb81a483b Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 18 Nov 2022 16:13:22 +0300 Subject: [PATCH 42/83] Move variable declaration closer to assignment --- src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index df8ade3a3..29a96bfdc 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs @@ -76,7 +76,6 @@ public OpenApiReference ConvertToOpenApiReference( string summary = null, string description = null) { - var openApiReference = new OpenApiReference(); if (!string.IsNullOrWhiteSpace(reference)) { var segments = reference.Split('#'); @@ -119,6 +118,8 @@ public OpenApiReference ConvertToOpenApiReference( } // Where fragments point into a non-OpenAPI document, the id will be the complete fragment identifier string id = segments[1]; + var openApiReference = new OpenApiReference(); + // $ref: externalSource.yaml#/Pet if (id.StartsWith("/components/")) { From 9a434197c597022749bde99ef5a323c7ea82bcbb Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 21 Nov 2022 10:30:32 +0300 Subject: [PATCH 43/83] Bump up lib versions from preview to stable releases --- 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 c7f84666a..4da2ea986 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -15,7 +15,7 @@ Microsoft.OpenApi.Hidi hidi ./../../artifacts - 1.1.0-preview3 + 1.1.0 OpenAPI.NET CLI tool for slicing OpenAPI documents © Microsoft Corporation. All rights reserved. OpenAPI .NET diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 0f9564c2a..3ddb197ad 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -11,7 +11,7 @@ Microsoft Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers - 1.4.4-preview1 + 1.4.4 OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. OpenAPI .NET diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 1affa74c6..50d026f91 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -11,7 +11,7 @@ Microsoft Microsoft.OpenApi Microsoft.OpenApi - 1.4.4-preview1 + 1.4.4 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET From e9b88c761d6a35703877bfdf824054caec518f2c Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 22 Nov 2022 16:49:23 +0300 Subject: [PATCH 44/83] Add condition to ensure collectionFormat is only written out if schema type is array --- src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index e0e472721..aa7983500 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -377,7 +377,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) // allowEmptyValue writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false); - if (this.In == ParameterLocation.Query) + if (this.In == ParameterLocation.Query && Schema?.Type == "array") { if (this.Style == ParameterStyle.Form && this.Explode == true) { From e3e730bff3c7b07cce65cdd9e77fd31cdfb97e77 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 22 Nov 2022 16:49:56 +0300 Subject: [PATCH 45/83] Update verify snapshots --- ...DocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt | 3 +-- ...dDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt | 2 +- ...eferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt | 3 +-- ...ReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt index a991e0761..a2e4fbd4c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt @@ -46,8 +46,7 @@ "name": "limit", "description": "maximum number of results to return", "type": "integer", - "format": "int32", - "collectionFormat": "multi" + "format": "int32" } ], "responses": { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt index 5ce01bf79..081bcda08 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32","collectionFormat":"multi"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt index 1ee60de40..443881617 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt @@ -46,8 +46,7 @@ "name": "limit", "description": "maximum number of results to return", "type": "integer", - "format": "int32", - "collectionFormat": "multi" + "format": "int32" } ], "responses": { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt index 682b253b7..3818a4799 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32","collectionFormat":"multi"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"$ref":"#/definitions/pet"}}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"$ref":"#/definitions/newPet"}}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"$ref":"#/definitions/pet"}}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"$ref":"#/definitions/newPet"}}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file From b40384c82213147135c1dc571a27ab639e1b93ef Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 22 Nov 2022 17:13:22 +0300 Subject: [PATCH 46/83] Address PR feedback --- src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index aa7983500..a57674da3 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.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.Runtime; using Microsoft.OpenApi.Any; @@ -377,7 +378,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) // allowEmptyValue writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false); - if (this.In == ParameterLocation.Query && Schema?.Type == "array") + if (this.In == ParameterLocation.Query && "array".Equals(Schema?.Type, StringComparison.OrdinalIgnoreCase)) { if (this.Style == ParameterStyle.Form && this.Explode == true) { From 2114c90a89e924c1c6e25aa1641bbef4e3197fc5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Nov 2022 09:38:17 +0300 Subject: [PATCH 47/83] Bump Newtonsoft.Json from 13.0.1 to 13.0.2 (#1091) Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 13.0.1 to 13.0.2. - [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases) - [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/13.0.1...13.0.2) --- updated-dependencies: - dependency-name: Newtonsoft.Json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../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 eeb3a97a5..af4ca74c0 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -268,7 +268,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 9c88e8394..9634f9358 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -9,7 +9,7 @@ - + all diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index e2a21cc74..8de99ad85 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -18,7 +18,7 @@ - + From c3894a45daf488f5b31817c6a046302668167657 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 23 Nov 2022 11:03:03 +0300 Subject: [PATCH 48/83] Use backing property to check whether user has explicitly set style, if not, we don't write it out. --- src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index a57674da3..184dbc751 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; @@ -239,9 +239,12 @@ public void SerializeAsV3WithoutReference(IOpenApiWriter writer) // allowEmptyValue writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false); - + // style - writer.WriteProperty(OpenApiConstants.Style, Style?.GetDisplayName()); + if (_style.HasValue) + { + writer.WriteProperty(OpenApiConstants.Style, Style.Value.GetDisplayName()); + } // explode writer.WriteProperty(OpenApiConstants.Explode, Explode, Style.HasValue && Style.Value == ParameterStyle.Form); From 49318b13fb5fd6934a9f965135f63aec8945dfec Mon Sep 17 00:00:00 2001 From: Afsal Rahman Date: Wed, 14 Dec 2022 11:55:39 +0530 Subject: [PATCH 49/83] merge conflicts --- .../Models/OpenApiDocumentTests.cs | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 6a185b556..0a07d304e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -1429,6 +1429,7 @@ public void CopyConstructorForAdvancedDocumentWorks() Assert.NotNull(doc.Components); } +<<<<<<< HEAD [Theory] [InlineData(true)] [InlineData(false)] @@ -1449,10 +1450,15 @@ public async void SerializeDocumentWithWebhooksAsV3JsonWorks(bool produceTerseOu [Fact] public void SerializeDocumentWithWebhooksAsV3YamlWorks() +======= + [Fact] + public void SerializeV2DocumentWithStyleAsNullDoesNotWriteOutStyleValue() +>>>>>>> 3eb4f02c (Add test to validate) { // Arrange var expected = @"openapi: 3.0.1 info: +<<<<<<< HEAD title: Webhook Example version: 1.0.0 paths: { } @@ -1485,11 +1491,93 @@ public void SerializeDocumentWithWebhooksAsV3YamlWorks() // Act var actual = DocumentWithWebhooks.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); +======= + title: magic style + version: 1.0.0 +paths: + /foo: + get: + parameters: + - name: id + in: query + schema: + type: object + additionalProperties: + type: integer + responses: + '200': + description: foo + content: + text/plain: + schema: + type: string"; + + var doc = new OpenApiDocument + { + Info = new OpenApiInfo + { + Title = "magic style", + Version = "1.0.0" + }, + Paths = new OpenApiPaths + { + ["/foo"] = new OpenApiPathItem + { + Operations = new Dictionary + { + [OperationType.Get] = new OpenApiOperation + { + Parameters = new List + { + new OpenApiParameter + { + Name = "id", + In = ParameterLocation.Query, + Schema = new OpenApiSchema + { + Type = "object", + AdditionalProperties = new OpenApiSchema + { + Type = "integer" + } + } + } + }, + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse + { + Description = "foo", + Content = new Dictionary + { + ["text/plain"] = new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = "string" + } + } + } + } + } + } + } + } + } + }; + + // Act + var actual = doc.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); +>>>>>>> 3eb4f02c (Add test to validate) // Assert actual = actual.MakeLineBreaksEnvironmentNeutral(); expected = expected.MakeLineBreaksEnvironmentNeutral(); +<<<<<<< HEAD Assert.Equal(expected, actual); +======= + actual.Should().Be(expected); +>>>>>>> 3eb4f02c (Add test to validate) } } } From 63687b1f76a0ed966565088761bad2b369782dbd Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 23 Nov 2022 11:29:00 +0300 Subject: [PATCH 50/83] Clean up tests --- src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 2 +- ...3JsonWorks_produceTerseOutput=False.verified.txt | 4 ---- ...3JsonWorks_produceTerseOutput=False.verified.txt | 4 ---- ...3JsonWorks_produceTerseOutput=False.verified.txt | 2 -- .../Models/OpenApiOperationTests.cs | 13 ++++--------- ...WorksAsync_produceTerseOutput=False.verified.txt | 3 +-- .../Models/OpenApiParameterTests.cs | 3 +-- 7 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 184dbc751..fa62f0b79 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; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt index 5b27add35..a688f8525 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -30,7 +30,6 @@ "name": "tags", "in": "query", "description": "tags to filter by", - "style": "form", "schema": { "type": "array", "items": { @@ -42,7 +41,6 @@ "name": "limit", "in": "query", "description": "maximum number of results to return", - "style": "form", "schema": { "type": "integer", "format": "int32" @@ -266,7 +264,6 @@ "in": "path", "description": "ID of pet to fetch", "required": true, - "style": "simple", "schema": { "type": "integer", "format": "int64" @@ -378,7 +375,6 @@ "in": "path", "description": "ID of pet to delete", "required": true, - "style": "simple", "schema": { "type": "integer", "format": "int64" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt index f272b26eb..f1da0b354 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -30,7 +30,6 @@ "name": "tags", "in": "query", "description": "tags to filter by", - "style": "form", "schema": { "type": "array", "items": { @@ -42,7 +41,6 @@ "name": "limit", "in": "query", "description": "maximum number of results to return", - "style": "form", "schema": { "type": "integer", "format": "int32" @@ -151,7 +149,6 @@ "in": "path", "description": "ID of pet to fetch", "required": true, - "style": "simple", "schema": { "type": "integer", "format": "int64" @@ -205,7 +202,6 @@ "in": "path", "description": "ID of pet to delete", "required": true, - "style": "simple", "schema": { "type": "integer", "format": "int64" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt index 8b90dd0ee..c2e9f5312 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -20,7 +20,6 @@ "in": "path", "description": "The first operand", "required": true, - "style": "simple", "schema": { "type": "integer", "my-extension": 4 @@ -32,7 +31,6 @@ "in": "path", "description": "The second operand", "required": true, - "style": "simple", "schema": { "type": "integer", "my-extension": 4 diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index 368aeb227..2079a3122 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -334,13 +334,11 @@ public void SerializeOperationWithBodyAsV3JsonWorks() ""parameters"": [ { ""name"": ""parameter1"", - ""in"": ""path"", - ""style"": ""simple"" + ""in"": ""path"" }, { ""name"": ""parameter2"", - ""in"": ""header"", - ""style"": ""simple"" + ""in"": ""header"" } ], ""requestBody"": { @@ -409,13 +407,11 @@ public void SerializeAdvancedOperationWithTagAndSecurityAsV3JsonWorks() ""parameters"": [ { ""name"": ""parameter1"", - ""in"": ""path"", - ""style"": ""simple"" + ""in"": ""path"" }, { ""name"": ""parameter2"", - ""in"": ""header"", - ""style"": ""simple"" + ""in"": ""header"" } ], ""requestBody"": { @@ -505,7 +501,6 @@ public void SerializeOperationWithFormDataAsV3JsonWorks() ""in"": ""path"", ""description"": ""ID of pet that needs to be updated"", ""required"": true, - ""style"": ""simple"", ""schema"": { ""type"": ""string"" } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index f4424fa30..5275532e8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1,5 +1,4 @@ { "name": "name1", - "in": "path", - "style": "simple" + "in": "path" } \ 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 cfcc56d15..2f57673af 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs @@ -213,8 +213,7 @@ public void SerializeBasicParameterAsV3JsonWorks() // Arrange var expected = @"{ ""name"": ""name1"", - ""in"": ""path"", - ""style"": ""simple"" + ""in"": ""path"" }"; // Act From e7822a292e19343dff52b099434722d68545ed2a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 23 Nov 2022 11:52:37 +0300 Subject: [PATCH 51/83] Update verifier snapshot --- ...dDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt index a688f8525..a94db37b7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "openapi": "3.0.1", "info": { "title": "Swagger Petstore (Simple)", From 590830e982d3df2b496262d975739456d1a2829f Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 23 Nov 2022 14:01:52 +0300 Subject: [PATCH 52/83] Delete verifier --- ...orks_produceTerseOutput=False.verified.txt | 495 ------------------ 1 file changed, 495 deletions(-) delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index a94db37b7..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,495 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore (Simple)", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://helloreverb.com/terms/", - "contact": { - "name": "Swagger API team", - "url": "http://swagger.io", - "email": "foo@example.com" - }, - "license": { - "name": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, - "version": "1.0.0" - }, - "servers": [ - { - "url": "http://petstore.swagger.io/api" - } - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "schema": { - "type": "integer", - "format": "int32" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "requestBody": { - "description": "Pet to add to the store", - "content": { - "application/json": { - "schema": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - }, - "application/xml": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "pet": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "newPet": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "errorModel": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } -} \ No newline at end of file From 794386ab53612d2495be3a67aa0e8e6664606266 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 23 Nov 2022 14:08:20 +0300 Subject: [PATCH 53/83] Revert change --- ...orks_produceTerseOutput=False.verified.txt | 495 ++++++++++++++++++ 1 file changed, 495 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..a94db37b7 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,495 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "content": { + "application/json": { + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "application/xml": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file From cf43c64a0ca89e629ea54ca538810654ca911825 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 25 Nov 2022 11:29:06 +0300 Subject: [PATCH 54/83] Remove test --- test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 0a07d304e..f4bd658cc 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -1060,7 +1060,6 @@ public OpenApiDocumentTests(ITestOutputHelper output) [Theory] [InlineData(true)] - [InlineData(false)] public async Task SerializeAdvancedDocumentAsV3JsonWorks(bool produceTerseOutput) { // Arrange From 7965b01fc1865b2ad352682617110a180fb3ac47 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 25 Nov 2022 11:53:24 +0300 Subject: [PATCH 55/83] Remove verified text --- ...orks_produceTerseOutput=False.verified.txt | 496 +----------------- 1 file changed, 1 insertion(+), 495 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt index a94db37b7..5f282702b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -1,495 +1 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore (Simple)", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://helloreverb.com/terms/", - "contact": { - "name": "Swagger API team", - "url": "http://swagger.io", - "email": "foo@example.com" - }, - "license": { - "name": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, - "version": "1.0.0" - }, - "servers": [ - { - "url": "http://petstore.swagger.io/api" - } - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "schema": { - "type": "integer", - "format": "int32" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "requestBody": { - "description": "Pet to add to the store", - "content": { - "application/json": { - "schema": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - }, - "application/xml": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "pet": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "newPet": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "errorModel": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } -} \ No newline at end of file + \ No newline at end of file From e5dd6ba48d8a2391e76848e1b12f726093427429 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 25 Nov 2022 11:57:32 +0300 Subject: [PATCH 56/83] Add verified text --- ...orks_produceTerseOutput=False.verified.txt | 496 +++++++++++++++++- 1 file changed, 495 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt index 5f282702b..a94db37b7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -1 +1,495 @@ - \ No newline at end of file +{ + "openapi": "3.0.1", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "content": { + "application/json": { + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "application/xml": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file From 943b7b8759421e01c9443855e729557ead887c4a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 25 Nov 2022 12:09:33 +0300 Subject: [PATCH 57/83] Return test --- test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index f4bd658cc..8341909a6 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -1059,7 +1059,8 @@ public OpenApiDocumentTests(ITestOutputHelper output) } [Theory] - [InlineData(true)] + //[InlineData(true)] + [InlineData(false)] public async Task SerializeAdvancedDocumentAsV3JsonWorks(bool produceTerseOutput) { // Arrange From a4f05798a6899cc2ec659886fcedb2c5bac16843 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 25 Nov 2022 12:13:34 +0300 Subject: [PATCH 58/83] Delete verified text --- ...edDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt index e3abf0e50..5f282702b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","style":"form","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","style":"form","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"application/xml":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"style":"simple","schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"application/xml":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"style":"simple","schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file + \ No newline at end of file From 2c27d78e9c49dc4fdca60994fb66010c7f17b528 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 25 Nov 2022 12:14:46 +0300 Subject: [PATCH 59/83] Add verified text --- ...edDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt index 5f282702b..72106e400 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"application/xml":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"application/xml":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file From e7e4e930037b5b2816dcf481b1b44d9c7d6e3222 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 25 Nov 2022 14:33:28 +0300 Subject: [PATCH 60/83] Revert change --- test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 8341909a6..c9e240ce5 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/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; @@ -1059,8 +1059,8 @@ public OpenApiDocumentTests(ITestOutputHelper output) } [Theory] - //[InlineData(true)] [InlineData(false)] + [InlineData(true)] public async Task SerializeAdvancedDocumentAsV3JsonWorks(bool produceTerseOutput) { // Arrange From a6b5d2095ed6a7ad91c86100a41635536112de34 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 28 Nov 2022 11:20:50 +0300 Subject: [PATCH 61/83] Remove static modifier as it creates static dependency of the document instance when running tests in parallel causing one to fail --- test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index c9e240ce5..33914113d 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.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.Globalization; using System.IO; +using System.Threading; using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Extensions; @@ -598,7 +599,7 @@ public class OpenApiDocumentTests public static OpenApiSchema ErrorModelSchema = AdvancedComponents.Schemas["errorModel"]; - public static OpenApiDocument AdvancedDocument = new OpenApiDocument + public OpenApiDocument AdvancedDocument = new OpenApiDocument { Info = new OpenApiInfo { From 6858f4cf233a17ccc62a9b117029d88898458e98 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 28 Nov 2022 11:21:07 +0300 Subject: [PATCH 62/83] Update verified snapshots --- ...rks2_produceTerseOutput=False.verified.txt | 495 ++++++++++++++++++ ...orks2_produceTerseOutput=True.verified.txt | 1 + 2 files changed, 496 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..a94db37b7 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=False.verified.txt @@ -0,0 +1,495 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "content": { + "application/json": { + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "application/xml": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..72106e400 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"application/xml":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"application/xml":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file From 628ee2c6b222cae126dccbaab247ce280fe18f8a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 21:01:40 +0000 Subject: [PATCH 63/83] Bump Verify.Xunit from 19.1.0 to 19.3.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 19.1.0 to 19.3.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/19.1.0...19.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 8de99ad85..40f9eb637 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + all From 8ceed9e3eafbf65340736a586540324444f4cad2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Dec 2022 21:03:37 +0000 Subject: [PATCH 64/83] Bump Moq from 4.18.2 to 4.18.3 Bumps [Moq](https://github.com/moq/moq4) from 4.18.2 to 4.18.3. - [Release notes](https://github.com/moq/moq4/releases) - [Changelog](https://github.com/moq/moq4/blob/main/CHANGELOG.md) - [Commits](https://github.com/moq/moq4/compare/v4.18.2...v4.18.3) --- updated-dependencies: - dependency-name: Moq dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.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.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj index f450e2ff7..a864bc5e4 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -10,7 +10,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 40f9eb637..b37500ccc 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -17,7 +17,7 @@ - + From cf58a232011dcae29762775e2add186b594963e4 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 5 Dec 2022 12:48:25 -0500 Subject: [PATCH 65/83] - adds missing validation methods Signed-off-by: Vincent Biret --- .../Microsoft.OpenApi.Readers.csproj | 2 +- .../Microsoft.OpenApi.csproj | 2 +- .../Validations/OpenApiValidator.cs | 96 ++++++++++++++++++- .../PublicApi/PublicApi.approved.txt | 18 ++++ 4 files changed, 115 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 3ddb197ad..816a797da 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -11,7 +11,7 @@ Microsoft Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers - 1.4.4 + 1.4.5 OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. OpenAPI .NET diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 50d026f91..a938a968f 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -11,7 +11,7 @@ Microsoft Microsoft.OpenApi Microsoft.OpenApi - 1.4.4 + 1.4.5 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs index ba2ed4129..a0aee12e7 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs @@ -20,7 +20,7 @@ public class OpenApiValidator : OpenApiVisitorBase, IValidationContext private readonly IList _warnings = new List(); /// - /// Create a vistor that will validate an OpenAPIDocument + /// Create a visitor that will validate an OpenAPIDocument /// /// public OpenApiValidator(ValidationRuleSet ruleSet) @@ -198,6 +198,100 @@ public void AddWarning(OpenApiValidatorWarning warning) /// The object to be validated public override void Visit(IList items) => Validate(items, items.GetType()); + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(OpenApiPathItem item) => Validate(item); + + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(OpenApiServerVariable item) => Validate(item); + + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(OpenApiSecurityScheme item) => Validate(item); + + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(OpenApiSecurityRequirement item) => Validate(item); + + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(OpenApiRequestBody item) => Validate(item); + + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(OpenApiPaths item) => Validate(item); + + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(OpenApiLink item) => Validate(item); + + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(OpenApiExample item) => Validate(item); + + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(OpenApiOperation item) => Validate(item); + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(IDictionary item) => Validate(item, item.GetType()); + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(IDictionary item) => Validate(item, item.GetType()); + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(IDictionary item) => Validate(item, item.GetType()); + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(IDictionary item) => Validate(item, item.GetType()); + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(IDictionary item) => Validate(item, item.GetType()); + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(IDictionary item) => Validate(item, item.GetType()); + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(IDictionary item) => Validate(item, item.GetType()); + /// + /// Execute validation rules against a + /// + /// The object to be validated + public override void Visit(IDictionary item) => Validate(item, item.GetType()); + private void Validate(T item) { var type = typeof(T); diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index de3b52e0c..470722baa 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1238,6 +1238,24 @@ namespace Microsoft.OpenApi.Validations public override void Visit(Microsoft.OpenApi.Models.OpenApiServer item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiTag item) { } public override void Visit(System.Collections.Generic.IList items) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiPathItem item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiServerVariable item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiSecurityScheme item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiSecurityRequirement item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiRequestBody item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiPaths item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiLink item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiExample item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiOperation item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } + } public class OpenApiValidatorError : Microsoft.OpenApi.Models.OpenApiError { From 9e1a91c13e0948911295b3386b7ac9b6acc8afbd Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 5 Dec 2022 13:15:27 -0500 Subject: [PATCH 66/83] - reorders public api definition Signed-off-by: Vincent Biret --- .../PublicApi/PublicApi.approved.txt | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 470722baa..94b81c2b4 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1225,37 +1225,36 @@ namespace Microsoft.OpenApi.Validations public override void Visit(Microsoft.OpenApi.Models.OpenApiContact item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiDocument item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiEncoding item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiExample item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiExternalDocs item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiHeader item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiInfo item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiLicense item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiLink item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiMediaType item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiOAuthFlow item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiOperation item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiParameter item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiPathItem item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiPaths item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiRequestBody item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiResponse item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiResponses item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiSchema item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiSecurityRequirement item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiSecurityScheme item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiServer item) { } - public override void Visit(Microsoft.OpenApi.Models.OpenApiTag item) { } - public override void Visit(System.Collections.Generic.IList items) { } - public override void Visit(Microsoft.OpenApi.Models.OpenApiPathItem item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiServerVariable item) { } - public override void Visit(Microsoft.OpenApi.Models.OpenApiSecurityScheme item) { } - public override void Visit(Microsoft.OpenApi.Models.OpenApiSecurityRequirement item) { } - public override void Visit(Microsoft.OpenApi.Models.OpenApiRequestBody item) { } - public override void Visit(Microsoft.OpenApi.Models.OpenApiPaths item) { } - public override void Visit(Microsoft.OpenApi.Models.OpenApiLink item) { } - public override void Visit(Microsoft.OpenApi.Models.OpenApiExample item) { } - public override void Visit(Microsoft.OpenApi.Models.OpenApiOperation item) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiTag item) { } public override void Visit(System.Collections.Generic.IDictionary item) { } - public override void Visit(System.Collections.Generic.IDictionary item) { } public override void Visit(System.Collections.Generic.IDictionary item) { } - public override void Visit(System.Collections.Generic.IDictionary item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } public override void Visit(System.Collections.Generic.IDictionary item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } public override void Visit(System.Collections.Generic.IDictionary item) { } + public override void Visit(System.Collections.Generic.IDictionary item) { } public override void Visit(System.Collections.Generic.IDictionary item) { } - public override void Visit(System.Collections.Generic.IDictionary item) { } - + public override void Visit(System.Collections.Generic.IList items) { } } public class OpenApiValidatorError : Microsoft.OpenApi.Models.OpenApiError { From 992a8e7aac3efe0bd2e06c6465474a8d7c8f17ae Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 29 Nov 2022 09:51:04 -0500 Subject: [PATCH 67/83] - adds coverage dependencies --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 4 ++++ .../Microsoft.OpenApi.Readers.Tests.csproj | 8 ++++++++ .../Microsoft.OpenApi.SmokeTests.csproj | 8 ++++++++ .../Microsoft.OpenApi.Tests.csproj | 8 ++++++++ 4 files changed, 28 insertions(+) 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 a864bc5e4..0902ff177 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -9,6 +9,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index af4ca74c0..a09695f70 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -265,6 +265,14 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 9634f9358..0fab323f7 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -8,6 +8,14 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index b37500ccc..5f6d0c748 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,6 +15,14 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + From 1dbcb00333530ad72a4932f0533636bca82ab0d2 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 29 Nov 2022 09:53:26 -0500 Subject: [PATCH 68/83] - adds sonarcloud workflow definition --- .github/workflows/sonarcloud.yml | 78 ++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/sonarcloud.yml diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 000000000..6812553ce --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,78 @@ +name: Sonarcloud +on: + workflow_dispatch: + push: + branches: + - main + paths-ignore: ['.vscode/**'] + pull_request: + types: [opened, synchronize, reopened] + paths-ignore: ['.vscode/**'] + +env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + +jobs: + checksecret: + name: check if SONAR_TOKEN is set in github secrets + runs-on: ubuntu-latest + outputs: + is_SONAR_TOKEN_set: ${{ steps.checksecret_job.outputs.is_SONAR_TOKEN_set }} + steps: + - name: Check whether unity activation requests should be done + id: checksecret_job + run: | + echo "is_SONAR_TOKEN_set=${{ env.SONAR_TOKEN != '' }}" >> $GITHUB_OUTPUT + build: + needs: [checksecret] + if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true' + name: Build + runs-on: ubuntu-latest + steps: + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: 11 + - name: Setup .NET 5 # At the moment the scanner requires dotnet 5 https://www.nuget.org/packages/dotnet-sonarscanner + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 5.0.x + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Cache SonarCloud packages + uses: actions/cache@v3 + 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 + with: + path: ./.sonar/scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + - name: Install SonarCloud scanner + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' + shell: pwsh + run: | + New-Item -Path ./.sonar/scanner -ItemType Directory + dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + CollectCoverage: true + CoverletOutputFormat: 'opencover' # https://github.com/microsoft/vstest/issues/4014#issuecomment-1307913682 + shell: pwsh + run: | + ./.sonar/scanner/dotnet-sonarscanner begin /k:"microsoft_OpenAPI.NET" /o:"microsoft" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="test/**/coverage.opencover.xml" + dotnet workload restore + dotnet build + dotnet test Microsoft.OpenApi.sln --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover + ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file From e7e3200168dba5c0c714bff6ac3ff4e578d878fa Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 29 Nov 2022 09:57:17 -0500 Subject: [PATCH 69/83] - switches to windows agent because of workbench projectg --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 6812553ce..d7efd6213 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -27,7 +27,7 @@ jobs: needs: [checksecret] if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true' name: Build - runs-on: ubuntu-latest + runs-on: windows-latest steps: - name: Set up JDK 11 uses: actions/setup-java@v3 From f53a031616c97b89b666eaedacbf9a2983872321 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 6 Dec 2022 10:44:11 +0300 Subject: [PATCH 70/83] Fixes bug where the schema copy constructor would run into a stack overflow due to wrong copying of AdditionalProperties object --- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 6019d7362..513b865df 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -280,7 +280,7 @@ public OpenApiSchema(OpenApiSchema schema) MaxProperties = schema?.MaxProperties ?? MaxProperties; MinProperties = schema?.MinProperties ?? MinProperties; AdditionalPropertiesAllowed = schema?.AdditionalPropertiesAllowed ?? AdditionalPropertiesAllowed; - AdditionalProperties = new(schema?.AdditionalProperties); + AdditionalProperties = schema?.AdditionalProperties != null ? new(schema?.AdditionalProperties) : null; Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null; Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(schema?.Example); Enum = schema?.Enum != null ? new List(schema.Enum) : null; From f06e10c383a9c0af30366d3445ae9ec9311f64fe Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 6 Dec 2022 10:44:49 +0300 Subject: [PATCH 71/83] Add test to validate --- .../Models/OpenApiSchemaTests.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 429129c1e..fd6fea2cb 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -463,5 +463,22 @@ public void SerializeAsV2ShouldSetFormatPropertyInParentSchemaIfPresentInChildre // Assert Assert.Equal(expectedV2Schema, v2Schema); } + + [Fact] + public void OpenApiSchemaCopyConstructorSucceeds() + { + var baseSchema = new OpenApiSchema() + { + Type = "string", + Format = "date" + }; + + var actualSchema = new OpenApiSchema(baseSchema) + { + Nullable = true + }; + + Assert.Equal("string", actualSchema.Type); + } } } From 96f1bdca4cd06aeb63919657b7ed944d0a490b4c Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 6 Dec 2022 10:46:56 +0300 Subject: [PATCH 72/83] Add test assertions --- test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index fd6fea2cb..447d01337 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -479,6 +479,8 @@ public void OpenApiSchemaCopyConstructorSucceeds() }; Assert.Equal("string", actualSchema.Type); + Assert.Equal("date", actualSchema.Format); + Assert.True(actualSchema.Nullable); } } } From 93a4c1cb389f487caa80f2f6ddc5069b13c333a4 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 1 Dec 2022 10:40:37 +0300 Subject: [PATCH 73/83] Add OpenApiTypeMapper that maps .NET primitive types to the OpenAPI schema type equivalent --- .../Extensions/OpenApiTypeMapper.cs | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs new file mode 100644 index 000000000..42b645b3a --- /dev/null +++ b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System; +using System.Collections.Generic; +using Microsoft.OpenApi.Models; + +namespace Microsoft.OpenApi.Extensions +{ + /// + /// Extension methods for . + /// + public static class OpenApiTypeMapper + { + private static readonly Dictionary> _simpleTypeToOpenApiSchema = new() + { + [typeof(bool)] = () => new OpenApiSchema { Type = "boolean" }, + [typeof(byte)] = () => new OpenApiSchema { Type = "string", Format = "byte" }, + [typeof(int)] = () => new OpenApiSchema { Type = "integer", Format = "int32" }, + [typeof(uint)] = () => new OpenApiSchema { Type = "integer", Format = "int32" }, + [typeof(long)] = () => new OpenApiSchema { Type = "integer", Format = "int64" }, + [typeof(ulong)] = () => new OpenApiSchema { Type = "integer", Format = "int64" }, + [typeof(float)] = () => new OpenApiSchema { Type = "number", Format = "float" }, + [typeof(double)] = () => new OpenApiSchema { Type = "number", Format = "double" }, + [typeof(decimal)] = () => new OpenApiSchema { Type = "number", Format = "double" }, + [typeof(DateTime)] = () => new OpenApiSchema { Type = "string", Format = "date-time" }, + [typeof(DateTimeOffset)] = () => new OpenApiSchema { Type = "string", Format = "date-time" }, + [typeof(Guid)] = () => new OpenApiSchema { Type = "string", Format = "uuid" }, + [typeof(char)] = () => new OpenApiSchema { Type = "string" }, + + // Nullable types + [typeof(bool?)] = () => new OpenApiSchema { Type = "boolean", Nullable = true }, + [typeof(byte?)] = () => new OpenApiSchema { Type = "string", Format = "byte", Nullable = true }, + [typeof(int?)] = () => new OpenApiSchema { Type = "integer", Format = "int32", Nullable = true }, + [typeof(uint?)] = () => new OpenApiSchema { Type = "integer", Format = "int32", Nullable = true }, + [typeof(long?)] = () => new OpenApiSchema { Type = "integer", Format = "int64", Nullable = true }, + [typeof(ulong?)] = () => new OpenApiSchema { Type = "integer", Format = "int64", Nullable = true }, + [typeof(float?)] = () => new OpenApiSchema { Type = "number", Format = "float", Nullable = true }, + [typeof(double?)] = () => new OpenApiSchema { Type = "number", Format = "double", Nullable = true }, + [typeof(decimal?)] = () => new OpenApiSchema { Type = "number", Format = "double", Nullable = true }, + [typeof(DateTime?)] = () => new OpenApiSchema { Type = "string", Format = "date-time", Nullable = true }, + [typeof(DateTimeOffset?)] = () => new OpenApiSchema { Type = "string", Format = "date-time", Nullable = true }, + [typeof(Guid?)] = () => new OpenApiSchema { Type = "string", Format = "uuid", Nullable = true }, + [typeof(char?)] = () => new OpenApiSchema { Type = "string", Nullable = true }, + + [typeof(Uri)] = () => new OpenApiSchema { Type = "string" }, // Uri is treated as simple string + [typeof(string)] = () => new OpenApiSchema { Type = "string" }, + [typeof(object)] = () => new OpenApiSchema { Type = "object" } + }; + + /// + /// Maps a simple type to an OpenAPI data type and format. + /// + /// Simple type. + /// + /// All the following types from http://swagger.io/specification/#data-types-12 are supported. + /// Other types including nullables and URL are also supported. + /// Common Name type format Comments + /// =========== ======= ====== ========================================= + /// integer integer int32 signed 32 bits + /// long integer int64 signed 64 bits + /// float number float + /// double number double + /// string string [empty] + /// byte string byte base64 encoded characters + /// binary string binary any sequence of octets + /// boolean boolean [empty] + /// date string date As defined by full-date - RFC3339 + /// dateTime string date-time As defined by date-time - RFC3339 + /// password string password Used to hint UIs the input needs to be obscured. + /// If the type is not recognized as "simple", System.String will be returned. + /// + public static OpenApiSchema MapTypeToOpenApiPrimitiveType(this Type type) + { + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + return _simpleTypeToOpenApiSchema.TryGetValue(type, out var result) + ? result() + : new OpenApiSchema { Type = "string" }; + } + } +} From f7ea11b78dab669e5361d83c1ec4b80af26b351b Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 1 Dec 2022 10:40:57 +0300 Subject: [PATCH 74/83] Add test and update public API interface --- .../Extensions/OpenApiTypeMapperTests.cs | 35 +++++++++++++++++++ .../PublicApi/PublicApi.approved.txt | 4 +++ 2 files changed, 39 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs diff --git a/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs new file mode 100644 index 000000000..450103e2c --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System; +using System.Collections.Generic; +using FluentAssertions; +using Microsoft.OpenApi.Extensions; +using Microsoft.OpenApi.Models; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Extensions +{ + public class OpenApiTypeMapperTests + { + [Theory] + [MemberData(nameof(PrimitiveTypeData))] + public void MapTypeToOpenApiPrimitiveTypeShouldSucceed(Type type, OpenApiSchema expected) + { + // Arrange & Act + var actual = OpenApiTypeMapper.MapTypeToOpenApiPrimitiveType(type); + + // Assert + actual.Should().BeEquivalentTo(expected); + } + + public static IEnumerable PrimitiveTypeData => new List + { + new object[] { typeof(int), new OpenApiSchema { Type = "integer", Format = "int32" } }, + new object[] { typeof(string), new OpenApiSchema { Type = "string" } }, + new object[] { typeof(double), new OpenApiSchema { Type = "number", Format = "double" } }, + new object[] { typeof(float?), new OpenApiSchema { Type = "number", Format = "float", Nullable = true } }, + new object[] { typeof(DateTimeOffset), new OpenApiSchema { Type = "string", Format = "date-time" } } + }; + } +} diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 94b81c2b4..787b536e0 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -282,6 +282,10 @@ namespace Microsoft.OpenApi.Extensions public static void SerializeAsYaml(this T element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion) where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } } + public static class OpenApiTypeMapper + { + public static Microsoft.OpenApi.Models.OpenApiSchema MapTypeToOpenApiPrimitiveType(this System.Type type) { } + } public static class StringExtensions { public static T GetEnumFromDisplayName(this string displayName) { } From 1d8e3cacb8462471e31962c5a9924715adfaab18 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 6 Dec 2022 10:23:47 +0300 Subject: [PATCH 75/83] Map OpenApiSchema types to simple type and add test to validate --- .../Extensions/OpenApiTypeMapper.cs | 47 ++++++++++++++++++- .../Extensions/OpenApiTypeMapperTests.cs | 34 +++++++++++--- 2 files changed, 73 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs index 42b645b3a..ec7235271 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs @@ -42,7 +42,7 @@ public static class OpenApiTypeMapper [typeof(DateTimeOffset?)] = () => new OpenApiSchema { Type = "string", Format = "date-time", Nullable = true }, [typeof(Guid?)] = () => new OpenApiSchema { Type = "string", Format = "uuid", Nullable = true }, [typeof(char?)] = () => new OpenApiSchema { Type = "string", Nullable = true }, - + [typeof(Uri)] = () => new OpenApiSchema { Type = "string" }, // Uri is treated as simple string [typeof(string)] = () => new OpenApiSchema { Type = "string" }, [typeof(object)] = () => new OpenApiSchema { Type = "object" } @@ -81,5 +81,50 @@ public static OpenApiSchema MapTypeToOpenApiPrimitiveType(this Type type) ? result() : new OpenApiSchema { Type = "string" }; } + + /// + /// Maps an OpenAPI data type and format to a simple type. + /// + /// The OpenApi data type + /// The simple type + /// + public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema) + { + if (schema == null) + { + throw new ArgumentNullException(nameof(schema)); + } + + var type = (schema.Type, schema.Format, schema.Nullable) switch + { + ("boolean", null, false) => typeof(bool), + ("integer", "int32", false) => typeof(int), + ("integer", "int64", false) => typeof(long), + ("number", "float", false) => typeof(float), + ("number", "double", false) => typeof(double), + ("number", "decimal", false) => typeof(decimal), + ("string", "byte", false) => typeof(byte), + ("string", "date-time", false) => typeof(DateTimeOffset), + ("string", "uuid", false) => typeof(Guid), + ("string", "duration", false) => typeof(TimeSpan), + ("string", "char", false) => typeof(char), + ("string", null, false) => typeof(string), + ("object", null, false) => typeof(object), + ("string", "uri", false) => typeof(Uri), + ("integer", "int32", true) => typeof(int?), + ("integer", "int64", true) => typeof(long?), + ("number", "float", true) => typeof(float?), + ("number", "double", true) => typeof(double?), + ("number", "decimal", true) => typeof(decimal?), + ("string", "byte", true) => typeof(byte?), + ("string", "date-time", true) => typeof(DateTimeOffset?), + ("string", "uuid", true) => typeof(Guid?), + ("string", "char", true) => typeof(char?), + ("boolean", null, true) => typeof(bool?), + _ => typeof(string), + }; + + return type; + } } } diff --git a/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs index 450103e2c..c2b6d9597 100644 --- a/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs +++ b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs @@ -12,6 +12,24 @@ namespace Microsoft.OpenApi.Tests.Extensions { public class OpenApiTypeMapperTests { + public static IEnumerable PrimitiveTypeData => new List + { + new object[] { typeof(int), new OpenApiSchema { Type = "integer", Format = "int32" } }, + new object[] { typeof(string), new OpenApiSchema { Type = "string" } }, + new object[] { typeof(double), new OpenApiSchema { Type = "number", Format = "double" } }, + new object[] { typeof(float?), new OpenApiSchema { Type = "number", Format = "float", Nullable = true } }, + new object[] { typeof(DateTimeOffset), new OpenApiSchema { Type = "string", Format = "date-time" } } + }; + + public static IEnumerable OpenApiDataTypes => new List + { + new object[] { new OpenApiSchema { Type = "integer", Format = "int32"}, typeof(int) }, + new object[] { new OpenApiSchema { Type = "string" }, typeof(string) }, + new object[] { new OpenApiSchema { Type = "number", Format = "double" }, typeof(double) }, + new object[] { new OpenApiSchema { Type = "number", Format = "float", Nullable = true }, typeof(float?) }, + new object[] { new OpenApiSchema { Type = "string", Format = "date-time" }, typeof(DateTimeOffset) } + }; + [Theory] [MemberData(nameof(PrimitiveTypeData))] public void MapTypeToOpenApiPrimitiveTypeShouldSucceed(Type type, OpenApiSchema expected) @@ -23,13 +41,15 @@ public void MapTypeToOpenApiPrimitiveTypeShouldSucceed(Type type, OpenApiSchema actual.Should().BeEquivalentTo(expected); } - public static IEnumerable PrimitiveTypeData => new List + [Theory] + [MemberData(nameof(OpenApiDataTypes))] + public void MapOpenApiSchemaTypeToSimpleTypeShouldSucceed(OpenApiSchema schema, Type expected) { - new object[] { typeof(int), new OpenApiSchema { Type = "integer", Format = "int32" } }, - new object[] { typeof(string), new OpenApiSchema { Type = "string" } }, - new object[] { typeof(double), new OpenApiSchema { Type = "number", Format = "double" } }, - new object[] { typeof(float?), new OpenApiSchema { Type = "number", Format = "float", Nullable = true } }, - new object[] { typeof(DateTimeOffset), new OpenApiSchema { Type = "string", Format = "date-time" } } - }; + // Arrange & Act + var actual = OpenApiTypeMapper.MapOpenApiPrimitiveTypeToSimpleType(schema); + + // Assert + actual.Should().Be(expected); + } } } From ffa4cf854a89f1c6a35fbfc3e7209d17912f5ea0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 6 Dec 2022 17:42:48 +0300 Subject: [PATCH 76/83] Update Uri format --- src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs index ec7235271..d8023b4cb 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs @@ -43,7 +43,7 @@ public static class OpenApiTypeMapper [typeof(Guid?)] = () => new OpenApiSchema { Type = "string", Format = "uuid", Nullable = true }, [typeof(char?)] = () => new OpenApiSchema { Type = "string", Nullable = true }, - [typeof(Uri)] = () => new OpenApiSchema { Type = "string" }, // Uri is treated as simple string + [typeof(Uri)] = () => new OpenApiSchema { Type = "string", Format = "uri"}, // Uri is treated as simple string [typeof(string)] = () => new OpenApiSchema { Type = "string" }, [typeof(object)] = () => new OpenApiSchema { Type = "object" } }; From c9d790fd04935874c1728f83ecb1dabc33573860 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 6 Dec 2022 18:00:16 +0300 Subject: [PATCH 77/83] Update type and format to lowercase --- src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs index d8023b4cb..16441a9e7 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs @@ -95,7 +95,7 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema throw new ArgumentNullException(nameof(schema)); } - var type = (schema.Type, schema.Format, schema.Nullable) switch + var type = (schema.Type?.ToLowerInvariant(), schema.Format.ToLowerInvariant(), schema.Nullable) switch { ("boolean", null, false) => typeof(bool), ("integer", "int32", false) => typeof(int), From ad3d267ff04513d6119ee0c105ce1f704fc6ff73 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 6 Dec 2022 19:01:56 +0300 Subject: [PATCH 78/83] Fix failing tests --- src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs | 2 +- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs index 16441a9e7..970b3a976 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs @@ -95,7 +95,7 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema throw new ArgumentNullException(nameof(schema)); } - var type = (schema.Type?.ToLowerInvariant(), schema.Format.ToLowerInvariant(), schema.Nullable) switch + var type = (schema.Type?.ToLowerInvariant(), schema.Format?.ToLowerInvariant(), schema.Nullable) switch { ("boolean", null, false) => typeof(bool), ("integer", "int32", false) => typeof(int), diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 787b536e0..3eca62791 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -284,6 +284,7 @@ namespace Microsoft.OpenApi.Extensions } public static class OpenApiTypeMapper { + public static System.Type MapOpenApiPrimitiveTypeToSimpleType(this Microsoft.OpenApi.Models.OpenApiSchema schema) { } public static Microsoft.OpenApi.Models.OpenApiSchema MapTypeToOpenApiPrimitiveType(this System.Type type) { } } public static class StringExtensions From 32d621e578e41bae12cf009e8aee1b4600adf05c Mon Sep 17 00:00:00 2001 From: Irvine Sunday <40403681+irvinesunday@users.noreply.github.com> Date: Thu, 8 Dec 2022 15:03:18 +0300 Subject: [PATCH 79/83] Serialize `OpenApiDate` values properly to short date (#1102) * Serialize OpenApiDate properly as Date * Change test date value Using value 01/01/0001 could be represented as 1/1/0001 in a machine using a different regional format, and thus cause the test to fail --- src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs | 2 +- ...ithoutReferenceWorks_produceTerseOutput=False.verified.txt | 3 ++- ...WithoutReferenceWorks_produceTerseOutput=True.verified.txt | 2 +- test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs b/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs index e0abda167..bd6db956a 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs @@ -118,7 +118,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) case PrimitiveType.Date: var dateValue = (OpenApiDate)(IOpenApiPrimitive)this; - writer.WriteValue(dateValue.Value); + writer.WriteValue(dateValue.Value.ToShortDateString()); break; case PrimitiveType.DateTime: diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt index 45f085f73..868b45156 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt @@ -21,6 +21,7 @@ } ] } - ] + ], + "aDate": "12/12/2022" } } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt index b503d318e..7ab9ad1d6 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}]}} \ No newline at end of file +{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}],"aDate":"12/12/2022"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs index 6108c3c26..d42d65ce7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Globalization; using System.IO; using System.Text; @@ -95,7 +96,8 @@ public class OpenApiExampleTests } } } - } + }, + ["aDate"] = new OpenApiDate(DateTime.Parse("12/12/2022 00:00:00")) } }; From d624cd58eb20135ce509f03f4bbcc8e660b56bb4 Mon Sep 17 00:00:00 2001 From: Roman Kolesnikov Date: Fri, 9 Dec 2022 17:06:07 +0100 Subject: [PATCH 80/83] check Extensions object for null using Microsoft.OpenApi.OData package it generates OpenApi document with OpenApiComponents.Extensions == null --- src/Microsoft.OpenApi/Services/OpenApiWalker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs index e454e37a8..d800082e5 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs @@ -310,7 +310,7 @@ internal void Walk(IOpenApiExtensible openApiExtensible) _visitor.Visit(openApiExtensible); - if (openApiExtensible != null) + if (openApiExtensible.Extensions != null) { foreach (var item in openApiExtensible.Extensions) { From 698f7e82ebd4fc868d6b186b5005e31b6748a75d Mon Sep 17 00:00:00 2001 From: Afsal Rahman Date: Tue, 13 Dec 2022 22:19:34 +0530 Subject: [PATCH 81/83] replace decimal.Parse with double.Parse to include support for parsing values exceeding range of decimal --- .../V2/OpenApiHeaderDeserializer.cs | 8 ++++---- .../V2/OpenApiParameterDeserializer.cs | 4 ++-- .../V2/OpenApiSchemaDeserializer.cs | 6 +++--- .../V3/OpenApiSchemaDeserializer.cs | 6 +++--- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 6 +++--- src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs | 4 ++-- src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs | 6 ++++-- .../Writers/SpecialCharacterStringExtensions.cs | 12 +++++++----- .../V2Tests/OpenApiDocumentTests.cs | 4 ++-- .../V3Tests/OpenApiDocumentTests.cs | 4 ++-- .../PublicApi/PublicApi.approved.txt | 11 ++++++----- .../Writers/OpenApiJsonWriterTests.cs | 2 +- .../Writers/OpenApiYamlWriterTests.cs | 2 +- 13 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiHeaderDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiHeaderDeserializer.cs index 5d6cc2ff3..436ae1ca3 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiHeaderDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiHeaderDeserializer.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; @@ -57,7 +57,7 @@ internal static partial class OpenApiV2Deserializer { "maximum", (o, n) => { - GetOrCreateSchema(o).Maximum = decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture); + GetOrCreateSchema(o).Maximum = double.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture); } }, { @@ -69,7 +69,7 @@ internal static partial class OpenApiV2Deserializer { "minimum", (o, n) => { - GetOrCreateSchema(o).Minimum = decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture); + GetOrCreateSchema(o).Minimum = double.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture); } }, { @@ -117,7 +117,7 @@ internal static partial class OpenApiV2Deserializer { "multipleOf", (o, n) => { - GetOrCreateSchema(o).MultipleOf = decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture); + GetOrCreateSchema(o).MultipleOf = double.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture); } }, { diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs index 5be08c71e..38ab18639 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs @@ -82,13 +82,13 @@ internal static partial class OpenApiV2Deserializer { "minimum", (o, n) => { - GetOrCreateSchema(o).Minimum = decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture); + GetOrCreateSchema(o).Minimum = double.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture); } }, { "maximum", (o, n) => { - GetOrCreateSchema(o).Maximum = decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture); + GetOrCreateSchema(o).Maximum = double.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture); } }, { diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiSchemaDeserializer.cs index 0878eda9a..cb2c563bf 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiSchemaDeserializer.cs @@ -26,13 +26,13 @@ internal static partial class OpenApiV2Deserializer { "multipleOf", (o, n) => { - o.MultipleOf = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); + o.MultipleOf = double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); } }, { "maximum", (o, n) => { - o.Maximum = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); + o.Maximum = double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); } }, { @@ -44,7 +44,7 @@ internal static partial class OpenApiV2Deserializer { "minimum", (o, n) => { - o.Minimum = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); + o.Minimum = double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); } }, { diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs index 8f465e38e..6d5f9a9ce 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs @@ -28,13 +28,13 @@ internal static partial class OpenApiV3Deserializer { "multipleOf", (o, n) => { - o.MultipleOf = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); + o.MultipleOf = double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); } }, { "maximum", (o, n) => { - o.Maximum = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); + o.Maximum = double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); } }, { @@ -46,7 +46,7 @@ internal static partial class OpenApiV3Deserializer { "minimum", (o, n) => { - o.Minimum = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); + o.Minimum = double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); } }, { diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 513b865df..b00419d85 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -41,7 +41,7 @@ public class OpenApiSchema : IOpenApiSerializable, IOpenApiReferenceable, IEffec /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public decimal? Maximum { get; set; } + public double? Maximum { get; set; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -51,7 +51,7 @@ public class OpenApiSchema : IOpenApiSerializable, IOpenApiReferenceable, IEffec /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public decimal? Minimum { get; set; } + public double? Minimum { get; set; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -77,7 +77,7 @@ public class OpenApiSchema : IOpenApiSerializable, IOpenApiReferenceable, IEffec /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// - public decimal? MultipleOf { get; set; } + public double? MultipleOf { get; set; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 diff --git a/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs b/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs index 8fcbf10ed..7d086806e 100644 --- a/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs +++ b/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs @@ -39,9 +39,9 @@ public interface IOpenApiWriter void WriteValue(string value); /// - /// Write the decimal value. + /// Write the double value. /// - void WriteValue(decimal value); + void WriteValue(double value); /// /// Write the int value. diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs index 4d7f11032..bfac14f67 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs @@ -148,9 +148,11 @@ public virtual void WriteValue(double value) } /// - /// Write decimal value. + /// Write + /// + /// value. /// - /// The decimal value. + /// The double value. public virtual void WriteValue(decimal value) { WriteValueSeparator(); diff --git a/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs b/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs index 6e1ea2beb..56eda2937 100644 --- a/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs @@ -187,10 +187,12 @@ internal static string GetYamlCompatibleString(this string input) return $"'{input}'"; } - // If string can be mistaken as a number, c-style hexadecimal notation, a boolean, or a timestamp, - // wrap it in quote to indicate that this is indeed a string, not a number, c-style hexadecimal notation, a boolean, or a timestamp - if (decimal.TryParse(input, NumberStyles.Float, CultureInfo.InvariantCulture, out var _) || - IsHexadecimalNotation(input) || + // If string can be mistaken as a number, c-style hexa + // + // notation, a boolean, or a timestamp, + // wrap it in quote to indicate that this is indeed a string, not a number, c-style hexadouble notation, a boolean, or a timestamp + if (double.TryParse(input, NumberStyles.Float, CultureInfo.InvariantCulture, out var _) || + IsHexadoubleNotation(input) || bool.TryParse(input, out var _) || DateTime.TryParse(input, CultureInfo.InvariantCulture, DateTimeStyles.None, out var _)) { @@ -227,7 +229,7 @@ internal static string GetJsonCompatibleString(this string value) return $"\"{value}\""; } - internal static bool IsHexadecimalNotation(string input) + internal static bool IsHexadoubleNotation(string input) { return input.StartsWith("0x") && int.TryParse(input.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var _); } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index 256ad2630..fa67203de 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -134,8 +134,8 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) ["sampleProperty"] = new OpenApiSchema() { Type = "double", - Minimum = (decimal)100.54, - Maximum = (decimal)60000000.35, + Minimum = (double)100.54, + Maximum = (double)60000000.35, ExclusiveMaximum = true, ExclusiveMinimum = false } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index ef5d58d5e..82556a67e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -164,8 +164,8 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) ["sampleProperty"] = new OpenApiSchema() { Type = "double", - Minimum = (decimal)100.54, - Maximum = (decimal)60000000.35, + Minimum = (double)100.54, + Maximum = (double)60000000.35, ExclusiveMaximum = true, ExclusiveMinimum = false } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 3eca62791..3d535fafa 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -862,12 +862,13 @@ namespace Microsoft.OpenApi.Models public int? MaxItems { get; set; } public int? MaxLength { get; set; } public int? MaxProperties { get; set; } - public decimal? Maximum { get; set; } + public + ? Maximum { get; set; } public int? MinItems { get; set; } public int? MinLength { get; set; } public int? MinProperties { get; set; } - public decimal? Minimum { get; set; } - public decimal? MultipleOf { get; set; } + public double? Minimum { get; set; } + public double? MultipleOf { get; set; } public Microsoft.OpenApi.Models.OpenApiSchema Not { get; set; } public bool Nullable { get; set; } public System.Collections.Generic.IList OneOf { get; set; } @@ -1417,7 +1418,7 @@ namespace Microsoft.OpenApi.Writers void WriteStartArray(); void WriteStartObject(); void WriteValue(bool value); - void WriteValue(decimal value); + void WriteValue(double value); void WriteValue(int value); void WriteValue(object value); void WriteValue(string value); @@ -1480,7 +1481,7 @@ namespace Microsoft.OpenApi.Writers public virtual void WriteValue(bool value) { } public virtual void WriteValue(System.DateTime value) { } public virtual void WriteValue(System.DateTimeOffset value) { } - public virtual void WriteValue(decimal value) { } + public virtual void WriteValue(double value) { } public virtual void WriteValue(double value) { } public virtual void WriteValue(int value) { } public virtual void WriteValue(long value) { } diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs index 44d1be55b..0317bfb12 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs @@ -188,7 +188,7 @@ private void WriteValueRecursive(OpenApiJsonWriter writer, object value) { if (value == null || value.GetType().IsPrimitive - || value is decimal + || value is double || value is string || value is DateTimeOffset || value is DateTime) diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs index bfaa3da51..fc29bbe94 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs @@ -256,7 +256,7 @@ private void WriteValueRecursive(OpenApiYamlWriter writer, object value) { if (value == null || value.GetType().IsPrimitive - || value is decimal + || value is double || value is string || value is DateTimeOffset || value is DateTime) From f2c3f9375da66feb32877eb63c01ca3f9715d45c Mon Sep 17 00:00:00 2001 From: Afsal Rahman Date: Wed, 14 Dec 2022 11:15:49 +0530 Subject: [PATCH 82/83] remove unnecessary changes --- src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs index 970b3a976..36f08bcb0 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs @@ -22,7 +22,7 @@ public static class OpenApiTypeMapper [typeof(ulong)] = () => new OpenApiSchema { Type = "integer", Format = "int64" }, [typeof(float)] = () => new OpenApiSchema { Type = "number", Format = "float" }, [typeof(double)] = () => new OpenApiSchema { Type = "number", Format = "double" }, - [typeof(decimal)] = () => new OpenApiSchema { Type = "number", Format = "double" }, + [typeof(decimal)] = () => new OpenApiSchema { Type = "number", Format = "decimal" }, [typeof(DateTime)] = () => new OpenApiSchema { Type = "string", Format = "date-time" }, [typeof(DateTimeOffset)] = () => new OpenApiSchema { Type = "string", Format = "date-time" }, [typeof(Guid)] = () => new OpenApiSchema { Type = "string", Format = "uuid" }, @@ -36,8 +36,8 @@ public static class OpenApiTypeMapper [typeof(long?)] = () => new OpenApiSchema { Type = "integer", Format = "int64", Nullable = true }, [typeof(ulong?)] = () => new OpenApiSchema { Type = "integer", Format = "int64", Nullable = true }, [typeof(float?)] = () => new OpenApiSchema { Type = "number", Format = "float", Nullable = true }, + [typeof(decimal?)] = () => new OpenApiSchema { Type = "number", Format = "decimal", Nullable = true }, [typeof(double?)] = () => new OpenApiSchema { Type = "number", Format = "double", Nullable = true }, - [typeof(decimal?)] = () => new OpenApiSchema { Type = "number", Format = "double", Nullable = true }, [typeof(DateTime?)] = () => new OpenApiSchema { Type = "string", Format = "date-time", Nullable = true }, [typeof(DateTimeOffset?)] = () => new OpenApiSchema { Type = "string", Format = "date-time", Nullable = true }, [typeof(Guid?)] = () => new OpenApiSchema { Type = "string", Format = "uuid", Nullable = true }, From 9ca8d2369ec28591465d18cbedbce1c87a08c439 Mon Sep 17 00:00:00 2001 From: Afsal Rahman Date: Thu, 15 Dec 2022 15:45:41 +0530 Subject: [PATCH 83/83] code cleanup --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 04887dce6..896c4ca8b 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -333,8 +333,7 @@ public static async Task ConvertCsdlToOpenApi(Stream csdl) ShowLinks = false, ExpandDerivedTypesNavigationProperties = false, EnableCount = true, - UseSuccessStatusCodeRange = true, - EnableTypeDisambiguationForDefaultValueOfOdataTypeProperty = true + UseSuccessStatusCodeRange = true }; OpenApiDocument document = edmModel.ConvertToOpenApi(settings);