From 6e0f84a6f783d96119a80fef710aece7cd4d08b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Sep 2023 21:55:15 +0000 Subject: [PATCH 01/69] Bump Verify.Xunit from 21.2.0 to 21.3.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 21.2.0 to 21.3.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits/21.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 214b2f017..56c833d45 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -28,7 +28,7 @@ - + all From 7fe922db323c32a16e1a97d861b6f4c7bfa6c0fd Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:29:02 +1000 Subject: [PATCH 02/69] fix some warnings --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 13 +++++++------ .../Services/OpenApiServiceTests.cs | 14 +++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 809e3ecf9..b3e66cfe2 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -81,7 +81,7 @@ public static async Task TransformOpenApiDocument(HidiOptions options, ILogger l if (!string.IsNullOrEmpty(options.FilterOptions?.FilterByCollection)) { using var collectionStream = await GetStream(options.FilterOptions.FilterByCollection, logger, cancellationToken).ConfigureAwait(false); - postmanCollection = JsonDocument.Parse(collectionStream); + postmanCollection = await JsonDocument.ParseAsync(collectionStream, cancellationToken: cancellationToken).ConfigureAwait(false); } // Load OpenAPI document @@ -132,7 +132,8 @@ public static async Task TransformOpenApiDocument(HidiOptions options, ILogger l } using (var fileStream = await GetStream(apiManifestRef[0], logger, cancellationToken).ConfigureAwait(false)) { - apiManifest = ApiManifestDocument.Load(JsonDocument.Parse(fileStream).RootElement); + var document = await JsonDocument.ParseAsync(fileStream, cancellationToken: cancellationToken).ConfigureAwait(false); + apiManifest = ApiManifestDocument.Load(document.RootElement); } apiDependency = !string.IsNullOrEmpty(apiDependencyName) && apiManifest.ApiDependencies.TryGetValue(apiDependencyName, out var dependency) ? dependency : apiManifest.ApiDependencies.First().Value; @@ -453,13 +454,13 @@ private static Dictionary> EnumerateJsonDocument(JsonElemen // 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(); - if (!paths.ContainsKey(path)) + if (paths.TryGetValue(path, out var value)) { - paths.Add(path, new List { method }); + value.Add(method); } else { - paths[path].Add(method); + paths.Add(path, new List {method}); } } else @@ -755,7 +756,7 @@ internal static async Task PluginManifest(HidiOptions options, ILogger logger, C using var file = new FileStream(manifestFile.FullName, FileMode.Create); using var jsonWriter = new Utf8JsonWriter(file, new JsonWriterOptions { Indented = true }); manifest.Write(jsonWriter); - jsonWriter.Flush(); + await jsonWriter.FlushAsync(cancellationToken).ConfigureAwait(false); } } } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index b1fcd24d3..9d73c8db6 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -144,7 +144,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram() await OpenApiService.ShowOpenApiDocument(options, _logger, new CancellationToken()); - var output = File.ReadAllText(options.Output.FullName); + var output = await File.ReadAllTextAsync(options.Output.FullName); Assert.Contains("graph LR", output, StringComparison.Ordinal); } @@ -172,7 +172,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiag // create a dummy ILogger instance for testing await OpenApiService.ShowOpenApiDocument(options, _logger, new CancellationToken()); - var output = File.ReadAllText(options.Output.FullName); + var output = await File.ReadAllTextAsync(options.Output.FullName); Assert.Contains("graph LR", output, StringComparison.Ordinal); } @@ -223,7 +223,7 @@ public async Task TransformCommandConvertsOpenApi() // create a dummy ILogger instance for testing await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken()); - var output = File.ReadAllText("sample.json"); + var output = await File.ReadAllTextAsync("sample.json"); Assert.NotEmpty(output); } @@ -242,7 +242,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputName() // create a dummy ILogger instance for testing await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken()); - var output = File.ReadAllText("output.yml"); + var output = await File.ReadAllTextAsync("output.yml"); Assert.NotEmpty(output); } @@ -260,7 +260,7 @@ public async Task TransformCommandConvertsCsdlWithDefaultOutputName() // create a dummy ILogger instance for testing await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken()); - var output = File.ReadAllText("output.yml"); + var output = await File.ReadAllTextAsync("output.yml"); Assert.NotEmpty(output); } @@ -280,7 +280,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF // create a dummy ILogger instance for testing await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken()); - var output = File.ReadAllText("output.yml"); + var output = await File.ReadAllTextAsync("output.yml"); Assert.NotEmpty(output); } @@ -317,7 +317,7 @@ public async Task TransformToPowerShellCompliantOpenApi() // create a dummy ILogger instance for testing await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken()); - var output = File.ReadAllText("output.yml"); + var output = await File.ReadAllTextAsync("output.yml"); Assert.NotEmpty(output); } From c1a6ebaf5a768cb97877b4d0a63218f2d264366f Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:44:25 +1000 Subject: [PATCH 03/69] move dir props up --- src/Directory.Build.props => Directory.Build.props | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename src/Directory.Build.props => Directory.Build.props (61%) diff --git a/src/Directory.Build.props b/Directory.Build.props similarity index 61% rename from src/Directory.Build.props rename to Directory.Build.props index bfc937cba..c1064f1a0 100644 --- a/src/Directory.Build.props +++ b/Directory.Build.props @@ -3,6 +3,8 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - + \ No newline at end of file From 63aa7330355e42acc73b3daf30bddbdf57687ce5 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:45:54 +1000 Subject: [PATCH 04/69] remove csproj settings that are convention based on project name --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ---- .../Microsoft.OpenApi.Readers.csproj | 4 ---- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 4 ---- .../Microsoft.OpenApi.Readers.Tests.csproj | 5 ----- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 5 ----- 5 files changed, 22 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index ced9d9c3c..ae373f6c8 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -13,8 +13,6 @@ true Microsoft Microsoft - Microsoft.OpenApi.Hidi - Microsoft.OpenApi.Hidi hidi ./../../artifacts 1.3.0 @@ -23,8 +21,6 @@ OpenAPI .NET https://github.com/Microsoft/OpenAPI.NET https://github.com/microsoft/OpenAPI.NET/releases - Microsoft.OpenApi.Hidi - Microsoft.OpenApi.Hidi true true diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 49dde408e..f7faa1d9b 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -9,16 +9,12 @@ true Microsoft Microsoft - Microsoft.OpenApi.Readers - Microsoft.OpenApi.Readers 1.6.9 OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. OpenAPI .NET https://github.com/Microsoft/OpenAPI.NET https://github.com/microsoft/OpenAPI.NET/releases - Microsoft.OpenApi.Readers - Microsoft.OpenApi.Readers true true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 7372332c1..e876a57d2 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -9,16 +9,12 @@ true Microsoft Microsoft - Microsoft.OpenApi - Microsoft.OpenApi 1.6.9 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET https://github.com/Microsoft/OpenAPI.NET https://github.com/microsoft/OpenAPI.NET/releases - Microsoft.OpenApi - Microsoft.OpenApi true true 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 ee9240603..bbea8fe69 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -4,11 +4,6 @@ false Microsoft - Microsoft.OpenApi.Readers.Tests - Microsoft.OpenApi.Readers.Tests - Tests for Microsoft.OpenApi.Readers - Microsoft.OpenApi.Readers.Tests - Microsoft.OpenApi.Readers.Tests true ..\..\src\Microsoft.OpenApi.snk diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 56c833d45..25f915704 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -4,11 +4,6 @@ false Microsoft - Microsoft.OpenApi.Tests - Microsoft.OpenApi.Tests - Tests for Microsoft.OpenApi - Microsoft.OpenApi.Tests - Microsoft.OpenApi.Tests true Library ..\..\src\Microsoft.OpenApi.snk From 6356fc2ae91ba44173929e37d9e0f30009ab924f Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:47:29 +1000 Subject: [PATCH 05/69] move Authors and company to props --- Directory.Build.props | 2 ++ 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 -- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 -- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 -- 6 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index c1064f1a0..861236ce2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,8 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + Microsoft + Microsoft https://github.com/Microsoft/OpenAPI.NET MIT true - Microsoft - Microsoft hidi ./../../artifacts 1.3.0 diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index f7faa1d9b..026d2d47a 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -7,8 +7,6 @@ https://github.com/Microsoft/OpenAPI.NET MIT true - Microsoft - Microsoft 1.6.9 OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index e876a57d2..c5266741f 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -7,8 +7,6 @@ https://github.com/Microsoft/OpenAPI.NET MIT true - Microsoft - Microsoft 1.6.9 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. 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 bbea8fe69..e9eadcd38 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -2,8 +2,6 @@ net7.0 false - - Microsoft true ..\..\src\Microsoft.OpenApi.snk diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 25f915704..25d764817 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -2,8 +2,6 @@ net7.0 false - - Microsoft true Library ..\..\src\Microsoft.OpenApi.snk From 6149e55defabdf62713acb9c174cc554ac2e36c7 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:48:20 +1000 Subject: [PATCH 06/69] move license to props --- Directory.Build.props | 1 + src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 1 - src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 1 - src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 861236ce2..b6c70f6cc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,6 +3,7 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb Microsoft Microsoft + MIT enable http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET - MIT true hidi ./../../artifacts diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 026d2d47a..7b80c66fa 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -5,7 +5,6 @@ true http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET - MIT true 1.6.9 OpenAPI.NET Readers for JSON and YAML documents diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index c5266741f..80e76f089 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -5,7 +5,6 @@ true http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET - MIT true 1.6.9 .NET models with JSON and YAML writers for OpenAPI specification From 7e60f937e36a75b1a9ce5ed2abaec15febbb77be Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:48:57 +1000 Subject: [PATCH 07/69] move PackageRequireLicenseAcceptance to props --- Directory.Build.props | 1 + src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 1 - src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 1 - src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index b6c70f6cc..00158e414 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,6 +4,7 @@ Microsoft Microsoft MIT + true enable http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET - true hidi ./../../artifacts 1.3.0 diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 7b80c66fa..a090f4aef 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -5,7 +5,6 @@ true http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET - true 1.6.9 OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 80e76f089..9f76741a1 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -5,7 +5,6 @@ true http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET - true 1.6.9 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. From 6e6a2b8e438500e3549a841945e809bd0d02f25f Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:49:52 +1000 Subject: [PATCH 08/69] move RepositoryUrl to props --- Directory.Build.props | 1 + src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 1 - src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 1 - src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 00158e414..cb89aecf0 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,6 +5,7 @@ Microsoft MIT true + https://github.com/Microsoft/OpenAPI.NET OpenAPI.NET CLI tool for slicing OpenAPI documents © Microsoft Corporation. All rights reserved. OpenAPI .NET - https://github.com/Microsoft/OpenAPI.NET https://github.com/microsoft/OpenAPI.NET/releases true diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index a090f4aef..7ea9c4655 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -9,7 +9,6 @@ OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. OpenAPI .NET - https://github.com/Microsoft/OpenAPI.NET https://github.com/microsoft/OpenAPI.NET/releases true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 9f76741a1..71fcdf361 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -9,7 +9,6 @@ .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET - https://github.com/Microsoft/OpenAPI.NET https://github.com/microsoft/OpenAPI.NET/releases true From 4f1513e24e7a73365d90cd814e0cb867aadd40d9 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:50:26 +1000 Subject: [PATCH 09/69] move PackageReleaseNotes to props --- Directory.Build.props | 1 + src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 1 - src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 1 - src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index cb89aecf0..671fcd507 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,6 +6,7 @@ MIT true https://github.com/Microsoft/OpenAPI.NET + https://github.com/microsoft/OpenAPI.NET/releases OpenAPI.NET CLI tool for slicing OpenAPI documents © Microsoft Corporation. All rights reserved. OpenAPI .NET - https://github.com/microsoft/OpenAPI.NET/releases true true diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 7ea9c4655..120ad9215 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -9,7 +9,6 @@ OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. OpenAPI .NET - https://github.com/microsoft/OpenAPI.NET/releases true true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 71fcdf361..720995f9b 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -9,7 +9,6 @@ .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET - https://github.com/microsoft/OpenAPI.NET/releases true true From 838ac24ed6aaf6dc1a5df1f808693284b9e368c3 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:51:20 +1000 Subject: [PATCH 10/69] move TreatWarningsAsErrors to props --- Directory.Build.props | 1 + src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 1 - src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 1 - src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 - .../Microsoft.OpenApi.Hidi.Tests.csproj | 1 - 5 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 671fcd507..37fb23a82 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,6 +7,7 @@ true https://github.com/Microsoft/OpenAPI.NET https://github.com/microsoft/OpenAPI.NET/releases + true true $(NoWarn);NU5048;NU5104;CA1848; - true readme.md All diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 120ad9215..41504d442 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -13,7 +13,6 @@ true NU5048 - true README.md diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 720995f9b..b54feb2cf 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -13,7 +13,6 @@ true NU5048 - true README.md 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 3f719eda8..89789bbb9 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -6,7 +6,6 @@ enable false - true All CA2007 From b813e518985cddf7faadde60aea81aa1a68194fe Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:52:02 +1000 Subject: [PATCH 11/69] move ContinuousIntegrationBuild to props --- Directory.Build.props | 4 ++++ .../Microsoft.OpenApi.Readers.csproj | 5 ----- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 5 ----- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 37fb23a82..95d10054c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,6 +9,10 @@ https://github.com/microsoft/OpenAPI.NET/releases true + + + true + ..\Microsoft.OpenApi.snk - - - true - - diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index b54feb2cf..6419da7a6 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -21,11 +21,6 @@ ..\Microsoft.OpenApi.snk - - - true - - True From 37afc804893216dda1f9831a34265432e70e5cc7 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:52:51 +1000 Subject: [PATCH 12/69] move PackageIconUrl and PackageProjectUrl to props --- Directory.Build.props | 2 ++ 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 -- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 95d10054c..d2685c137 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -8,6 +8,8 @@ https://github.com/Microsoft/OpenAPI.NET https://github.com/microsoft/OpenAPI.NET/releases true + http://go.microsoft.com/fwlink/?LinkID=288890 + https://github.com/Microsoft/OpenAPI.NET diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 6435a5256..7806fbd3d 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -7,8 +7,6 @@ true true enable - http://go.microsoft.com/fwlink/?LinkID=288890 - https://github.com/Microsoft/OpenAPI.NET hidi ./../../artifacts 1.3.0 diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 1c95ae7aa..df29cfc1f 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -3,8 +3,6 @@ netstandard2.0 latest true - http://go.microsoft.com/fwlink/?LinkID=288890 - https://github.com/Microsoft/OpenAPI.NET 1.6.9 OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 6419da7a6..404afc36b 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -3,8 +3,6 @@ netstandard2.0 Latest true - http://go.microsoft.com/fwlink/?LinkID=288890 - https://github.com/Microsoft/OpenAPI.NET 1.6.9 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. From 0ac9a52fc1be2062c73c1ad6387e79162db1602c Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:53:36 +1000 Subject: [PATCH 13/69] move Copyright to props --- Directory.Build.props | 1 + src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 1 - src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 1 - src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index d2685c137..70ab6850a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,6 +10,7 @@ true http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET + © Microsoft Corporation. All rights reserved. diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 7806fbd3d..14d5125ae 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -11,7 +11,6 @@ ./../../artifacts 1.3.0 OpenAPI.NET CLI tool for slicing OpenAPI documents - © Microsoft Corporation. All rights reserved. OpenAPI .NET true diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index df29cfc1f..edb08e140 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -5,7 +5,6 @@ true 1.6.9 OpenAPI.NET Readers for JSON and YAML documents - © Microsoft Corporation. All rights reserved. OpenAPI .NET true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 404afc36b..2b891ffdc 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -5,7 +5,6 @@ true 1.6.9 .NET models with JSON and YAML writers for OpenAPI specification - © Microsoft Corporation. All rights reserved. OpenAPI .NET true From cde8923c853393ed48a6bca24dcea69635fe1b2f Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:54:10 +1000 Subject: [PATCH 14/69] move PackageTags to props --- Directory.Build.props | 1 + src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 1 - src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 1 - src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 70ab6850a..f65c81703 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,6 +11,7 @@ http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET © Microsoft Corporation. All rights reserved. + OpenAPI .NET diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 14d5125ae..fd1520481 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -11,7 +11,6 @@ ./../../artifacts 1.3.0 OpenAPI.NET CLI tool for slicing OpenAPI documents - OpenAPI .NET true true diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index edb08e140..e08a54fca 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -5,7 +5,6 @@ true 1.6.9 OpenAPI.NET Readers for JSON and YAML documents - OpenAPI .NET true true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 2b891ffdc..e0afd008d 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -5,7 +5,6 @@ true 1.6.9 .NET models with JSON and YAML writers for OpenAPI specification - OpenAPI .NET true true From 4df30254f6c41aa34f9072ece2152d4a62ffbe5c Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:55:19 +1000 Subject: [PATCH 15/69] TargetFrameworks to TargetFramework --- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.SmokeTests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index e08a54fca..33788cebd 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0 latest true 1.6.9 diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index e0afd008d..dc1e97a64 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0 Latest true 1.6.9 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 e9eadcd38..cf6a7a470 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -1,6 +1,6 @@ - net7.0 + net7.0 false true ..\..\src\Microsoft.OpenApi.snk diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 2d72104ad..db323e1c6 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -1,7 +1,7 @@ - net7.0 + net7.0 diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 25d764817..1e29addc4 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -1,6 +1,6 @@ - net7.0 + net7.0 false true Library From 2b304a73d4c4194336e8b1f6be7555898a8065ad Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:57:08 +1000 Subject: [PATCH 16/69] simplify PrivateAssets all --- .../Microsoft.OpenApi.Workbench.csproj | 4 +--- .../Microsoft.OpenApi.Hidi.Tests.csproj | 15 +++------------ .../Microsoft.OpenApi.Readers.Tests.csproj | 15 +++------------ .../Microsoft.OpenApi.SmokeTests.csproj | 15 +++------------ .../Microsoft.OpenApi.Tests.csproj | 15 +++------------ 5 files changed, 13 insertions(+), 51 deletions(-) diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index e2d75c96a..36a1d979b 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -8,9 +8,7 @@ true - - all - + 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 89789bbb9..1f2ec91e3 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -11,21 +11,12 @@ - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - 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 cf6a7a470..1b3cec73a 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -260,14 +260,8 @@ - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + + @@ -277,10 +271,7 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index db323e1c6..637e25583 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -8,21 +8,12 @@ - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + + - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 1e29addc4..b073d6b8d 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -8,14 +8,8 @@ - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + + @@ -23,10 +17,7 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + From 32b2525ab7c472131d05b891b292c0023d870315 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 30 Sep 2023 22:57:41 +1000 Subject: [PATCH 17/69] remove redundant PackageReference closing tags --- .../Microsoft.OpenApi.Readers.Tests.csproj | 12 ++++-------- 1 file changed, 4 insertions(+), 8 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 1b3cec73a..5ba3103fe 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -263,14 +263,10 @@ - - - - - - - - + + + + From cf89b4f756bcfb7775d4b8987a553fbf11ac29ab Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 19:09:30 +1100 Subject: [PATCH 18/69] use some pattern matiching --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 16 +++++++++------- .../ParseNodes/OpenApiAnyConverter.cs | 2 +- .../ParseNodes/ValueNode.cs | 2 +- src/Microsoft.OpenApi.Readers/ParsingContext.cs | 2 +- .../V2/OpenApiV2VersionService.cs | 2 +- .../V3/OpenApiV3VersionService.cs | 2 +- .../OpenApiEnumValuesDescriptionExtension.cs | 2 +- .../Writers/OpenApiWriterAnyExtensionsTests.cs | 2 +- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index b3e66cfe2..8d6471e88 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -510,13 +510,15 @@ private static async Task GetStream(string input, ILogger logger, Cancel var fileInput = new FileInfo(input); stream = fileInput.OpenRead(); } - catch (Exception ex) when (ex is FileNotFoundException || - ex is PathTooLongException || - ex is DirectoryNotFoundException || - ex is IOException || - ex is UnauthorizedAccessException || - ex is SecurityException || - ex is NotSupportedException) + catch (Exception ex) when ( + ex is + FileNotFoundException or + PathTooLongException or + DirectoryNotFoundException or + IOException or + UnauthorizedAccessException or + SecurityException or + NotSupportedException) { throw new InvalidOperationException($"Could not open the file at {input}", ex); } diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs index ae9254fe8..01aef7652 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs @@ -116,7 +116,7 @@ public static IOpenApiAny GetSpecificOpenApiAny(IOpenApiAny openApiAny, OpenApiS return openApiAny; } - if (value == null || value == "null") + if (value is null or "null") { return new OpenApiNull(); } diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs index 68f4bd7ea..bbce7a7d3 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs @@ -34,7 +34,7 @@ public override string GetScalarValue() public override IOpenApiAny CreateAny() { var value = GetScalarValue(); - return new OpenApiString(value, this._node.Style == ScalarStyle.SingleQuoted || this._node.Style == ScalarStyle.DoubleQuoted || this._node.Style == ScalarStyle.Literal || this._node.Style == ScalarStyle.Folded); + return new OpenApiString(value, this._node.Style is ScalarStyle.SingleQuoted or ScalarStyle.DoubleQuoted or ScalarStyle.Literal or ScalarStyle.Folded); } } } diff --git a/src/Microsoft.OpenApi.Readers/ParsingContext.cs b/src/Microsoft.OpenApi.Readers/ParsingContext.cs index 0cd98c67e..afc76bcf5 100644 --- a/src/Microsoft.OpenApi.Readers/ParsingContext.cs +++ b/src/Microsoft.OpenApi.Readers/ParsingContext.cs @@ -60,7 +60,7 @@ internal OpenApiDocument Parse(YamlDocument yamlDocument) switch (inputVersion) { - case string version when version == "2.0": + case string and "2.0": VersionService = new OpenApiV2VersionService(Diagnostic); doc = VersionService.LoadDocument(RootNode); this.Diagnostic.SpecificationVersion = OpenApiSpecVersion.OpenApi2_0; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs index 33c9d7c6f..54b0a3776 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs @@ -152,7 +152,7 @@ public OpenApiReference ConvertToOpenApiReference(string reference, ReferenceTyp }; } - if (type == ReferenceType.Tag || type == ReferenceType.SecurityScheme) + if (type is ReferenceType.Tag or ReferenceType.SecurityScheme) { return new OpenApiReference { diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index 889ce4cb8..60ce71c8a 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs @@ -78,7 +78,7 @@ public OpenApiReference ConvertToOpenApiReference( var segments = reference.Split('#'); if (segments.Length == 1) { - if (type == ReferenceType.Tag || type == ReferenceType.SecurityScheme) + if (type is ReferenceType.Tag or ReferenceType.SecurityScheme) { return new OpenApiReference { diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs index b3db2b437..c98a87af1 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs @@ -38,7 +38,7 @@ public class OpenApiEnumValuesDescriptionExtension : IOpenApiExtension public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) { if (writer is null) throw new ArgumentNullException(nameof(writer)); - if ((specVersion == OpenApiSpecVersion.OpenApi2_0 || specVersion == OpenApiSpecVersion.OpenApi3_0) && + if (specVersion is OpenApiSpecVersion.OpenApi2_0 or OpenApiSpecVersion.OpenApi3_0 && !string.IsNullOrEmpty(EnumName) && ValuesDescriptions.Any()) { // when we upgrade to 3.1, we don't need to write this extension as JSON schema will support writing enum values diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs index c9ef96efd..d1839015d 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs @@ -274,7 +274,7 @@ private static string WriteAsJson(IOpenApiAny any, bool produceTerseOutput = fal // Act var value = new StreamReader(stream).ReadToEnd(); - if (any.AnyType == AnyType.Primitive || any.AnyType == AnyType.Null) + if (any.AnyType is AnyType.Primitive or AnyType.Null) { return value; } From fc431205206514a95415fef4410c99f4cfa86561 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 19:14:05 +1100 Subject: [PATCH 19/69] elide some asyncs --- src/Microsoft.OpenApi.Hidi/Program.cs | 4 ++-- .../OpenApiYamlDocumentReader.cs | 4 ++-- .../Services/OpenApiServiceTests.cs | 24 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index b8508ab5f..9fe8a3014 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -12,12 +12,12 @@ namespace Microsoft.OpenApi.Hidi { static class Program { - static async Task Main(string[] args) + static Task Main(string[] args) { var rootCommand = CreateRootCommand(); // Parse the incoming args and invoke the handler - return await rootCommand.InvokeAsync(args).ConfigureAwait(false); + return rootCommand.InvokeAsync(args); } internal static RootCommand CreateRootCommand() diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs index 4a120cbbf..de7f810ad 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs @@ -140,7 +140,7 @@ public async Task ReadAsync(YamlDocument input, CancellationToken ca }; } - private async Task LoadExternalRefs(OpenApiDocument document, CancellationToken cancellationToken) + private Task LoadExternalRefs(OpenApiDocument document, CancellationToken cancellationToken) { // Create workspace for all documents to live in. var openApiWorkSpace = new OpenApiWorkspace(); @@ -148,7 +148,7 @@ private async Task LoadExternalRefs(OpenApiDocument document, // Load this root document into the workspace var streamLoader = new DefaultStreamLoader(_settings.BaseUrl); var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings); - return await workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document, cancellationToken); + return workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document, cancellationToken); } private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument document) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 9d73c8db6..24169045f 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -177,25 +177,25 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiag } [Fact] - public async Task ThrowIfOpenApiUrlIsNotProvidedWhenValidating() + public Task ThrowIfOpenApiUrlIsNotProvidedWhenValidating() { - await Assert.ThrowsAsync(async () => - await OpenApiService.ValidateOpenApiDocument("", _logger, new CancellationToken())); + return Assert.ThrowsAsync(() => + OpenApiService.ValidateOpenApiDocument("", _logger, new CancellationToken())); } [Fact] - public async Task ThrowIfURLIsNotResolvableWhenValidating() + public Task ThrowIfURLIsNotResolvableWhenValidating() { - await Assert.ThrowsAsync(async () => - await OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", _logger, new CancellationToken())); + return Assert.ThrowsAsync(() => + OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", _logger, new CancellationToken())); } [Fact] - public async Task ThrowIfFileDoesNotExistWhenValidating() + public Task ThrowIfFileDoesNotExistWhenValidating() { - await Assert.ThrowsAsync(async () => - await OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", _logger, new CancellationToken())); + return Assert.ThrowsAsync(() => + OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", _logger, new CancellationToken())); } [Fact] @@ -285,7 +285,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF } [Fact] - public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty() + public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty() { HidiOptions options = new HidiOptions { @@ -294,8 +294,8 @@ public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty() InlineLocal = false, InlineExternal = false, }; - await Assert.ThrowsAsync(async () => - await OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken())); + return Assert.ThrowsAsync(() => + OpenApiService.TransformOpenApiDocument(options, _logger, new CancellationToken())); } From 86c72b561a4b8b06dcb198b9174d9f0c60751e16 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 19:17:02 +1100 Subject: [PATCH 20/69] using declarations --- .../OpenApiStreamReader.cs | 12 +- .../OpenApiStringReader.cs | 12 +- .../OpenApiSerializableExtensions.cs | 14 +- .../OpenApiDiagnosticTests.cs | 20 +- .../OpenApiStreamReaderTests.cs | 20 +- .../UnsupportedSpecVersionTests.cs | 16 +- .../Resources.cs | 8 +- .../V2Tests/ComparisonTests.cs | 14 +- .../V2Tests/OpenApiDocumentTests.cs | 256 ++++--- .../V2Tests/OpenApiSecuritySchemeTests.cs | 264 +++---- .../V3Tests/OpenApiCallbackTests.cs | 320 ++++---- .../V3Tests/OpenApiDiscriminatorTests.cs | 40 +- .../V3Tests/OpenApiDocumentTests.cs | 300 ++++---- .../V3Tests/OpenApiEncodingTests.cs | 70 +- .../V3Tests/OpenApiExampleTests.cs | 76 +- .../V3Tests/OpenApiInfoTests.cs | 202 +++-- .../V3Tests/OpenApiOperationTests.cs | 10 +- .../V3Tests/OpenApiResponseTests.cs | 10 +- .../V3Tests/OpenApiSchemaTests.cs | 710 +++++++++--------- .../V3Tests/OpenApiSecuritySchemeTests.cs | 220 +++--- .../V3Tests/OpenApiXmlTests.cs | 38 +- 21 files changed, 1259 insertions(+), 1373 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs index 8922be4ce..7debb3723 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs @@ -73,10 +73,8 @@ public async Task ReadAsync(Stream input, CancellationToken cancella bufferedStream.Position = 0; } - using (var reader = new StreamReader(bufferedStream)) - { - return await new OpenApiTextReaderReader(_settings).ReadAsync(reader, cancellationToken); - } + using var reader = new StreamReader(bufferedStream); + return await new OpenApiTextReaderReader(_settings).ReadAsync(reader, cancellationToken); } /// @@ -88,10 +86,8 @@ public async Task ReadAsync(Stream input, CancellationToken cancella /// Instance of newly created OpenApiDocument public T ReadFragment(Stream input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic) where T : IOpenApiReferenceable { - using (var reader = new StreamReader(input)) - { - return new OpenApiTextReaderReader(_settings).ReadFragment(reader, version, out diagnostic); - } + using var reader = new StreamReader(input); + return new OpenApiTextReaderReader(_settings).ReadFragment(reader, version, out diagnostic); } } } diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStringReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStringReader.cs index 0cb9605dd..92e5307c4 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStringReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStringReader.cs @@ -29,10 +29,8 @@ public OpenApiStringReader(OpenApiReaderSettings settings = null) /// public OpenApiDocument Read(string input, out OpenApiDiagnostic diagnostic) { - using (var reader = new StringReader(input)) - { - return new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic); - } + using var reader = new StringReader(input); + return new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic); } /// @@ -40,10 +38,8 @@ public OpenApiDocument Read(string input, out OpenApiDiagnostic diagnostic) /// public T ReadFragment(string input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic) where T : IOpenApiElement { - using (var reader = new StringReader(input)) - { - return new OpenApiTextReaderReader(_settings).ReadFragment(reader, version, out diagnostic); - } + using var reader = new StringReader(input); + return new OpenApiTextReaderReader(_settings).ReadFragment(reader, version, out diagnostic); } } } diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs index f60c5483b..92ede5634 100755 --- a/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs @@ -179,16 +179,12 @@ public static string Serialize( throw Error.ArgumentNull(nameof(element)); } - using (var stream = new MemoryStream()) - { - element.Serialize(stream, specVersion, format); - stream.Position = 0; + using var stream = new MemoryStream(); + element.Serialize(stream, specVersion, format); + stream.Position = 0; - using (var streamReader = new StreamReader(stream)) - { - return streamReader.ReadToEnd(); - } - } + using var streamReader = new StreamReader(stream); + return streamReader.ReadToEnd(); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs index 23c23b4d6..e9109c061 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs @@ -20,25 +20,21 @@ public class OpenApiDiagnosticTests [Fact] public void DetectedSpecificationVersionShouldBeV2_0() { - using (var stream = Resources.GetStream("V2Tests/Samples/basic.v2.yaml")) - { - new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream("V2Tests/Samples/basic.v2.yaml"); + new OpenApiStreamReader().Read(stream, out var diagnostic); - diagnostic.Should().NotBeNull(); - diagnostic.SpecificationVersion.Should().Be(OpenApiSpecVersion.OpenApi2_0); - } + diagnostic.Should().NotBeNull(); + diagnostic.SpecificationVersion.Should().Be(OpenApiSpecVersion.OpenApi2_0); } [Fact] public void DetectedSpecificationVersionShouldBeV3_0() { - using (var stream = Resources.GetStream("V3Tests/Samples/OpenApiDocument/minimalDocument.yaml")) - { - new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream("V3Tests/Samples/OpenApiDocument/minimalDocument.yaml"); + new OpenApiStreamReader().Read(stream, out var diagnostic); - diagnostic.Should().NotBeNull(); - diagnostic.SpecificationVersion.Should().Be(OpenApiSpecVersion.OpenApi3_0); - } + diagnostic.Should().NotBeNull(); + diagnostic.SpecificationVersion.Should().Be(OpenApiSpecVersion.OpenApi3_0); } [Fact] diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs index 7567e0b7d..0f6bbce15 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs @@ -13,23 +13,19 @@ public class OpenApiStreamReaderTests [Fact] public void StreamShouldCloseIfLeaveStreamOpenSettingEqualsFalse() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml"))) - { - var reader = new OpenApiStreamReader(new OpenApiReaderSettings { LeaveStreamOpen = false }); - reader.Read(stream, out _); - Assert.False(stream.CanRead); - } + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml")); + var reader = new OpenApiStreamReader(new OpenApiReaderSettings { LeaveStreamOpen = false }); + reader.Read(stream, out _); + Assert.False(stream.CanRead); } [Fact] public void StreamShouldNotCloseIfLeaveStreamOpenSettingEqualsTrue() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml"))) - { - var reader = new OpenApiStreamReader(new OpenApiReaderSettings { LeaveStreamOpen = true}); - reader.Read(stream, out _); - Assert.True(stream.CanRead); - } + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml")); + var reader = new OpenApiStreamReader(new OpenApiReaderSettings { LeaveStreamOpen = true}); + reader.Read(stream, out _); + Assert.True(stream.CanRead); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs index cd60aa630..753f60e6a 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs @@ -13,16 +13,14 @@ public class UnsupportedSpecVersionTests [Fact] public void ThrowOpenApiUnsupportedSpecVersionException() { - using (var stream = Resources.GetStream("OpenApiReaderTests/Samples/unsupported.v1.yaml")) + using var stream = Resources.GetStream("OpenApiReaderTests/Samples/unsupported.v1.yaml"); + try { - try - { - new OpenApiStreamReader().Read(stream, out var diagnostic); - } - catch (OpenApiUnsupportedSpecVersionException exception) - { - exception.SpecificationVersion.Should().Be("1.0.0"); - } + new OpenApiStreamReader().Read(stream, out var diagnostic); + } + catch (OpenApiUnsupportedSpecVersionException exception) + { + exception.SpecificationVersion.Should().Be("1.0.0"); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/Resources.cs b/test/Microsoft.OpenApi.Readers.Tests/Resources.cs index 895e1ed3f..a817dc203 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Resources.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/Resources.cs @@ -14,11 +14,9 @@ internal static class Resources /// The file contents. public static string GetString(string fileName) { - using (Stream stream = GetStream(fileName)) - using (TextReader reader = new StreamReader(stream)) - { - return reader.ReadToEnd(); - } + using Stream stream = GetStream(fileName); + using TextReader reader = new StreamReader(stream); + return reader.ReadToEnd(); } /// diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs index 1ae3678d6..7d4f607f0 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs @@ -18,16 +18,14 @@ public class ComparisonTests //[InlineData("definitions")] //Currently broken due to V3 references not behaving the same as V2 public void EquivalentV2AndV3DocumentsShouldProductEquivalentObjects(string fileName) { - using (var streamV2 = Resources.GetStream(Path.Combine(SampleFolderPath, $"{fileName}.v2.yaml"))) - using (var streamV3 = Resources.GetStream(Path.Combine(SampleFolderPath, $"{fileName}.v3.yaml"))) - { - var openApiDocV2 = new OpenApiStreamReader().Read(streamV2, out var diagnosticV2); - var openApiDocV3 = new OpenApiStreamReader().Read(streamV3, out var diagnosticV3); + using var streamV2 = Resources.GetStream(Path.Combine(SampleFolderPath, $"{fileName}.v2.yaml")); + using var streamV3 = Resources.GetStream(Path.Combine(SampleFolderPath, $"{fileName}.v3.yaml")); + var openApiDocV2 = new OpenApiStreamReader().Read(streamV2, out var diagnosticV2); + var openApiDocV3 = new OpenApiStreamReader().Read(streamV3, out var diagnosticV3); - openApiDocV3.Should().BeEquivalentTo(openApiDocV2); + openApiDocV3.Should().BeEquivalentTo(openApiDocV2); - diagnosticV2.Errors.Should().BeEquivalentTo(diagnosticV3.Errors); - } + diagnosticV2.Errors.Should().BeEquivalentTo(diagnosticV3.Errors); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index ac5f99a86..9a6ec6a63 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -158,176 +158,174 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) [Fact] public void ShouldParseProducesInAnyOrder() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "twoResponses.json"))) - { - var reader = new OpenApiStreamReader(); - var doc = reader.Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "twoResponses.json")); + var reader = new OpenApiStreamReader(); + var doc = reader.Read(stream, out var diagnostic); - var okSchema = new OpenApiSchema() + var okSchema = new OpenApiSchema() + { + Reference = new OpenApiReference { - Reference = new OpenApiReference - { - Type = ReferenceType.Schema, - Id = "Item", - HostDocument = doc - }, - Properties = new Dictionary() - { - { "id", new OpenApiSchema() - { - Type = "string", - Description = "Item identifier." - } + Type = ReferenceType.Schema, + Id = "Item", + HostDocument = doc + }, + Properties = new Dictionary() + { + { "id", new OpenApiSchema() + { + Type = "string", + Description = "Item identifier." } } - }; + } + }; - var errorSchema = new OpenApiSchema() + var errorSchema = new OpenApiSchema() + { + Reference = new OpenApiReference { - Reference = new OpenApiReference - { - Type = ReferenceType.Schema, - Id = "Error", - HostDocument = doc + Type = ReferenceType.Schema, + Id = "Error", + HostDocument = doc + }, + Properties = new Dictionary() + { + { "code", new OpenApiSchema() + { + Type = "integer", + Format = "int32" + } }, - Properties = new Dictionary() - { - { "code", new OpenApiSchema() - { - Type = "integer", - Format = "int32" - } - }, - { "message", new OpenApiSchema() - { - Type = "string" - } - }, - { "fields", new OpenApiSchema() - { - Type = "string" - } + { "message", new OpenApiSchema() + { + Type = "string" + } + }, + { "fields", new OpenApiSchema() + { + Type = "string" } } - }; + } + }; - var okMediaType = new OpenApiMediaType + var okMediaType = new OpenApiMediaType + { + Schema = new OpenApiSchema { - Schema = new OpenApiSchema - { - Type = "array", - Items = okSchema - } - }; + Type = "array", + Items = okSchema + } + }; - var errorMediaType = new OpenApiMediaType - { - Schema = errorSchema - }; + var errorMediaType = new OpenApiMediaType + { + Schema = errorSchema + }; - doc.Should().BeEquivalentTo(new OpenApiDocument + doc.Should().BeEquivalentTo(new OpenApiDocument + { + Info = new OpenApiInfo { - Info = new OpenApiInfo - { - Title = "Two responses", - Version = "1.0.0" - }, - Servers = + Title = "Two responses", + Version = "1.0.0" + }, + Servers = + { + new OpenApiServer { - new OpenApiServer - { - Url = "https://" - } - }, - Paths = new OpenApiPaths + Url = "https://" + } + }, + Paths = new OpenApiPaths + { + ["/items"] = new OpenApiPathItem { - ["/items"] = new OpenApiPathItem + Operations = { - Operations = + [OperationType.Get] = new OpenApiOperation { - [OperationType.Get] = new OpenApiOperation + Responses = { - Responses = + ["200"] = new OpenApiResponse { - ["200"] = new OpenApiResponse + Description = "An OK response", + Content = { - Description = "An OK response", - Content = - { - ["application/json"] = okMediaType, - ["application/xml"] = okMediaType, - } - }, - ["default"] = new OpenApiResponse + ["application/json"] = okMediaType, + ["application/xml"] = okMediaType, + } + }, + ["default"] = new OpenApiResponse + { + Description = "An error response", + Content = { - Description = "An error response", - Content = - { - ["application/json"] = errorMediaType, - ["application/xml"] = errorMediaType - } + ["application/json"] = errorMediaType, + ["application/xml"] = errorMediaType } } - }, - [OperationType.Post] = new OpenApiOperation + } + }, + [OperationType.Post] = new OpenApiOperation + { + Responses = { - Responses = + ["200"] = new OpenApiResponse { - ["200"] = new OpenApiResponse + Description = "An OK response", + Content = { - Description = "An OK response", - Content = - { - ["html/text"] = okMediaType - } - }, - ["default"] = new OpenApiResponse + ["html/text"] = okMediaType + } + }, + ["default"] = new OpenApiResponse + { + Description = "An error response", + Content = { - Description = "An error response", - Content = - { - ["html/text"] = errorMediaType - } + ["html/text"] = errorMediaType } } - }, - [OperationType.Patch] = new OpenApiOperation + } + }, + [OperationType.Patch] = new OpenApiOperation + { + Responses = { - Responses = + ["200"] = new OpenApiResponse { - ["200"] = new OpenApiResponse + Description = "An OK response", + Content = { - Description = "An OK response", - Content = - { - ["application/json"] = okMediaType, - ["application/xml"] = okMediaType, - } - }, - ["default"] = new OpenApiResponse + ["application/json"] = okMediaType, + ["application/xml"] = okMediaType, + } + }, + ["default"] = new OpenApiResponse + { + Description = "An error response", + Content = { - Description = "An error response", - Content = - { - ["application/json"] = errorMediaType, - ["application/xml"] = errorMediaType - } + ["application/json"] = errorMediaType, + ["application/xml"] = errorMediaType } } } } } - }, - Components = new OpenApiComponents + } + }, + Components = new OpenApiComponents + { + Schemas = { - Schemas = - { - ["Item"] = okSchema, - ["Error"] = errorSchema - } + ["Item"] = okSchema, + ["Error"] = errorSchema } - }); - } + } + }); } [Fact] diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs index 22f7d1633..2745385af 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs @@ -21,202 +21,188 @@ public class OpenApiSecuritySchemeTests [Fact] public void ParseHttpSecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicSecurityScheme.yaml"))) - { - var document = LoadYamlDocument(stream); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicSecurityScheme.yaml")); + var document = LoadYamlDocument(stream); - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)document.RootNode); + var node = new MapNode(context, (YamlMappingNode)document.RootNode); - // Act - var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); + // Act + var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme - { - Type = SecuritySchemeType.Http, - Scheme = OpenApiConstants.Basic - }); - } + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.Http, + Scheme = OpenApiConstants.Basic + }); } [Fact] public void ParseApiKeySecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "apiKeySecurityScheme.yaml"))) - { - var document = LoadYamlDocument(stream); - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)document.RootNode); - - // Act - var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); - - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme - { - Type = SecuritySchemeType.ApiKey, - Name = "api_key", - In = ParameterLocation.Header - }); - } + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "apiKeySecurityScheme.yaml")); + var document = LoadYamlDocument(stream); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)document.RootNode); + + // Act + var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); + + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.ApiKey, + Name = "api_key", + In = ParameterLocation.Header + }); } [Fact] public void ParseOAuth2ImplicitSecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2ImplicitSecurityScheme.yaml"))) - { - var document = LoadYamlDocument(stream); - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)document.RootNode); - - // Act - var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); - - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2ImplicitSecurityScheme.yaml")); + var document = LoadYamlDocument(stream); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)document.RootNode); + + // Act + var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); + + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows { - Type = SecuritySchemeType.OAuth2, - Flows = new OpenApiOAuthFlows + Implicit = new OpenApiOAuthFlow { - Implicit = new OpenApiOAuthFlow + AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), + Scopes = { - AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), - Scopes = - { - ["write:pets"] = "modify pets in your account", - ["read:pets"] = "read your pets" - } + ["write:pets"] = "modify pets in your account", + ["read:pets"] = "read your pets" } } - }); - } + } + }); } [Fact] public void ParseOAuth2PasswordSecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2PasswordSecurityScheme.yaml"))) - { - var document = LoadYamlDocument(stream); - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)document.RootNode); - - // Act - var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); - - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2PasswordSecurityScheme.yaml")); + var document = LoadYamlDocument(stream); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)document.RootNode); + + // Act + var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); + + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows { - Type = SecuritySchemeType.OAuth2, - Flows = new OpenApiOAuthFlows + Password = new OpenApiOAuthFlow { - Password = new OpenApiOAuthFlow + AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), + Scopes = { - AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), - Scopes = - { - ["write:pets"] = "modify pets in your account", - ["read:pets"] = "read your pets" - } + ["write:pets"] = "modify pets in your account", + ["read:pets"] = "read your pets" } } - }); - } + } + }); } [Fact] public void ParseOAuth2ApplicationSecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2ApplicationSecurityScheme.yaml"))) - { - var document = LoadYamlDocument(stream); - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)document.RootNode); - - // Act - var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); - - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2ApplicationSecurityScheme.yaml")); + var document = LoadYamlDocument(stream); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)document.RootNode); + + // Act + var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); + + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows { - Type = SecuritySchemeType.OAuth2, - Flows = new OpenApiOAuthFlows + ClientCredentials = new OpenApiOAuthFlow { - ClientCredentials = new OpenApiOAuthFlow + AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), + Scopes = { - AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), - Scopes = - { - ["write:pets"] = "modify pets in your account", - ["read:pets"] = "read your pets" - } + ["write:pets"] = "modify pets in your account", + ["read:pets"] = "read your pets" } } - }); - } + } + }); } [Fact] public void ParseOAuth2AccessCodeSecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2AccessCodeSecurityScheme.yaml"))) - { - var document = LoadYamlDocument(stream); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2AccessCodeSecurityScheme.yaml")); + var document = LoadYamlDocument(stream); - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)document.RootNode); + var node = new MapNode(context, (YamlMappingNode)document.RootNode); - // Act - var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); + // Act + var securityScheme = OpenApiV2Deserializer.LoadSecurityScheme(node); - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows { - Type = SecuritySchemeType.OAuth2, - Flows = new OpenApiOAuthFlows + AuthorizationCode = new OpenApiOAuthFlow { - AuthorizationCode = new OpenApiOAuthFlow + AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), + Scopes = { - AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), - Scopes = - { - ["write:pets"] = "modify pets in your account", - ["read:pets"] = "read your pets" - } + ["write:pets"] = "modify pets in your account", + ["read:pets"] = "read your pets" } } - }); - } + } + }); } static YamlDocument LoadYamlDocument(Stream input) { - using (var reader = new StreamReader(input)) - { - var yamlStream = new YamlStream(); - yamlStream.Load(reader); - return yamlStream.Documents.First(); - } + using var reader = new StreamReader(input); + var yamlStream = new YamlStream(); + yamlStream.Load(reader); + return yamlStream.Documents.First(); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs index 320f01fae..fde8a9b63 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs @@ -21,254 +21,248 @@ public class OpenApiCallbackTests [Fact] public void ParseBasicCallbackShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicCallback.yaml"))) - { - // Arrange - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicCallback.yaml")); + // Arrange + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - // Act - var callback = OpenApiV3Deserializer.LoadCallback(node); + // Act + var callback = OpenApiV3Deserializer.LoadCallback(node); - // Assert - diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); + // Assert + diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); - callback.Should().BeEquivalentTo( - new OpenApiCallback + callback.Should().BeEquivalentTo( + new OpenApiCallback + { + PathItems = { - PathItems = - { - [RuntimeExpression.Build("$request.body#/url")] + [RuntimeExpression.Build("$request.body#/url")] = new OpenApiPathItem { Operations = { [OperationType.Post] = - new OpenApiOperation - { - RequestBody = new OpenApiRequestBody + new OpenApiOperation { - Content = + RequestBody = new OpenApiRequestBody { - ["application/json"] = null - } - }, - Responses = new OpenApiResponses - { - ["200"] = new OpenApiResponse + Content = + { + ["application/json"] = null + } + }, + Responses = new OpenApiResponses { - Description = "Success" + ["200"] = new OpenApiResponse + { + Description = "Success" + } } } - } } } - } - }); - } + } + }); } [Fact] public void ParseCallbackWithReferenceShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "callbackWithReference.yaml"))) - { - // Act - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "callbackWithReference.yaml")); + // Act + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - // Assert - var path = openApiDoc.Paths.First().Value; - var subscribeOperation = path.Operations[OperationType.Post]; + // Assert + var path = openApiDoc.Paths.First().Value; + var subscribeOperation = path.Operations[OperationType.Post]; - var callback = subscribeOperation.Callbacks["simpleHook"]; + var callback = subscribeOperation.Callbacks["simpleHook"]; - diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + diagnostic.Should().BeEquivalentTo( + new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); - callback.Should().BeEquivalentTo( - new OpenApiCallback + callback.Should().BeEquivalentTo( + new OpenApiCallback + { + PathItems = { - PathItems = - { - [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { - Operations = { - [OperationType.Post] = new OpenApiOperation() + [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { + Operations = { + [OperationType.Post] = new OpenApiOperation() + { + RequestBody = new OpenApiRequestBody { - RequestBody = new OpenApiRequestBody + Content = { - Content = + ["application/json"] = new OpenApiMediaType { - ["application/json"] = new OpenApiMediaType + Schema = new OpenApiSchema() { - Schema = new OpenApiSchema() - { - Type = "object" - } + Type = "object" } } - }, - Responses = { - ["200"]= new OpenApiResponse - { - Description = "Success" - } + } + }, + Responses = { + ["200"]= new OpenApiResponse + { + Description = "Success" } } } } - }, - Reference = new OpenApiReference - { - Type = ReferenceType.Callback, - Id = "simpleHook", - HostDocument = openApiDoc } - }); - } + }, + Reference = new OpenApiReference + { + Type = ReferenceType.Callback, + Id = "simpleHook", + HostDocument = openApiDoc + } + }); } [Fact] public void ParseMultipleCallbacksWithReferenceShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "multipleCallbacksWithReference.yaml"))) - { - // Act - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "multipleCallbacksWithReference.yaml")); + // Act + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - // Assert - var path = openApiDoc.Paths.First().Value; - var subscribeOperation = path.Operations[OperationType.Post]; + // Assert + var path = openApiDoc.Paths.First().Value; + var subscribeOperation = path.Operations[OperationType.Post]; - diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + diagnostic.Should().BeEquivalentTo( + new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); - var callback1 = subscribeOperation.Callbacks["simpleHook"]; + var callback1 = subscribeOperation.Callbacks["simpleHook"]; - callback1.Should().BeEquivalentTo( - new OpenApiCallback + callback1.Should().BeEquivalentTo( + new OpenApiCallback + { + PathItems = { - PathItems = - { - [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { - Operations = { - [OperationType.Post] = new OpenApiOperation() + [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { + Operations = { + [OperationType.Post] = new OpenApiOperation() + { + RequestBody = new OpenApiRequestBody { - RequestBody = new OpenApiRequestBody + Content = { - Content = + ["application/json"] = new OpenApiMediaType { - ["application/json"] = new OpenApiMediaType + Schema = new OpenApiSchema() { - Schema = new OpenApiSchema() - { - Type = "object" - } + Type = "object" } } - }, - Responses = { - ["200"]= new OpenApiResponse - { - Description = "Success" - } + } + }, + Responses = { + ["200"]= new OpenApiResponse + { + Description = "Success" } } } } - }, - Reference = new OpenApiReference - { - Type = ReferenceType.Callback, - Id = "simpleHook", - HostDocument = openApiDoc } - }); + }, + Reference = new OpenApiReference + { + Type = ReferenceType.Callback, + Id = "simpleHook", + HostDocument = openApiDoc + } + }); - var callback2 = subscribeOperation.Callbacks["callback2"]; - callback2.Should().BeEquivalentTo( - new OpenApiCallback + var callback2 = subscribeOperation.Callbacks["callback2"]; + callback2.Should().BeEquivalentTo( + new OpenApiCallback + { + PathItems = { - PathItems = - { - [RuntimeExpression.Build("/simplePath")]= new OpenApiPathItem { - Operations = { - [OperationType.Post] = new OpenApiOperation() + [RuntimeExpression.Build("/simplePath")]= new OpenApiPathItem { + Operations = { + [OperationType.Post] = new OpenApiOperation() + { + RequestBody = new OpenApiRequestBody { - RequestBody = new OpenApiRequestBody + Description = "Callback 2", + Content = { - Description = "Callback 2", - Content = + ["application/json"] = new OpenApiMediaType { - ["application/json"] = new OpenApiMediaType + Schema = new OpenApiSchema() { - Schema = new OpenApiSchema() - { - Type = "string" - } + Type = "string" } } - }, - Responses = { - ["400"]= new OpenApiResponse - { - Description = "Callback Response" - } + } + }, + Responses = { + ["400"]= new OpenApiResponse + { + Description = "Callback Response" } } - }, - } + } + }, } - }); + } + }); - var callback3 = subscribeOperation.Callbacks["callback3"]; - callback3.Should().BeEquivalentTo( - new OpenApiCallback + var callback3 = subscribeOperation.Callbacks["callback3"]; + callback3.Should().BeEquivalentTo( + new OpenApiCallback + { + PathItems = { - PathItems = - { - [RuntimeExpression.Build(@"http://example.com?transactionId={$request.body#/id}&email={$request.body#/email}")] = new OpenApiPathItem { - Operations = { - [OperationType.Post] = new OpenApiOperation() + [RuntimeExpression.Build(@"http://example.com?transactionId={$request.body#/id}&email={$request.body#/email}")] = new OpenApiPathItem { + Operations = { + [OperationType.Post] = new OpenApiOperation() + { + RequestBody = new OpenApiRequestBody { - RequestBody = new OpenApiRequestBody + Content = { - Content = + ["application/xml"] = new OpenApiMediaType { - ["application/xml"] = new OpenApiMediaType + Schema = new OpenApiSchema() { - Schema = new OpenApiSchema() - { - Type = "object" - } + Type = "object" } } + } + }, + Responses = { + ["200"]= new OpenApiResponse + { + Description = "Success" }, - Responses = { - ["200"]= new OpenApiResponse - { - Description = "Success" - }, - ["401"]= new OpenApiResponse - { - Description = "Unauthorized" - }, - ["404"]= new OpenApiResponse - { - Description = "Not Found" - } + ["401"]= new OpenApiResponse + { + Description = "Unauthorized" + }, + ["404"]= new OpenApiResponse + { + Description = "Not Found" } } } } } - }); - } + } + }); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs index 0768592b3..6496a48b8 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs @@ -20,32 +20,30 @@ public class OpenApiDiscriminatorTests [Fact] public void ParseBasicDiscriminatorShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicDiscriminator.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicDiscriminator.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - // Act - var discriminator = OpenApiV3Deserializer.LoadDiscriminator(node); + // Act + var discriminator = OpenApiV3Deserializer.LoadDiscriminator(node); - // Assert - discriminator.Should().BeEquivalentTo( - new OpenApiDiscriminator + // Assert + discriminator.Should().BeEquivalentTo( + new OpenApiDiscriminator + { + PropertyName = "pet_type", + Mapping = { - PropertyName = "pet_type", - Mapping = - { - ["puppy"] = "#/components/schemas/Dog", - ["kitten"] = "Cat" - } - }); - } + ["puppy"] = "#/components/schemas/Dog", + ["kitten"] = "Cat" + } + }); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 8a0da3481..a112824be 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -32,46 +32,38 @@ public class OpenApiDocumentTests public T Clone(T element) where T : IOpenApiSerializable { - using (var stream = new MemoryStream()) + using var stream = new MemoryStream(); + IOpenApiWriter writer; + var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); + writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings() { - IOpenApiWriter writer; - var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); - writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings() - { - InlineLocalReferences = true - }); - element.SerializeAsV3(writer); - writer.Flush(); - stream.Position = 0; - - using (var streamReader = new StreamReader(stream)) - { - var result = streamReader.ReadToEnd(); - return new OpenApiStringReader().ReadFragment(result, OpenApiSpecVersion.OpenApi3_0, out OpenApiDiagnostic diagnostic4); - } - } + InlineLocalReferences = true + }); + element.SerializeAsV3(writer); + writer.Flush(); + stream.Position = 0; + + using var streamReader = new StreamReader(stream); + var result = streamReader.ReadToEnd(); + return new OpenApiStringReader().ReadFragment(result, OpenApiSpecVersion.OpenApi3_0, out OpenApiDiagnostic diagnostic4); } public OpenApiSecurityScheme CloneSecurityScheme(OpenApiSecurityScheme element) { - using (var stream = new MemoryStream()) + using var stream = new MemoryStream(); + IOpenApiWriter writer; + var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); + writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings() { - IOpenApiWriter writer; - var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); - writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings() - { - InlineLocalReferences = true - }); - element.SerializeAsV3WithoutReference(writer); - writer.Flush(); - stream.Position = 0; - - using (var streamReader = new StreamReader(stream)) - { - var result = streamReader.ReadToEnd(); - return new OpenApiStringReader().ReadFragment(result, OpenApiSpecVersion.OpenApi3_0, out OpenApiDiagnostic diagnostic4); - } - } + InlineLocalReferences = true + }); + element.SerializeAsV3WithoutReference(writer); + writer.Flush(); + stream.Position = 0; + + using var streamReader = new StreamReader(stream); + var result = streamReader.ReadToEnd(); + return new OpenApiStringReader().ReadFragment(result, OpenApiSpecVersion.OpenApi3_0, out OpenApiDiagnostic diagnostic4); } @@ -182,89 +174,83 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) [Fact] public void ParseBasicDocumentWithMultipleServersShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicDocumentWithMultipleServers.yaml"))) - { - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicDocumentWithMultipleServers.yaml")); + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + diagnostic.Should().BeEquivalentTo( + new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); - openApiDoc.Should().BeEquivalentTo( - new OpenApiDocument + openApiDoc.Should().BeEquivalentTo( + new OpenApiDocument + { + Info = new OpenApiInfo + { + Title = "The API", + Version = "0.9.1", + }, + Servers = { - Info = new OpenApiInfo + new OpenApiServer { - Title = "The API", - Version = "0.9.1", + Url = new Uri("http://www.example.org/api").ToString(), + Description = "The http endpoint" }, - Servers = + new OpenApiServer { - new OpenApiServer - { - Url = new Uri("http://www.example.org/api").ToString(), - Description = "The http endpoint" - }, - new OpenApiServer - { - Url = new Uri("https://www.example.org/api").ToString(), - Description = "The https endpoint" - } - }, - Paths = new OpenApiPaths() - }); - } + Url = new Uri("https://www.example.org/api").ToString(), + Description = "The https endpoint" + } + }, + Paths = new OpenApiPaths() + }); } [Fact] public void ParseBrokenMinimalDocumentShouldYieldExpectedDiagnostic() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "brokenMinimalDocument.yaml"))) - { - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "brokenMinimalDocument.yaml")); + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - openApiDoc.Should().BeEquivalentTo( - new OpenApiDocument + openApiDoc.Should().BeEquivalentTo( + new OpenApiDocument + { + Info = new OpenApiInfo { - Info = new OpenApiInfo - { - Version = "0.9" - }, - Paths = new OpenApiPaths() - }); + Version = "0.9" + }, + Paths = new OpenApiPaths() + }); - diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic + diagnostic.Should().BeEquivalentTo( + new OpenApiDiagnostic + { + Errors = { - Errors = - { - new OpenApiValidatorError(nameof(OpenApiInfoRules.InfoRequiredFields),"#/info/title", "The field 'title' in 'info' object is REQUIRED.") - }, - SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 - }); - } + new OpenApiValidatorError(nameof(OpenApiInfoRules.InfoRequiredFields),"#/info/title", "The field 'title' in 'info' object is REQUIRED.") + }, + SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 + }); } [Fact] public void ParseMinimalDocumentShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "minimalDocument.yaml"))) - { - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "minimalDocument.yaml")); + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - openApiDoc.Should().BeEquivalentTo( - new OpenApiDocument + openApiDoc.Should().BeEquivalentTo( + new OpenApiDocument + { + Info = new OpenApiInfo { - Info = new OpenApiInfo - { - Title = "Simple Document", - Version = "0.9.1" - }, - Paths = new OpenApiPaths() - }); + Title = "Simple Document", + Version = "0.9.1" + }, + Paths = new OpenApiPaths() + }); - diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); - } + diagnostic.Should().BeEquivalentTo( + new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Fact] @@ -1249,85 +1235,81 @@ public void ParsePetStoreExpandedShouldSucceed() [Fact] public void GlobalSecurityRequirementShouldReferenceSecurityScheme() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "securedApi.yaml"))) - { - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "securedApi.yaml")); + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - var securityRequirement = openApiDoc.SecurityRequirements.First(); + var securityRequirement = openApiDoc.SecurityRequirements.First(); - Assert.Same(securityRequirement.Keys.First(), openApiDoc.Components.SecuritySchemes.First().Value); - } + Assert.Same(securityRequirement.Keys.First(), openApiDoc.Components.SecuritySchemes.First().Value); } [Fact] public void HeaderParameterShouldAllowExample() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "apiWithFullHeaderComponent.yaml"))) - { - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "apiWithFullHeaderComponent.yaml")); + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - var exampleHeader = openApiDoc.Components?.Headers?["example-header"]; - Assert.NotNull(exampleHeader); - exampleHeader.Should().BeEquivalentTo( - new OpenApiHeader() + var exampleHeader = openApiDoc.Components?.Headers?["example-header"]; + Assert.NotNull(exampleHeader); + exampleHeader.Should().BeEquivalentTo( + new OpenApiHeader() + { + Description = "Test header with example", + Required = true, + Deprecated = true, + AllowEmptyValue = true, + AllowReserved = true, + Style = ParameterStyle.Simple, + Explode = true, + Example = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721"), + Schema = new OpenApiSchema() { - Description = "Test header with example", - Required = true, - Deprecated = true, - AllowEmptyValue = true, - AllowReserved = true, - Style = ParameterStyle.Simple, - Explode = true, - Example = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721"), - Schema = new OpenApiSchema() - { - Type = "string", - Format = "uuid" - }, - Reference = new OpenApiReference() - { - Type = ReferenceType.Header, - Id = "example-header" - } - }); + Type = "string", + Format = "uuid" + }, + Reference = new OpenApiReference() + { + Type = ReferenceType.Header, + Id = "example-header" + } + }); - var examplesHeader = openApiDoc.Components?.Headers?["examples-header"]; - Assert.NotNull(examplesHeader); - examplesHeader.Should().BeEquivalentTo( - new OpenApiHeader() + var examplesHeader = openApiDoc.Components?.Headers?["examples-header"]; + Assert.NotNull(examplesHeader); + examplesHeader.Should().BeEquivalentTo( + new OpenApiHeader() + { + Description = "Test header with example", + Required = true, + Deprecated = true, + AllowEmptyValue = true, + AllowReserved = true, + Style = ParameterStyle.Simple, + Explode = true, + Examples = new Dictionary() { - Description = "Test header with example", - Required = true, - Deprecated = true, - AllowEmptyValue = true, - AllowReserved = true, - Style = ParameterStyle.Simple, - Explode = true, - Examples = new Dictionary() - { - { "uuid1", new OpenApiExample() - { - Value = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721") - } - }, - { "uuid2", new OpenApiExample() - { - Value = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721") - } + { "uuid1", new OpenApiExample() + { + Value = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721") } }, - Schema = new OpenApiSchema() - { - Type = "string", - Format = "uuid" - }, - Reference = new OpenApiReference() - { - Type = ReferenceType.Header, - Id = "examples-header" + { "uuid2", new OpenApiExample() + { + Value = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721") + } } - }); - } + }, + Schema = new OpenApiSchema() + { + Type = "string", + Format = "uuid" + }, + Reference = new OpenApiReference() + { + Type = ReferenceType.Header, + Id = "examples-header" + } + }); } [Fact] diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs index 7f33491ff..2d3f7d3b6 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs @@ -20,54 +20,51 @@ public class OpenApiEncodingTests [Fact] public void ParseBasicEncodingShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicEncoding.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicEncoding.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - // Act - var encoding = OpenApiV3Deserializer.LoadEncoding(node); + // Act + var encoding = OpenApiV3Deserializer.LoadEncoding(node); - // Assert - encoding.Should().BeEquivalentTo( - new OpenApiEncoding - { - ContentType = "application/xml; charset=utf-8" - }); - } + // Assert + encoding.Should().BeEquivalentTo( + new OpenApiEncoding + { + ContentType = "application/xml; charset=utf-8" + }); } [Fact] public void ParseAdvancedEncodingShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedEncoding.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedEncoding.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - // Act - var encoding = OpenApiV3Deserializer.LoadEncoding(node); + // Act + var encoding = OpenApiV3Deserializer.LoadEncoding(node); - // Assert - encoding.Should().BeEquivalentTo( - new OpenApiEncoding + // Assert + encoding.Should().BeEquivalentTo( + new OpenApiEncoding + { + ContentType = "image/png, image/jpeg", + Headers = { - ContentType = "image/png, image/jpeg", - Headers = - { - ["X-Rate-Limit-Limit"] = + ["X-Rate-Limit-Limit"] = new OpenApiHeader { Description = "The number of allowed requests in the current period", @@ -76,9 +73,8 @@ public void ParseAdvancedEncodingShouldSucceed() Type = "integer" } } - } - }); - } + } + }); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs index ead84f201..68e218408 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs @@ -21,69 +21,65 @@ public class OpenApiExampleTests [Fact] public void ParseAdvancedExampleShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedExample.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedExample.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - var example = OpenApiV3Deserializer.LoadExample(node); + var example = OpenApiV3Deserializer.LoadExample(node); - diagnostic.Errors.Should().BeEmpty(); + diagnostic.Errors.Should().BeEmpty(); - example.Should().BeEquivalentTo( - new OpenApiExample + example.Should().BeEquivalentTo( + new OpenApiExample + { + Value = new OpenApiObject { - Value = new OpenApiObject + ["versions"] = new OpenApiArray { - ["versions"] = new OpenApiArray + new OpenApiObject { - new OpenApiObject + ["status"] = new OpenApiString("Status1"), + ["id"] = new OpenApiString("v1"), + ["links"] = new OpenApiArray { - ["status"] = new OpenApiString("Status1"), - ["id"] = new OpenApiString("v1"), - ["links"] = new OpenApiArray + new OpenApiObject { - new OpenApiObject - { - ["href"] = new OpenApiString("http://example.com/1"), - ["rel"] = new OpenApiString("sampleRel1") - } + ["href"] = new OpenApiString("http://example.com/1"), + ["rel"] = new OpenApiString("sampleRel1") } - }, + } + }, - new OpenApiObject + new OpenApiObject + { + ["status"] = new OpenApiString("Status2"), + ["id"] = new OpenApiString("v2"), + ["links"] = new OpenApiArray { - ["status"] = new OpenApiString("Status2"), - ["id"] = new OpenApiString("v2"), - ["links"] = new OpenApiArray + new OpenApiObject { - new OpenApiObject - { - ["href"] = new OpenApiString("http://example.com/2"), - ["rel"] = new OpenApiString("sampleRel2") - } + ["href"] = new OpenApiString("http://example.com/2"), + ["rel"] = new OpenApiString("sampleRel2") } } } } - }); - } + } + }); } [Fact] public void ParseExampleForcedStringSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "explicitString.yaml"))) - { - new OpenApiStreamReader().Read(stream, out var diagnostic); - diagnostic.Errors.Should().BeEmpty(); - } + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "explicitString.yaml")); + new OpenApiStreamReader().Read(stream, out var diagnostic); + diagnostic.Errors.Should().BeEmpty(); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs index 29b23cb31..29852898f 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs @@ -22,128 +22,122 @@ public class OpenApiInfoTests [Fact] public void ParseAdvancedInfoShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedInfo.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; - - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)yamlNode); - - // Act - var openApiInfo = OpenApiV3Deserializer.LoadInfo(node); - - // Assert - openApiInfo.Should().BeEquivalentTo( - new OpenApiInfo + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedInfo.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; + + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)yamlNode); + + // Act + var openApiInfo = OpenApiV3Deserializer.LoadInfo(node); + + // Assert + openApiInfo.Should().BeEquivalentTo( + new OpenApiInfo + { + Title = "Advanced Info", + Description = "Sample Description", + Version = "1.0.0", + TermsOfService = new Uri("http://example.org/termsOfService"), + Contact = new OpenApiContact { - Title = "Advanced Info", - Description = "Sample Description", - Version = "1.0.0", - TermsOfService = new Uri("http://example.org/termsOfService"), - Contact = new OpenApiContact + Email = "example@example.com", + Extensions = { - Email = "example@example.com", - Extensions = - { - ["x-twitter"] = new OpenApiString("@exampleTwitterHandler") - }, - Name = "John Doe", - Url = new Uri("http://www.example.com/url1") + ["x-twitter"] = new OpenApiString("@exampleTwitterHandler") }, - License = new OpenApiLicense + Name = "John Doe", + Url = new Uri("http://www.example.com/url1") + }, + License = new OpenApiLicense + { + Extensions = { ["x-disclaimer"] = new OpenApiString("Sample Extension String Disclaimer") }, + Name = "licenseName", + Url = new Uri("http://www.example.com/url2") + }, + Extensions = + { + ["x-something"] = new OpenApiString("Sample Extension String Something"), + ["x-contact"] = new OpenApiObject { - Extensions = { ["x-disclaimer"] = new OpenApiString("Sample Extension String Disclaimer") }, - Name = "licenseName", - Url = new Uri("http://www.example.com/url2") + ["name"] = new OpenApiString("John Doe"), + ["url"] = new OpenApiString("http://www.example.com/url3"), + ["email"] = new OpenApiString("example@example.com") }, - Extensions = + ["x-list"] = new OpenApiArray { - ["x-something"] = new OpenApiString("Sample Extension String Something"), - ["x-contact"] = new OpenApiObject - { - ["name"] = new OpenApiString("John Doe"), - ["url"] = new OpenApiString("http://www.example.com/url3"), - ["email"] = new OpenApiString("example@example.com") - }, - ["x-list"] = new OpenApiArray - { - new OpenApiString("1"), - new OpenApiString("2") - } + new OpenApiString("1"), + new OpenApiString("2") } - }); - } + } + }); } [Fact] public void ParseBasicInfoShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicInfo.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; - - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)yamlNode); - - // Act - var openApiInfo = OpenApiV3Deserializer.LoadInfo(node); - - // Assert - openApiInfo.Should().BeEquivalentTo( - new OpenApiInfo + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicInfo.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; + + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)yamlNode); + + // Act + var openApiInfo = OpenApiV3Deserializer.LoadInfo(node); + + // Assert + openApiInfo.Should().BeEquivalentTo( + new OpenApiInfo + { + Title = "Basic Info", + Description = "Sample Description", + Version = "1.0.1", + TermsOfService = new Uri("http://swagger.io/terms/"), + Contact = new OpenApiContact { - Title = "Basic Info", - Description = "Sample Description", - Version = "1.0.1", - TermsOfService = new Uri("http://swagger.io/terms/"), - Contact = new OpenApiContact - { - Email = "support@swagger.io", - Name = "API Support", - Url = new Uri("http://www.swagger.io/support") - }, - License = new OpenApiLicense - { - Name = "Apache 2.0", - Url = new Uri("http://www.apache.org/licenses/LICENSE-2.0.html") - } - }); - } + Email = "support@swagger.io", + Name = "API Support", + Url = new Uri("http://www.swagger.io/support") + }, + License = new OpenApiLicense + { + Name = "Apache 2.0", + Url = new Uri("http://www.apache.org/licenses/LICENSE-2.0.html") + } + }); } [Fact] public void ParseMinimalInfoShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "minimalInfo.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; - - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)yamlNode); - - // Act - var openApiInfo = OpenApiV3Deserializer.LoadInfo(node); - - // Assert - openApiInfo.Should().BeEquivalentTo( - new OpenApiInfo - { - Title = "Minimal Info", - Version = "1.0.1" - }); - } + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "minimalInfo.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; + + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)yamlNode); + + // Act + var openApiInfo = OpenApiV3Deserializer.LoadInfo(node); + + // Assert + openApiInfo.Should().BeEquivalentTo( + new OpenApiInfo + { + Title = "Minimal Info", + Version = "1.0.1" + }); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs index a74c64154..836181532 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs @@ -18,14 +18,12 @@ public class OpenApiOperationTests [Fact] public void OperationWithSecurityRequirementShouldReferenceSecurityScheme() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "securedOperation.yaml"))) - { - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "securedOperation.yaml")); + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - var securityRequirement = openApiDoc.Paths["/"].Operations[Models.OperationType.Get].Security.First(); + var securityRequirement = openApiDoc.Paths["/"].Operations[Models.OperationType.Get].Security.First(); - Assert.Same(securityRequirement.Keys.First(), openApiDoc.Components.SecuritySchemes.First().Value); - } + Assert.Same(securityRequirement.Keys.First(), openApiDoc.Components.SecuritySchemes.First().Value); } [Fact] diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs index 60e3db6e4..c0768f7df 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs @@ -20,14 +20,12 @@ public class OpenApiResponseTests [Fact] public void ResponseWithReferencedHeaderShouldReferenceComponent() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "responseWithHeaderReference.yaml"))) - { - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "responseWithHeaderReference.yaml")); + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - var response = openApiDoc.Components.Responses["Test"]; + var response = openApiDoc.Components.Responses["Test"]; - Assert.Same(response.Headers.First().Value, openApiDoc.Components.Headers.First().Value); - } + Assert.Same(response.Headers.First().Value, openApiDoc.Components.Headers.First().Value); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index 0101d9c6e..a381864ac 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -22,53 +22,49 @@ public class OpenApiSchemaTests [Fact] public void ParsePrimitiveSchemaShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "primitiveSchema.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "primitiveSchema.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - // Act - var schema = OpenApiV3Deserializer.LoadSchema(node); + // Act + var schema = OpenApiV3Deserializer.LoadSchema(node); - // Assert - diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); + // Assert + diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); - schema.Should().BeEquivalentTo( - new OpenApiSchema - { - Type = "string", - Format = "email" - }); - } + schema.Should().BeEquivalentTo( + new OpenApiSchema + { + Type = "string", + Format = "email" + }); } [Fact] public void ParsePrimitiveSchemaFragmentShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "primitiveSchema.yaml"))) - { - var reader = new OpenApiStreamReader(); - var diagnostic = new OpenApiDiagnostic(); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "primitiveSchema.yaml")); + var reader = new OpenApiStreamReader(); + var diagnostic = new OpenApiDiagnostic(); - // Act - var schema = reader.ReadFragment(stream, OpenApiSpecVersion.OpenApi3_0, out diagnostic); + // Act + var schema = reader.ReadFragment(stream, OpenApiSpecVersion.OpenApi3_0, out diagnostic); - // Assert - diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); + // Assert + diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); - schema.Should().BeEquivalentTo( - new OpenApiSchema - { - Type = "string", - Format = "email" - }); - } + schema.Should().BeEquivalentTo( + new OpenApiSchema + { + Type = "string", + Format = "email" + }); } [Fact] @@ -154,51 +150,49 @@ public void ParseEnumFragmentShouldSucceed() [Fact] public void ParseSimpleSchemaShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "simpleSchema.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "simpleSchema.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - // Act - var schema = OpenApiV3Deserializer.LoadSchema(node); + // Act + var schema = OpenApiV3Deserializer.LoadSchema(node); - // Assert - diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); + // Assert + diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); - schema.Should().BeEquivalentTo( - new OpenApiSchema + schema.Should().BeEquivalentTo( + new OpenApiSchema + { + Type = "object", + Required = { - Type = "object", - Required = + "name" + }, + Properties = + { + ["name"] = new OpenApiSchema { - "name" + Type = "string" }, - Properties = + ["address"] = new OpenApiSchema { - ["name"] = new OpenApiSchema - { - Type = "string" - }, - ["address"] = new OpenApiSchema - { - Type = "string" - }, - ["age"] = new OpenApiSchema - { - Type = "integer", - Format = "int32", - Minimum = 0 - } + Type = "string" }, - AdditionalPropertiesAllowed = false - }); - } + ["age"] = new OpenApiSchema + { + Type = "integer", + Format = "int32", + Minimum = 0 + } + }, + AdditionalPropertiesAllowed = false + }); } [Fact] @@ -243,416 +237,406 @@ public void ParsePathFragmentShouldSucceed() [Fact] public void ParseDictionarySchemaShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "dictionarySchema.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "dictionarySchema.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - // Act - var schema = OpenApiV3Deserializer.LoadSchema(node); + // Act + var schema = OpenApiV3Deserializer.LoadSchema(node); - // Assert - diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); + // Assert + diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); - schema.Should().BeEquivalentTo( - new OpenApiSchema + schema.Should().BeEquivalentTo( + new OpenApiSchema + { + Type = "object", + AdditionalProperties = new OpenApiSchema { - Type = "object", - AdditionalProperties = new OpenApiSchema - { - Type = "string" - } - }); - } + Type = "string" + } + }); } [Fact] public void ParseBasicSchemaWithExampleShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicSchemaWithExample.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicSchemaWithExample.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - // Act - var schema = OpenApiV3Deserializer.LoadSchema(node); + // Act + var schema = OpenApiV3Deserializer.LoadSchema(node); - // Assert - diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); + // Assert + diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); - schema.Should().BeEquivalentTo( - new OpenApiSchema + schema.Should().BeEquivalentTo( + new OpenApiSchema + { + Type = "object", + Properties = { - Type = "object", - Properties = - { - ["id"] = new OpenApiSchema - { - Type = "integer", - Format = "int64" - }, - ["name"] = new OpenApiSchema - { - Type = "string" - } - }, - Required = + ["id"] = new OpenApiSchema { - "name" + Type = "integer", + Format = "int64" }, - Example = new OpenApiObject + ["name"] = new OpenApiSchema { - ["name"] = new OpenApiString("Puma"), - ["id"] = new OpenApiLong(1) + Type = "string" } - }); - } + }, + Required = + { + "name" + }, + Example = new OpenApiObject + { + ["name"] = new OpenApiString("Puma"), + ["id"] = new OpenApiLong(1) + } + }); } [Fact] public void ParseBasicSchemaWithReferenceShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicSchemaWithReference.yaml"))) - { - // Act - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicSchemaWithReference.yaml")); + // Act + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - // Assert - var components = openApiDoc.Components; + // Assert + var components = openApiDoc.Components; - diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + diagnostic.Should().BeEquivalentTo( + new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); - components.Should().BeEquivalentTo( - new OpenApiComponents + components.Should().BeEquivalentTo( + new OpenApiComponents + { + Schemas = { - Schemas = + ["ErrorModel"] = new OpenApiSchema { - ["ErrorModel"] = new OpenApiSchema + Type = "object", + Properties = { - Type = "object", - Properties = + ["code"] = new OpenApiSchema { - ["code"] = new OpenApiSchema - { - Type = "integer", - Minimum = 100, - Maximum = 600 - }, - ["message"] = new OpenApiSchema - { - Type = "string" - } + Type = "integer", + Minimum = 100, + Maximum = 600 }, - Reference = new OpenApiReference + ["message"] = new OpenApiSchema { - Type = ReferenceType.Schema, - Id = "ErrorModel", - HostDocument = openApiDoc - }, - Required = - { - "message", - "code" + Type = "string" } }, - ["ExtendedErrorModel"] = new OpenApiSchema + Reference = new OpenApiReference { - Reference = new OpenApiReference - { - Type = ReferenceType.Schema, - Id = "ExtendedErrorModel", - HostDocument = openApiDoc - }, - AllOf = + Type = ReferenceType.Schema, + Id = "ErrorModel", + HostDocument = openApiDoc + }, + Required = + { + "message", + "code" + } + }, + ["ExtendedErrorModel"] = new OpenApiSchema + { + Reference = new OpenApiReference + { + Type = ReferenceType.Schema, + Id = "ExtendedErrorModel", + HostDocument = openApiDoc + }, + AllOf = + { + new OpenApiSchema { - new OpenApiSchema + Reference = new OpenApiReference { - Reference = new OpenApiReference - { - Type = ReferenceType.Schema, - Id = "ErrorModel", - HostDocument = openApiDoc - }, - // Schema should be dereferenced in our model, so all the properties - // from the ErrorModel above should be propagated here. - Type = "object", - Properties = + Type = ReferenceType.Schema, + Id = "ErrorModel", + HostDocument = openApiDoc + }, + // Schema should be dereferenced in our model, so all the properties + // from the ErrorModel above should be propagated here. + Type = "object", + Properties = + { + ["code"] = new OpenApiSchema { - ["code"] = new OpenApiSchema - { - Type = "integer", - Minimum = 100, - Maximum = 600 - }, - ["message"] = new OpenApiSchema - { - Type = "string" - } + Type = "integer", + Minimum = 100, + Maximum = 600 }, - Required = + ["message"] = new OpenApiSchema { - "message", - "code" + Type = "string" } }, - new OpenApiSchema + Required = + { + "message", + "code" + } + }, + new OpenApiSchema + { + Type = "object", + Required = {"rootCause"}, + Properties = { - Type = "object", - Required = {"rootCause"}, - Properties = + ["rootCause"] = new OpenApiSchema { - ["rootCause"] = new OpenApiSchema - { - Type = "string" - } + Type = "string" } } } } } - }, options => options.Excluding(m => m.Name == "HostDocument")); - } + } + }, options => options.Excluding(m => m.Name == "HostDocument")); } [Fact] public void ParseAdvancedSchemaWithReferenceShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedSchemaWithReference.yaml"))) - { - // Act - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedSchemaWithReference.yaml")); + // Act + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - // Assert - var components = openApiDoc.Components; + // Assert + var components = openApiDoc.Components; - diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + diagnostic.Should().BeEquivalentTo( + new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); - components.Should().BeEquivalentTo( - new OpenApiComponents + components.Should().BeEquivalentTo( + new OpenApiComponents + { + Schemas = { - Schemas = + ["Pet"] = new OpenApiSchema { - ["Pet"] = new OpenApiSchema + Type = "object", + Discriminator = new OpenApiDiscriminator { - Type = "object", - Discriminator = new OpenApiDiscriminator - { - PropertyName = "petType" - }, - Properties = - { - ["name"] = new OpenApiSchema - { - Type = "string" - }, - ["petType"] = new OpenApiSchema - { - Type = "string" - } - }, - Required = + PropertyName = "petType" + }, + Properties = + { + ["name"] = new OpenApiSchema { - "name", - "petType" + Type = "string" }, - Reference = new OpenApiReference() + ["petType"] = new OpenApiSchema { - Id= "Pet", - Type = ReferenceType.Schema, - HostDocument = openApiDoc + Type = "string" } }, - ["Cat"] = new OpenApiSchema + Required = + { + "name", + "petType" + }, + Reference = new OpenApiReference() { - Description = "A representation of a cat", - AllOf = + Id= "Pet", + Type = ReferenceType.Schema, + HostDocument = openApiDoc + } + }, + ["Cat"] = new OpenApiSchema + { + Description = "A representation of a cat", + AllOf = + { + new OpenApiSchema { - new OpenApiSchema + Reference = new OpenApiReference { - Reference = new OpenApiReference - { - Type = ReferenceType.Schema, - Id = "Pet", - HostDocument = openApiDoc - }, - // Schema should be dereferenced in our model, so all the properties - // from the Pet above should be propagated here. - Type = "object", - Discriminator = new OpenApiDiscriminator - { - PropertyName = "petType" - }, - Properties = + Type = ReferenceType.Schema, + Id = "Pet", + HostDocument = openApiDoc + }, + // Schema should be dereferenced in our model, so all the properties + // from the Pet above should be propagated here. + Type = "object", + Discriminator = new OpenApiDiscriminator + { + PropertyName = "petType" + }, + Properties = + { + ["name"] = new OpenApiSchema { - ["name"] = new OpenApiSchema - { - Type = "string" - }, - ["petType"] = new OpenApiSchema - { - Type = "string" - } + Type = "string" }, - Required = + ["petType"] = new OpenApiSchema { - "name", - "petType" + Type = "string" } }, - new OpenApiSchema + Required = + { + "name", + "petType" + } + }, + new OpenApiSchema + { + Type = "object", + Required = {"huntingSkill"}, + Properties = { - Type = "object", - Required = {"huntingSkill"}, - Properties = + ["huntingSkill"] = new OpenApiSchema { - ["huntingSkill"] = new OpenApiSchema + Type = "string", + Description = "The measured skill for hunting", + Enum = { - Type = "string", - Description = "The measured skill for hunting", - Enum = - { - new OpenApiString("clueless"), - new OpenApiString("lazy"), - new OpenApiString("adventurous"), - new OpenApiString("aggressive") - } + new OpenApiString("clueless"), + new OpenApiString("lazy"), + new OpenApiString("adventurous"), + new OpenApiString("aggressive") } } } - }, - Reference = new OpenApiReference() - { - Id= "Cat", - Type = ReferenceType.Schema, - HostDocument = openApiDoc } }, - ["Dog"] = new OpenApiSchema + Reference = new OpenApiReference() + { + Id= "Cat", + Type = ReferenceType.Schema, + HostDocument = openApiDoc + } + }, + ["Dog"] = new OpenApiSchema + { + Description = "A representation of a dog", + AllOf = { - Description = "A representation of a dog", - AllOf = + new OpenApiSchema { - new OpenApiSchema + Reference = new OpenApiReference { - Reference = new OpenApiReference - { - Type = ReferenceType.Schema, - Id = "Pet", - HostDocument = openApiDoc - }, - // Schema should be dereferenced in our model, so all the properties - // from the Pet above should be propagated here. - Type = "object", - Discriminator = new OpenApiDiscriminator - { - PropertyName = "petType" - }, - Properties = + Type = ReferenceType.Schema, + Id = "Pet", + HostDocument = openApiDoc + }, + // Schema should be dereferenced in our model, so all the properties + // from the Pet above should be propagated here. + Type = "object", + Discriminator = new OpenApiDiscriminator + { + PropertyName = "petType" + }, + Properties = + { + ["name"] = new OpenApiSchema { - ["name"] = new OpenApiSchema - { - Type = "string" - }, - ["petType"] = new OpenApiSchema - { - Type = "string" - } + Type = "string" }, - Required = + ["petType"] = new OpenApiSchema { - "name", - "petType" + Type = "string" } }, - new OpenApiSchema + Required = { - Type = "object", - Required = {"packSize"}, - Properties = - { - ["packSize"] = new OpenApiSchema - { - Type = "integer", - Format = "int32", - Description = "the size of the pack the dog is from", - Default = new OpenApiInteger(0), - Minimum = 0 - } - } + "name", + "petType" } }, - Reference = new OpenApiReference() + new OpenApiSchema { - Id= "Dog", - Type = ReferenceType.Schema, - HostDocument = openApiDoc + Type = "object", + Required = {"packSize"}, + Properties = + { + ["packSize"] = new OpenApiSchema + { + Type = "integer", + Format = "int32", + Description = "the size of the pack the dog is from", + Default = new OpenApiInteger(0), + Minimum = 0 + } + } } + }, + Reference = new OpenApiReference() + { + Id= "Dog", + Type = ReferenceType.Schema, + HostDocument = openApiDoc } } - }, options => options.Excluding(m => m.Name == "HostDocument")); - } + } + }, options => options.Excluding(m => m.Name == "HostDocument")); } [Fact] public void ParseSelfReferencingSchemaShouldNotStackOverflow() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "selfReferencingSchema.yaml"))) - { - // Act - var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "selfReferencingSchema.yaml")); + // Act + var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); - // Assert - var components = openApiDoc.Components; + // Assert + var components = openApiDoc.Components; - diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + diagnostic.Should().BeEquivalentTo( + new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); - var schemaExtension = new OpenApiSchema() - { - AllOf = { new OpenApiSchema() + var schemaExtension = new OpenApiSchema() + { + AllOf = { new OpenApiSchema() { Title = "schemaExtension", Type = "object", Properties = { - ["description"] = new OpenApiSchema() { Type = "string", Nullable = true}, - ["targetTypes"] = new OpenApiSchema() { - Type = "array", - Items = new OpenApiSchema() { - Type = "string" - } - }, - ["status"] = new OpenApiSchema() { Type = "string"}, - ["owner"] = new OpenApiSchema() { Type = "string"}, - ["child"] = null - } + ["description"] = new OpenApiSchema() { Type = "string", Nullable = true}, + ["targetTypes"] = new OpenApiSchema() { + Type = "array", + Items = new OpenApiSchema() { + Type = "string" + } + }, + ["status"] = new OpenApiSchema() { Type = "string"}, + ["owner"] = new OpenApiSchema() { Type = "string"}, + ["child"] = null } - }, - Reference = new OpenApiReference() - { - Type = ReferenceType.Schema, - Id = "microsoft.graph.schemaExtension" } - }; + }, + Reference = new OpenApiReference() + { + Type = ReferenceType.Schema, + Id = "microsoft.graph.schemaExtension" + } + }; - schemaExtension.AllOf[0].Properties["child"] = schemaExtension; + schemaExtension.AllOf[0].Properties["child"] = schemaExtension; - components.Schemas["microsoft.graph.schemaExtension"].Should().BeEquivalentTo(components.Schemas["microsoft.graph.schemaExtension"].AllOf[0].Properties["child"]); - } + components.Schemas["microsoft.graph.schemaExtension"].Should().BeEquivalentTo(components.Schemas["microsoft.graph.schemaExtension"].AllOf[0].Properties["child"]); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs index 9d7a27d72..6992e68f5 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs @@ -21,150 +21,140 @@ public class OpenApiSecuritySchemeTests [Fact] public void ParseHttpSecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "httpSecurityScheme.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; - - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)yamlNode); - - // Act - var securityScheme = OpenApiV3Deserializer.LoadSecurityScheme(node); - - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme - { - Type = SecuritySchemeType.Http, - Scheme = OpenApiConstants.Basic - }); - } + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "httpSecurityScheme.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; + + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)yamlNode); + + // Act + var securityScheme = OpenApiV3Deserializer.LoadSecurityScheme(node); + + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.Http, + Scheme = OpenApiConstants.Basic + }); } [Fact] public void ParseApiKeySecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "apiKeySecurityScheme.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; - - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)yamlNode); - - // Act - var securityScheme = OpenApiV3Deserializer.LoadSecurityScheme(node); - - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme - { - Type = SecuritySchemeType.ApiKey, - Name = "api_key", - In = ParameterLocation.Header - }); - } + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "apiKeySecurityScheme.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; + + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)yamlNode); + + // Act + var securityScheme = OpenApiV3Deserializer.LoadSecurityScheme(node); + + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.ApiKey, + Name = "api_key", + In = ParameterLocation.Header + }); } [Fact] public void ParseBearerSecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "bearerSecurityScheme.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; - - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)yamlNode); - - // Act - var securityScheme = OpenApiV3Deserializer.LoadSecurityScheme(node); - - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme - { - Type = SecuritySchemeType.Http, - Scheme = OpenApiConstants.Bearer, - BearerFormat = OpenApiConstants.Jwt - }); - } + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "bearerSecurityScheme.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; + + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)yamlNode); + + // Act + var securityScheme = OpenApiV3Deserializer.LoadSecurityScheme(node); + + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.Http, + Scheme = OpenApiConstants.Bearer, + BearerFormat = OpenApiConstants.Jwt + }); } [Fact] public void ParseOAuth2SecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2SecurityScheme.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2SecurityScheme.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - // Act - var securityScheme = OpenApiV3Deserializer.LoadSecurityScheme(node); + // Act + var securityScheme = OpenApiV3Deserializer.LoadSecurityScheme(node); - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows { - Type = SecuritySchemeType.OAuth2, - Flows = new OpenApiOAuthFlows + Implicit = new OpenApiOAuthFlow { - Implicit = new OpenApiOAuthFlow + AuthorizationUrl = new Uri("https://example.com/api/oauth/dialog"), + Scopes = { - AuthorizationUrl = new Uri("https://example.com/api/oauth/dialog"), - Scopes = - { - ["write:pets"] = "modify pets in your account", - ["read:pets"] = "read your pets" - } + ["write:pets"] = "modify pets in your account", + ["read:pets"] = "read your pets" } } - }); - } + } + }); } [Fact] public void ParseOpenIdConnectSecuritySchemeShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "openIdConnectSecurityScheme.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; - - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); - - var node = new MapNode(context, (YamlMappingNode)yamlNode); - - // Act - var securityScheme = OpenApiV3Deserializer.LoadSecurityScheme(node); - - // Assert - securityScheme.Should().BeEquivalentTo( - new OpenApiSecurityScheme - { - Type = SecuritySchemeType.OpenIdConnect, - Description = "Sample Description", - OpenIdConnectUrl = new Uri("http://www.example.com") - }); - } + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "openIdConnectSecurityScheme.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; + + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); + + var node = new MapNode(context, (YamlMappingNode)yamlNode); + + // Act + var securityScheme = OpenApiV3Deserializer.LoadSecurityScheme(node); + + // Assert + securityScheme.Should().BeEquivalentTo( + new OpenApiSecurityScheme + { + Type = SecuritySchemeType.OpenIdConnect, + Description = "Sample Description", + OpenIdConnectUrl = new Uri("http://www.example.com") + }); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs index a10d674a9..19e411e15 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs @@ -21,30 +21,28 @@ public class OpenApiXmlTests [Fact] public void ParseBasicXmlShouldSucceed() { - using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicXml.yaml"))) - { - var yamlStream = new YamlStream(); - yamlStream.Load(new StreamReader(stream)); - var yamlNode = yamlStream.Documents.First().RootNode; + using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicXml.yaml")); + var yamlStream = new YamlStream(); + yamlStream.Load(new StreamReader(stream)); + var yamlNode = yamlStream.Documents.First().RootNode; - var diagnostic = new OpenApiDiagnostic(); - var context = new ParsingContext(diagnostic); + var diagnostic = new OpenApiDiagnostic(); + var context = new ParsingContext(diagnostic); - var node = new MapNode(context, (YamlMappingNode)yamlNode); + var node = new MapNode(context, (YamlMappingNode)yamlNode); - // Act - var xml = OpenApiV3Deserializer.LoadXml(node); + // Act + var xml = OpenApiV3Deserializer.LoadXml(node); - // Assert - xml.Should().BeEquivalentTo( - new OpenApiXml - { - Name = "name1", - Namespace = new Uri("http://example.com/schema/namespaceSample"), - Prefix = "samplePrefix", - Wrapped = true - }); - } + // Assert + xml.Should().BeEquivalentTo( + new OpenApiXml + { + Name = "name1", + Namespace = new Uri("http://example.com/schema/namespaceSample"), + Prefix = "samplePrefix", + Wrapped = true + }); } } } From 4b341a04bfcba7242eb7ca424c3ba1e97ee381e5 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 19:18:24 +1100 Subject: [PATCH 21/69] remove some redundant braces --- .../Formatters/PowerShellFormatter.cs | 2 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 4 +- src/Microsoft.OpenApi.Hidi/Program.cs | 2 +- .../OpenApiYamlDocumentReader.cs | 4 +- .../ParseNodes/MapNode.cs | 4 +- .../V2/OpenApiDocumentDeserializer.cs | 6 +- .../V2/OpenApiOperationDeserializer.cs | 4 +- .../V2/OpenApiPathItemDeserializer.cs | 2 +- .../OpenApiSecurityRequirementDeserializer.cs | 4 +- .../V3/OpenApiDocumentDeserializer.cs | 2 +- .../V3/OpenApiOperationDeserializer.cs | 4 +- .../V3/OpenApiPathItemDeserializer.cs | 2 +- .../V3/OpenApiSchemaDeserializer.cs | 2 +- .../OpenApiSecurityRequirementDeserializer.cs | 4 +- src/Microsoft.OpenApi.Workbench/MainModel.cs | 3 +- .../OpenApiPrimaryErrorMessageExtension.cs | 3 +- .../Services/OpenApiReferenceResolver.cs | 4 +- .../Services/OperationSearch.cs | 2 +- .../Formatters/PowerShellFormatterTests.cs | 15 +- .../Services/OpenApiFilterServiceTests.cs | 7 +- .../Services/OpenApiServiceTests.cs | 6 +- .../UtilityFiles/OpenApiDocumentMock.cs | 134 +++++++++--------- .../OpenApiDiagnosticTests.cs | 2 +- .../OpenApiWorkspaceStreamTests.cs | 4 +- .../ParseNodeTests.cs | 6 +- .../ParseNodes/OpenApiAnyConverterTests.cs | 128 ++++++++--------- .../TryLoadReferenceV2Tests.cs | 4 +- .../TestCustomExtension.cs | 5 +- .../V2Tests/OpenApiDocumentTests.cs | 26 ++-- .../V2Tests/OpenApiHeaderTests.cs | 4 +- .../V2Tests/OpenApiOperationTests.cs | 30 ++-- .../V2Tests/OpenApiParameterTests.cs | 18 +-- .../V2Tests/OpenApiPathItemTests.cs | 8 +- .../V2Tests/OpenApiServerTests.cs | 26 ++-- .../V3Tests/OpenApiCallbackTests.cs | 20 +-- .../V3Tests/OpenApiDocumentTests.cs | 46 +++--- .../V3Tests/OpenApiMediaTypeTests.cs | 4 +- .../V3Tests/OpenApiOperationTests.cs | 4 +- .../V3Tests/OpenApiParameterTests.cs | 4 +- .../V3Tests/OpenApiSchemaTests.cs | 37 ++--- test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs | 2 +- .../GraphTests.cs | 2 +- .../Expressions/RuntimeExpressionTests.cs | 4 +- .../Models/OpenApiComponentsTests.cs | 18 +-- .../Models/OpenApiDocumentTests.cs | 61 ++++---- .../Models/OpenApiOperationTests.cs | 36 ++--- .../Models/OpenApiSchemaTests.cs | 8 +- .../PublicApi/PublicApiTests.cs | 2 +- .../Services/OpenApiUrlTreeNodeTests.cs | 69 ++++----- .../Services/OpenApiValidatorTests.cs | 8 +- .../OpenApiComponentsValidationTests.cs | 2 +- .../OpenApiContactValidationTests.cs | 2 +- .../OpenApiHeaderValidationTests.cs | 26 ++-- .../OpenApiMediaTypeValidationTests.cs | 26 ++-- .../OpenApiParameterValidationTests.cs | 36 ++--- .../OpenApiReferenceValidationTests.cs | 48 +++---- .../OpenApiSchemaValidationTests.cs | 38 ++--- .../Walkers/WalkerLocationTests.cs | 63 ++++---- .../Workspaces/OpenApiReferencableTests.cs | 4 +- .../Workspaces/OpenApiWorkspaceTests.cs | 49 ++++--- .../Writers/OpenApiYamlWriterTests.cs | 30 ++-- 61 files changed, 578 insertions(+), 552 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs index 450a05d21..4db55a05e 100644 --- a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs +++ b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs @@ -179,7 +179,7 @@ private void AddAdditionalPropertiesToSchema(OpenApiSchema schema) { if (schema != null && !_schemaLoop.Contains(schema) && "object".Equals(schema.Type, StringComparison.OrdinalIgnoreCase)) { - schema.AdditionalProperties = new OpenApiSchema() { Type = "object" }; + schema.AdditionalProperties = new OpenApiSchema { Type = "object" }; /* Because 'additionalProperties' are now being walked, * we need a way to keep track of visited schemas to avoid diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index b3e66cfe2..63a8bbb94 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -186,7 +186,7 @@ private static void WriteOpenApi(HidiOptions options, OpenApiFormat openApiForma using var outputStream = options.Output.Create(); using var textWriter = new StreamWriter(outputStream); - var settings = new OpenApiWriterSettings() + var settings = new OpenApiWriterSettings { InlineLocalReferences = options.InlineLocal, InlineExternalReferences = options.InlineExternal @@ -738,7 +738,7 @@ internal static async Task PluginManifest(HidiOptions options, ILogger logger, C WriteOpenApi(options, OpenApiFormat.Json, OpenApiSpecVersion.OpenApi3_0, document, logger); // Create OpenAIPluginManifest from ApiDependency and OpenAPI document - var manifest = new OpenAIPluginManifest() + var manifest = new OpenAIPluginManifest { NameForHuman = document.Info.Title, DescriptionForHuman = document.Info.Description, diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index b8508ab5f..faf09352f 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -22,7 +22,7 @@ static async Task Main(string[] args) internal static RootCommand CreateRootCommand() { - var rootCommand = new RootCommand() { }; + var rootCommand = new RootCommand { }; var commandOptions = new CommandOptions(); diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs index 4a120cbbf..5537366d0 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs @@ -133,7 +133,7 @@ public async Task ReadAsync(YamlDocument input, CancellationToken ca } } - return new ReadResult() + return new ReadResult { OpenApiDocument = document, OpenApiDiagnostic = diagnostic @@ -148,7 +148,7 @@ private async Task LoadExternalRefs(OpenApiDocument document, // Load this root document into the workspace var streamLoader = new DefaultStreamLoader(_settings.BaseUrl); var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings); - return await workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document, cancellationToken); + return await workspaceLoader.LoadAsync(new OpenApiReference { ExternalResource = "/" }, document, cancellationToken); } private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument document) diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs index 0ee5934ce..92c49726b 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs @@ -120,7 +120,7 @@ public override Dictionary CreateMapWithReference( // If the component isn't a reference to another component, then point it to itself. if (entry.value.Reference == null) { - entry.value.Reference = new OpenApiReference() + entry.value.Reference = new OpenApiReference { Type = referenceType, Id = entry.key @@ -184,7 +184,7 @@ public override string GetRaw() public T GetReferencedObject(ReferenceType referenceType, string referenceId) where T : IOpenApiReferenceable, new() { - return new T() + return new T { UnresolvedReference = true, Reference = Context.VersionService.ConvertToOpenApiReference(referenceId, referenceType) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs index fa3aa7224..806c96877 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs @@ -220,7 +220,7 @@ private static string BuildUrl(string scheme, string host, string basePath) port = int.Parse(pieces.Last(), CultureInfo.InvariantCulture); } - var uriBuilder = new UriBuilder() + var uriBuilder = new UriBuilder { Scheme = scheme, Host = host, @@ -327,10 +327,10 @@ public override void Visit(OpenApiOperation operation) if (body != null) { operation.Parameters.Remove(body); - operation.RequestBody = new OpenApiRequestBody() + operation.RequestBody = new OpenApiRequestBody { UnresolvedReference = true, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = body.Reference.Id, Type = ReferenceType.RequestBody diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs index 1cf5b7ae8..cf54df8c3 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs @@ -221,10 +221,10 @@ private static OpenApiTag LoadTagByReference( ParsingContext context, string tagName) { - var tagObject = new OpenApiTag() + var tagObject = new OpenApiTag { UnresolvedReference = true, - Reference = new OpenApiReference() { Id = tagName, Type = ReferenceType.Tag } + Reference = new OpenApiReference { Id = tagName, Type = ReferenceType.Tag } }; return tagObject; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs index d905ea42e..d9db5a8d8 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs @@ -20,7 +20,7 @@ internal static partial class OpenApiV2Deserializer { "$ref", (o, n) => { - o.Reference = new OpenApiReference() { ExternalResource = n.GetScalarValue() }; + o.Reference = new OpenApiReference { ExternalResource = n.GetScalarValue() }; o.UnresolvedReference =true; } }, diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs index c5e0776ee..c8384fb05 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs @@ -45,10 +45,10 @@ private static OpenApiSecurityScheme LoadSecuritySchemeByReference( ParsingContext context, string schemeName) { - var securitySchemeObject = new OpenApiSecurityScheme() + var securitySchemeObject = new OpenApiSecurityScheme { UnresolvedReference = true, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = schemeName, Type = ReferenceType.SecurityScheme diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs index df1434cd9..d5c437148 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs @@ -30,7 +30,7 @@ internal static partial class OpenApiV3Deserializer {"tags", (o, n) => {o.Tags = n.CreateList(LoadTag); foreach (var tag in o.Tags) { - tag.Reference = new OpenApiReference() + tag.Reference = new OpenApiReference { Id = tag.Name, Type = ReferenceType.Tag diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs index 16f7a16f4..d6cd2e387 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs @@ -112,10 +112,10 @@ private static OpenApiTag LoadTagByReference( ParsingContext context, string tagName) { - var tagObject = new OpenApiTag() + var tagObject = new OpenApiTag { UnresolvedReference = true, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Tag, Id = tagName diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs index 371e7da80..698fe64cc 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs @@ -18,7 +18,7 @@ internal static partial class OpenApiV3Deserializer { "$ref", (o,n) => { - o.Reference = new OpenApiReference() { ExternalResource = n.GetScalarValue() }; + o.Reference = new OpenApiReference { ExternalResource = n.GetScalarValue() }; o.UnresolvedReference =true; } }, diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs index 60727c4bb..e5482e22f 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs @@ -280,7 +280,7 @@ public static OpenApiSchema LoadSchema(ParseNode node) if (pointer != null) { - return new OpenApiSchema() + return new OpenApiSchema { UnresolvedReference = true, Reference = node.Context.VersionService.ConvertToOpenApiReference(pointer, ReferenceType.Schema) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs index b6b80cf7b..ed8322622 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs @@ -44,10 +44,10 @@ private static OpenApiSecurityScheme LoadSecuritySchemeByReference( ParsingContext context, string schemeName) { - var securitySchemeObject = new OpenApiSecurityScheme() + var securitySchemeObject = new OpenApiSecurityScheme { UnresolvedReference = true, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = schemeName, Type = ReferenceType.SecurityScheme diff --git a/src/Microsoft.OpenApi.Workbench/MainModel.cs b/src/Microsoft.OpenApi.Workbench/MainModel.cs index 70074736b..0d0d689ec 100644 --- a/src/Microsoft.OpenApi.Workbench/MainModel.cs +++ b/src/Microsoft.OpenApi.Workbench/MainModel.cs @@ -313,7 +313,8 @@ private string WriteContents(OpenApiDocument document) outputStream, Version, Format, - new OpenApiWriterSettings() { + new OpenApiWriterSettings + { InlineLocalReferences = InlineLocal, InlineExternalReferences = InlineExternal }); diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs index adcaa85dd..9a92e0d6e 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs @@ -37,7 +37,8 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) public static OpenApiPrimaryErrorMessageExtension Parse(IOpenApiAny source) { if (source is not OpenApiBoolean rawObject) throw new ArgumentOutOfRangeException(nameof(source)); - return new OpenApiPrimaryErrorMessageExtension() { + return new OpenApiPrimaryErrorMessageExtension + { IsPrimaryErrorMessage = rawObject.Value }; } diff --git a/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs b/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs index 3b431d4b5..dc0fb1c8d 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs @@ -206,7 +206,7 @@ private void ResolveTags(IList tags) if (resolvedTag == null) { - resolvedTag = new OpenApiTag() + resolvedTag = new OpenApiTag { Name = tag.Reference.Id }; @@ -291,7 +291,7 @@ private void ResolveTags(IList tags) else { // Leave as unresolved reference - return new T() + return new T { UnresolvedReference = true, Reference = reference diff --git a/src/Microsoft.OpenApi/Services/OperationSearch.cs b/src/Microsoft.OpenApi/Services/OperationSearch.cs index 90e88cc70..8d251ec71 100644 --- a/src/Microsoft.OpenApi/Services/OperationSearch.cs +++ b/src/Microsoft.OpenApi/Services/OperationSearch.cs @@ -43,7 +43,7 @@ public override void Visit(OpenApiPathItem pathItem) if (_predicate(CurrentKeys.Path, operationType, operation)) { - _searchResults.Add(new SearchResult() + _searchResults.Add(new SearchResult { Operation = operation, Parameters = pathItem.Parameters, diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs index a22348897..c261a8e46 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs @@ -21,14 +21,15 @@ public class PowerShellFormatterTests public void FormatOperationIdsInOpenAPIDocument(string operationId, string expectedOperationId, OperationType operationType, string path = "/foo") { // Arrange - var openApiDocument = new OpenApiDocument() + var openApiDocument = new OpenApiDocument { Info = new() { Title = "Test", Version = "1.0" }, - Servers = new List() { new() { Url = "https://localhost/" } }, + Servers = new List { new() { Url = "https://localhost/" } }, Paths = new() { { path, new() { - Operations = new Dictionary() { + Operations = new Dictionary + { { operationType, new() { OperationId = operationId } } } } @@ -92,14 +93,14 @@ public void ResolveFunctionParameters() private static OpenApiDocument GetSampleOpenApiDocument() { - return new OpenApiDocument() + return new OpenApiDocument { Info = new() { Title = "Test", Version = "1.0" }, - Servers = new List() { new() { Url = "https://localhost/" } }, + Servers = new List { new() { Url = "https://localhost/" } }, Paths = new() { { "/foo", new() { - Operations = new Dictionary() + Operations = new Dictionary { { OperationType.Get, new() @@ -107,7 +108,7 @@ private static OpenApiDocument GetSampleOpenApiDocument() OperationId = "Foo.GetFoo", Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "ids", In = ParameterLocation.Query, diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index 34cdd3a0a..32d3db3b4 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -70,14 +70,15 @@ public void ReturnFilteredOpenApiDocumentBasedOnPostmanCollection() [Fact] public void TestPredicateFiltersUsingRelativeRequestUrls() { - var openApiDocument = new OpenApiDocument() + var openApiDocument = new OpenApiDocument { Info = new() { Title = "Test", Version = "1.0" }, - Servers = new List() { new() { Url = "https://localhost/" } }, + Servers = new List { new() { Url = "https://localhost/" } }, Paths = new() { {"/foo", new() { - Operations = new Dictionary() { + Operations = new Dictionary + { { OperationType.Get, new() }, { OperationType.Patch, new() }, { OperationType.Post, new() } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 9d73c8db6..fb2349e52 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -136,7 +136,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram() { // create a dummy ILogger instance for testing - var options = new HidiOptions() + var options = new HidiOptions { OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"), Output = new FileInfo("sample.md") @@ -151,7 +151,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram() [Fact] public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagram() { - var options = new HidiOptions() + var options = new HidiOptions { OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml") }; @@ -162,7 +162,7 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagram() [Fact] public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiagram() { - var options = new HidiOptions() + var options = new HidiOptions { Csdl = Path.Combine("UtilityFiles", "Todo.xml"), CsdlFilter = "todos", diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs index 58b85d91d..3fc77fc01 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs @@ -22,9 +22,9 @@ public static OpenApiDocument CreateOpenApiDocument() { var applicationJsonMediaType = "application/json"; - var document = new OpenApiDocument() + var document = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = "People", Version = "v1.0" @@ -36,7 +36,7 @@ public static OpenApiDocument CreateOpenApiDocument() Url = "https://graph.microsoft.com/v1.0" } }, - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem() // root path { @@ -46,10 +46,10 @@ public static OpenApiDocument CreateOpenApiDocument() OperationType.Get, new OpenApiOperation { OperationId = "graphService.GetGraphService", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200",new OpenApiResponse() + "200",new OpenApiResponse { Description = "OK" } @@ -59,7 +59,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/reports/microsoft.graph.getTeamsUserActivityCounts(period={period})"] = new OpenApiPathItem() + ["/reports/microsoft.graph.getTeamsUserActivityCounts(period={period})"] = new OpenApiPathItem { Operations = new Dictionary { @@ -69,7 +69,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "reports.Functions" } @@ -80,22 +80,22 @@ public static OpenApiDocument CreateOpenApiDocument() Parameters = new List { { - new OpenApiParameter() + new OpenApiParameter { Name = "period", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Success", Content = new Dictionary @@ -120,12 +120,12 @@ public static OpenApiDocument CreateOpenApiDocument() Parameters = new List { { - new OpenApiParameter() + new OpenApiParameter { Name = "period", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } @@ -133,7 +133,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/reports/microsoft.graph.getTeamsUserActivityUserDetail(date={date})"] = new OpenApiPathItem() + ["/reports/microsoft.graph.getTeamsUserActivityUserDetail(date={date})"] = new OpenApiPathItem { Operations = new Dictionary { @@ -143,7 +143,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "reports.Functions" } @@ -154,22 +154,22 @@ public static OpenApiDocument CreateOpenApiDocument() Parameters = new List { { - new OpenApiParameter() + new OpenApiParameter { Name = "period", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Success", Content = new Dictionary @@ -198,14 +198,14 @@ public static OpenApiDocument CreateOpenApiDocument() Name = "period", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } } } }, - ["/users"] = new OpenApiPathItem() + ["/users"] = new OpenApiPathItem { Operations = new Dictionary { @@ -215,7 +215,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "users.user" } @@ -223,10 +223,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, OperationId = "users.user.ListUser", Summary = "Get entities from users", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entities", Content = new Dictionary @@ -268,7 +268,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/users/{user-id}"] = new OpenApiPathItem() + ["/users/{user-id}"] = new OpenApiPathItem { Operations = new Dictionary { @@ -278,7 +278,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "users.user" } @@ -286,10 +286,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, OperationId = "users.user.GetUser", Summary = "Get entity from users by key", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entity", Content = new Dictionary @@ -320,7 +320,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "users.user" } @@ -328,10 +328,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, OperationId = "users.user.UpdateUser", Summary = "Update entity in users", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "204", new OpenApiResponse() + "204", new OpenApiResponse { Description = "Success" } @@ -341,7 +341,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/users/{user-id}/messages/{message-id}"] = new OpenApiPathItem() + ["/users/{user-id}/messages/{message-id}"] = new OpenApiPathItem { Operations = new Dictionary { @@ -351,7 +351,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "users.message" } @@ -362,23 +362,23 @@ public static OpenApiDocument CreateOpenApiDocument() Description = "The messages in a mailbox or folder. Read-only. Nullable.", Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "$select", In = ParameterLocation.Query, Required = true, Description = "Select properties to be returned", - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "array" } // missing explode parameter } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved navigation property", Content = new Dictionary @@ -405,7 +405,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/administrativeUnits/{administrativeUnit-id}/microsoft.graph.restore"] = new OpenApiPathItem() + ["/administrativeUnits/{administrativeUnit-id}/microsoft.graph.restore"] = new OpenApiPathItem { Operations = new Dictionary { @@ -415,7 +415,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "administrativeUnits.Actions" } @@ -426,23 +426,23 @@ public static OpenApiDocument CreateOpenApiDocument() Parameters = new List { { - new OpenApiParameter() + new OpenApiParameter { Name = "administrativeUnit-id", In = ParameterLocation.Path, Required = true, Description = "key: id of administrativeUnit", - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Success", Content = new Dictionary @@ -472,7 +472,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/applications/{application-id}/logo"] = new OpenApiPathItem() + ["/applications/{application-id}/logo"] = new OpenApiPathItem { Operations = new Dictionary { @@ -482,7 +482,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "applications.application" } @@ -490,10 +490,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, OperationId = "applications.application.UpdateLogo", Summary = "Update media content for application in applications", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "204", new OpenApiResponse() + "204", new OpenApiResponse { Description = "Success" } @@ -503,7 +503,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/security/hostSecurityProfiles"] = new OpenApiPathItem() + ["/security/hostSecurityProfiles"] = new OpenApiPathItem { Operations = new Dictionary { @@ -513,7 +513,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "security.hostSecurityProfile" } @@ -521,10 +521,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, OperationId = "security.ListHostSecurityProfiles", Summary = "Get hostSecurityProfiles from security", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved navigation property", Content = new Dictionary @@ -566,7 +566,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/communications/calls/{call-id}/microsoft.graph.keepAlive"] = new OpenApiPathItem() + ["/communications/calls/{call-id}/microsoft.graph.keepAlive"] = new OpenApiPathItem { Operations = new Dictionary { @@ -576,7 +576,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "communications.Actions" } @@ -586,13 +586,13 @@ public static OpenApiDocument CreateOpenApiDocument() Summary = "Invoke action keepAlive", Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "call-id", In = ParameterLocation.Path, Description = "key: id of call", Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" }, @@ -604,10 +604,10 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "204", new OpenApiResponse() + "204", new OpenApiResponse { Description = "Success" } @@ -623,7 +623,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/groups/{group-id}/events/{event-id}/calendar/events/microsoft.graph.delta"] = new OpenApiPathItem() + ["/groups/{group-id}/events/{event-id}/calendar/events/microsoft.graph.delta"] = new OpenApiPathItem { Operations = new Dictionary { @@ -632,7 +632,7 @@ public static OpenApiDocument CreateOpenApiDocument() { Tags = new List { - new OpenApiTag() + new OpenApiTag { Name = "groups.Functions" } @@ -641,13 +641,13 @@ public static OpenApiDocument CreateOpenApiDocument() Summary = "Invoke function delta", Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "group-id", In = ParameterLocation.Path, Description = "key: id of group", Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" }, @@ -658,13 +658,13 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - new OpenApiParameter() + new OpenApiParameter { Name = "event-id", In = ParameterLocation.Path, Description = "key: id of event", Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" }, @@ -676,10 +676,10 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Success", Content = new Dictionary @@ -713,7 +713,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/applications/{application-id}/createdOnBehalfOf/$ref"] = new OpenApiPathItem() + ["/applications/{application-id}/createdOnBehalfOf/$ref"] = new OpenApiPathItem { Operations = new Dictionary { @@ -722,7 +722,7 @@ public static OpenApiDocument CreateOpenApiDocument() { Tags = new List { - new OpenApiTag() + new OpenApiTag { Name = "applications.directoryObject" } diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs index 23c23b4d6..5b01e0444 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs @@ -45,7 +45,7 @@ public void DetectedSpecificationVersionShouldBeV3_0() public async Task DiagnosticReportMergedForExternalReference() { // Create a reader that will resolve all references - var reader = new OpenApiStreamReader(new OpenApiReaderSettings() + var reader = new OpenApiStreamReader(new OpenApiReaderSettings { LoadExternalRefs = true, CustomExternalLoader = new ResourceLoader(), diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs index 4a2c2cafe..869d43fab 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs @@ -18,7 +18,7 @@ public class OpenApiWorkspaceStreamTests public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoWorkspace() { // Create a reader that will resolve all references - var reader = new OpenApiStreamReader(new OpenApiReaderSettings() + var reader = new OpenApiStreamReader(new OpenApiReaderSettings { LoadExternalRefs = true, CustomExternalLoader = new MockLoader(), @@ -48,7 +48,7 @@ public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoW public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWorkspace() { // Create a reader that will resolve all references - var reader = new OpenApiStreamReader(new OpenApiReaderSettings() + var reader = new OpenApiStreamReader(new OpenApiReaderSettings { LoadExternalRefs = true, CustomExternalLoader = new ResourceLoader(), diff --git a/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs index 677232ac4..2ece19537 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs @@ -25,7 +25,8 @@ public void BrokenSimpleList() var reader = new OpenApiStringReader(); reader.Read(input, out var diagnostic); - diagnostic.Errors.Should().BeEquivalentTo(new List() { + diagnostic.Errors.Should().BeEquivalentTo(new List + { new OpenApiError(new OpenApiReaderException("Expected a value.") { Pointer = "#line=4" }) @@ -53,7 +54,8 @@ public void BadSchema() var reader = new OpenApiStringReader(); reader.Read(input, out var diagnostic); - diagnostic.Errors.Should().BeEquivalentTo(new List() { + diagnostic.Errors.Should().BeEquivalentTo(new List + { new OpenApiError(new OpenApiReaderException("schema must be a map/object") { Pointer = "#/paths/~1foo/get/responses/200/content/application~1json/schema" }) diff --git a/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs index 7ee8c3439..3875b77b0 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs @@ -38,31 +38,31 @@ public void ParseObjectAsAnyShouldSucceed() var anyMap = node.CreateAny(); - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Type = "object", Properties = { - ["aString"] = new OpenApiSchema() + ["aString"] = new OpenApiSchema { Type = "string" }, - ["aInteger"] = new OpenApiSchema() + ["aInteger"] = new OpenApiSchema { Type = "integer", Format = "int32" }, - ["aDouble"] = new OpenApiSchema() + ["aDouble"] = new OpenApiSchema { Type = "number", Format = "double" }, - ["aDateTime"] = new OpenApiSchema() + ["aDateTime"] = new OpenApiSchema { Type = "string", Format = "date-time" }, - ["aDate"] = new OpenApiSchema() + ["aDate"] = new OpenApiSchema { Type = "string", Format = "date" @@ -124,59 +124,59 @@ public void ParseNestedObjectAsAnyShouldSucceed() var anyMap = node.CreateAny(); - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Type = "object", Properties = { - ["aString"] = new OpenApiSchema() + ["aString"] = new OpenApiSchema { Type = "string" }, - ["aInteger"] = new OpenApiSchema() + ["aInteger"] = new OpenApiSchema { Type = "integer", Format = "int32" }, - ["aArray"] = new OpenApiSchema() + ["aArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "integer", Format = "int64" } }, - ["aNestedArray"] = new OpenApiSchema() + ["aNestedArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "object", Properties = { - ["aFloat"] = new OpenApiSchema() + ["aFloat"] = new OpenApiSchema { Type = "number", Format = "float" }, - ["aPassword"] = new OpenApiSchema() + ["aPassword"] = new OpenApiSchema { Type = "string", Format = "password" }, - ["aArray"] = new OpenApiSchema() + ["aArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "string", } }, - ["aDictionary"] = new OpenApiSchema() + ["aDictionary"] = new OpenApiSchema { Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "integer", Format = "int64" @@ -185,24 +185,24 @@ public void ParseNestedObjectAsAnyShouldSucceed() } } }, - ["aObject"] = new OpenApiSchema() + ["aObject"] = new OpenApiSchema { Type = "array", Properties = { - ["aDate"] = new OpenApiSchema() + ["aDate"] = new OpenApiSchema { Type = "string", Format = "date" } } }, - ["aDouble"] = new OpenApiSchema() + ["aDouble"] = new OpenApiSchema { Type = "number", Format = "double" }, - ["aDateTime"] = new OpenApiSchema() + ["aDateTime"] = new OpenApiSchema { Type = "string", Format = "date-time" @@ -219,44 +219,44 @@ public void ParseNestedObjectAsAnyShouldSucceed() { ["aString"] = new OpenApiString("fooBar"), ["aInteger"] = new OpenApiInteger(10), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiLong(1), new OpenApiLong(2), new OpenApiLong(3), }, - ["aNestedArray"] = new OpenApiArray() + ["aNestedArray"] = new OpenApiArray { - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiFloat(1), ["aPassword"] = new OpenApiPassword("1234"), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiString("abc"), new OpenApiString("def") }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiLong(1), ["arbitraryProperty2"] = new OpenApiLong(2), } }, - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiFloat((float)1.6), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiString("123"), }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiLong(1), ["arbitraryProperty3"] = new OpenApiLong(20), } } }, - ["aObject"] = new OpenApiObject() + ["aObject"] = new OpenApiObject { ["aDate"] = new OpenApiDate(DateTimeOffset.Parse("2017-02-03", CultureInfo.InvariantCulture).Date) }, @@ -304,41 +304,41 @@ public void ParseNestedObjectAsAnyWithPartialSchemaShouldSucceed() var anyMap = node.CreateAny(); - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Type = "object", Properties = { - ["aString"] = new OpenApiSchema() + ["aString"] = new OpenApiSchema { Type = "string" }, - ["aArray"] = new OpenApiSchema() + ["aArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "integer" } }, - ["aNestedArray"] = new OpenApiSchema() + ["aNestedArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "object", Properties = { - ["aFloat"] = new OpenApiSchema() + ["aFloat"] = new OpenApiSchema { }, - ["aPassword"] = new OpenApiSchema() + ["aPassword"] = new OpenApiSchema { }, - ["aArray"] = new OpenApiSchema() + ["aArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "string", } @@ -346,21 +346,21 @@ public void ParseNestedObjectAsAnyWithPartialSchemaShouldSucceed() } } }, - ["aObject"] = new OpenApiSchema() + ["aObject"] = new OpenApiSchema { Type = "array", Properties = { - ["aDate"] = new OpenApiSchema() + ["aDate"] = new OpenApiSchema { Type = "string" } } }, - ["aDouble"] = new OpenApiSchema() + ["aDouble"] = new OpenApiSchema { }, - ["aDateTime"] = new OpenApiSchema() + ["aDateTime"] = new OpenApiSchema { } } @@ -375,44 +375,44 @@ public void ParseNestedObjectAsAnyWithPartialSchemaShouldSucceed() { ["aString"] = new OpenApiString("fooBar"), ["aInteger"] = new OpenApiInteger(10), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiInteger(1), new OpenApiInteger(2), new OpenApiInteger(3), }, - ["aNestedArray"] = new OpenApiArray() + ["aNestedArray"] = new OpenApiArray { - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiInteger(1), ["aPassword"] = new OpenApiInteger(1234), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiString("abc"), new OpenApiString("def") }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiInteger(1), ["arbitraryProperty2"] = new OpenApiInteger(2), } }, - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiDouble(1.6), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiString("123"), }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiInteger(1), ["arbitraryProperty3"] = new OpenApiInteger(20), } } }, - ["aObject"] = new OpenApiObject() + ["aObject"] = new OpenApiObject { ["aDate"] = new OpenApiString("2017-02-03") }, @@ -468,44 +468,44 @@ public void ParseNestedObjectAsAnyWithoutUsingSchemaShouldSucceed() { ["aString"] = new OpenApiString("fooBar"), ["aInteger"] = new OpenApiInteger(10), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiInteger(1), new OpenApiInteger(2), new OpenApiInteger(3), }, - ["aNestedArray"] = new OpenApiArray() + ["aNestedArray"] = new OpenApiArray { - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiInteger(1), ["aPassword"] = new OpenApiInteger(1234), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiString("abc"), new OpenApiString("def") }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiInteger(1), ["arbitraryProperty2"] = new OpenApiInteger(2), } }, - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiDouble(1.6), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiInteger(123), }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiInteger(1), ["arbitraryProperty3"] = new OpenApiInteger(20), } } }, - ["aObject"] = new OpenApiObject() + ["aObject"] = new OpenApiObject { ["aDate"] = new OpenApiDateTime(DateTimeOffset.Parse("2017-02-03", CultureInfo.InvariantCulture)) }, diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs index a641b7d6f..9469de370 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs @@ -228,11 +228,11 @@ public void LoadResponseAndSchemaReference() Description = "Sample description", Required = new HashSet {"name" }, Properties = { - ["name"] = new OpenApiSchema() + ["name"] = new OpenApiSchema { Type = "string" }, - ["tag"] = new OpenApiSchema() + ["tag"] = new OpenApiSchema { Type = "string" } diff --git a/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs b/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs index 88866fd95..89468229a 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs @@ -24,11 +24,12 @@ public void ParseCustomExtension() baz: hi! paths: {} "; - var settings = new OpenApiReaderSettings() + var settings = new OpenApiReaderSettings { ExtensionParsers = { { "x-foo", (a,v) => { var fooNode = (OpenApiObject)a; - return new FooExtension() { + return new FooExtension + { Bar = (fooNode["bar"] as OpenApiString)?.Value, Baz = (fooNode["baz"] as OpenApiString)?.Value }; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index ac5f99a86..4acdb583f 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -122,16 +122,16 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) ["x-extension"] = new OpenApiDouble(2.335) } }, - Components = new OpenApiComponents() + Components = new OpenApiComponents { Schemas = { - ["sampleSchema"] = new OpenApiSchema() + ["sampleSchema"] = new OpenApiSchema { Type = "object", Properties = { - ["sampleProperty"] = new OpenApiSchema() + ["sampleProperty"] = new OpenApiSchema { Type = "double", Minimum = (decimal)100.54, @@ -140,7 +140,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) ExclusiveMinimum = false } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "sampleSchema", Type = ReferenceType.Schema @@ -152,7 +152,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) }); context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi2_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi2_0 }); } [Fact] @@ -163,7 +163,7 @@ public void ShouldParseProducesInAnyOrder() var reader = new OpenApiStreamReader(); var doc = reader.Read(stream, out var diagnostic); - var okSchema = new OpenApiSchema() + var okSchema = new OpenApiSchema { Reference = new OpenApiReference { @@ -171,9 +171,9 @@ public void ShouldParseProducesInAnyOrder() Id = "Item", HostDocument = doc }, - Properties = new Dictionary() + Properties = new Dictionary { - { "id", new OpenApiSchema() + { "id", new OpenApiSchema { Type = "string", Description = "Item identifier." @@ -182,7 +182,7 @@ public void ShouldParseProducesInAnyOrder() } }; - var errorSchema = new OpenApiSchema() + var errorSchema = new OpenApiSchema { Reference = new OpenApiReference { @@ -190,20 +190,20 @@ public void ShouldParseProducesInAnyOrder() Id = "Error", HostDocument = doc }, - Properties = new Dictionary() + Properties = new Dictionary { - { "code", new OpenApiSchema() + { "code", new OpenApiSchema { Type = "integer", Format = "int32" } }, - { "message", new OpenApiSchema() + { "message", new OpenApiSchema { Type = "string" } }, - { "fields", new OpenApiSchema() + { "fields", new OpenApiSchema { Type = "string" } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs index 7a98c7a6d..eb3bb066c 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs @@ -34,7 +34,7 @@ public void ParseHeaderWithDefaultShouldSucceed() header.Should().BeEquivalentTo( new OpenApiHeader { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "number", Format = "float", @@ -60,7 +60,7 @@ public void ParseHeaderWithEnumShouldSucceed() header.Should().BeEquivalentTo( new OpenApiHeader { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "number", Format = "float", diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index 3b0f32871..76da8a763 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -330,39 +330,39 @@ public void ParseOperationWithResponseExamplesShouldSucceed() // Assert operation.Should().BeEquivalentTo( - new OpenApiOperation() + new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - { "200", new OpenApiResponse() + { "200", new OpenApiResponse { Description = "An array of float response", Content = { - ["application/json"] = new OpenApiMediaType() + ["application/json"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "number", Format = "float" } }, - Example = new OpenApiArray() + Example = new OpenApiArray { new OpenApiFloat(5), new OpenApiFloat(6), new OpenApiFloat(7), } }, - ["application/xml"] = new OpenApiMediaType() + ["application/xml"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "number", Format = "float" @@ -389,18 +389,18 @@ public void ParseOperationWithEmptyProducesArraySetsResponseSchemaIfExists() // Assert operation.Should().BeEquivalentTo( - new OpenApiOperation() + new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - { "200", new OpenApiResponse() + { "200", new OpenApiResponse { Description = "OK", Content = { - ["application/octet-stream"] = new OpenApiMediaType() + ["application/octet-stream"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Format = "binary", Description = "The content of the file.", diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs index fc4e84f50..3f46f5a2b 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs @@ -155,15 +155,16 @@ public void ParseHeaderParameterShouldSucceed() new OpenApiLong(4), } }, - Default = new OpenApiArray() { + Default = new OpenApiArray + { new OpenApiLong(1), new OpenApiLong(2) }, Enum = new List { - new OpenApiArray() { new OpenApiLong(1), new OpenApiLong(2) }, - new OpenApiArray() { new OpenApiLong(2), new OpenApiLong(3) }, - new OpenApiArray() { new OpenApiLong(3), new OpenApiLong(4) } + new OpenApiArray { new OpenApiLong(1), new OpenApiLong(2) }, + new OpenApiArray { new OpenApiLong(2), new OpenApiLong(3) }, + new OpenApiArray { new OpenApiLong(3), new OpenApiLong(4) } } } }); @@ -207,15 +208,16 @@ public void ParseHeaderParameterWithIncorrectDataTypeShouldSucceed() new OpenApiString("4"), } }, - Default = new OpenApiArray() { + Default = new OpenApiArray + { new OpenApiString("1"), new OpenApiString("2") }, Enum = new List { - new OpenApiArray() { new OpenApiString("1"), new OpenApiString("2") }, - new OpenApiArray() { new OpenApiString("2"), new OpenApiString("3") }, - new OpenApiArray() { new OpenApiString("3"), new OpenApiString("4") } + new OpenApiArray { new OpenApiString("1"), new OpenApiString("2") }, + new OpenApiArray { new OpenApiString("2"), new OpenApiString("3") }, + new OpenApiArray { new OpenApiString("3"), new OpenApiString("4") } } } }); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs index a11497cdf..c32c15ff4 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs @@ -19,20 +19,20 @@ public class OpenApiPathItemTests { private const string SampleFolderPath = "V2Tests/Samples/OpenApiPathItem/"; - private static readonly OpenApiPathItem _basicPathItemWithFormData = new OpenApiPathItem() + private static readonly OpenApiPathItem _basicPathItemWithFormData = new OpenApiPathItem { Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "id", In = ParameterLocation.Path, Description = "ID of pet to use", Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "string" } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs index bf0fe7b78..5037007a2 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs @@ -18,7 +18,7 @@ public void NoServer() version: 1.0.0 paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { }); @@ -39,7 +39,7 @@ public void JustSchemeNoDefault() - http paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { }); @@ -59,7 +59,7 @@ public void JustHostNoDefault() host: www.foo.com paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { }); @@ -83,7 +83,7 @@ public void NoBasePath() - http paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://www.foo.com/spec.yaml") }); @@ -106,7 +106,7 @@ public void JustBasePathNoDefault() basePath: /baz paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { }); @@ -129,7 +129,7 @@ public void JustSchemeWithCustomHost() - http paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com/foo") }); @@ -153,7 +153,7 @@ public void JustSchemeWithCustomHostWithEmptyPath() - http paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com") }); @@ -176,7 +176,7 @@ public void JustBasePathWithCustomHost() basePath: /api paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com") }); @@ -199,7 +199,7 @@ public void JustHostWithCustomHost() host: www.example.com paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com") }); @@ -222,7 +222,7 @@ public void JustHostWithCustomHostWithApi() host: prod.bing.com paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://dev.bing.com/api/description.yaml") }); @@ -247,7 +247,7 @@ public void MultipleServers() - https paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://dev.bing.com/api") }); @@ -271,7 +271,7 @@ public void LocalHostWithCustomHost() host: localhost:23232 paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com") }); @@ -294,7 +294,7 @@ public void InvalidHostShouldYieldError() host: http://test.microsoft.com paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com") }); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs index 320f01fae..1a45006db 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs @@ -89,7 +89,7 @@ public void ParseCallbackWithReferenceShouldSucceed() var callback = subscribeOperation.Callbacks["simpleHook"]; diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); callback.Should().BeEquivalentTo( new OpenApiCallback @@ -98,7 +98,7 @@ public void ParseCallbackWithReferenceShouldSucceed() { [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [OperationType.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -106,7 +106,7 @@ public void ParseCallbackWithReferenceShouldSucceed() { ["application/json"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object" } @@ -146,7 +146,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() var subscribeOperation = path.Operations[OperationType.Post]; diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); var callback1 = subscribeOperation.Callbacks["simpleHook"]; @@ -157,7 +157,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [OperationType.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -165,7 +165,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { ["application/json"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object" } @@ -198,7 +198,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { [RuntimeExpression.Build("/simplePath")]= new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [OperationType.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -207,7 +207,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { ["application/json"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } @@ -234,7 +234,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { [RuntimeExpression.Build(@"http://example.com?transactionId={$request.body#/id}&email={$request.body#/email}")] = new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [OperationType.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -242,7 +242,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { ["application/xml"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object" } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 8a0da3481..85a686e49 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -36,7 +36,7 @@ public T Clone(T element) where T : IOpenApiSerializable { IOpenApiWriter writer; var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); - writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings() + writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings { InlineLocalReferences = true }); @@ -58,7 +58,7 @@ public OpenApiSecurityScheme CloneSecurityScheme(OpenApiSecurityScheme element) { IOpenApiWriter writer; var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); - writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings() + writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings { InlineLocalReferences = true }); @@ -104,7 +104,7 @@ public void ParseDocumentFromInlineStringShouldSucceed() }); context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Theory] @@ -146,16 +146,16 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) Title = "Simple Document", Version = "0.9.1" }, - Components = new OpenApiComponents() + Components = new OpenApiComponents { Schemas = { - ["sampleSchema"] = new OpenApiSchema() + ["sampleSchema"] = new OpenApiSchema { Type = "object", Properties = { - ["sampleProperty"] = new OpenApiSchema() + ["sampleProperty"] = new OpenApiSchema { Type = "double", Minimum = (decimal)100.54, @@ -164,7 +164,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) ExclusiveMinimum = false } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "sampleSchema", Type = ReferenceType.Schema @@ -176,7 +176,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) }); context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Fact] @@ -187,7 +187,7 @@ public void ParseBasicDocumentWithMultipleServersShouldSucceed() var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); openApiDoc.Should().BeEquivalentTo( new OpenApiDocument @@ -263,7 +263,7 @@ public void ParseMinimalDocumentShouldSucceed() }); diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } } @@ -694,7 +694,7 @@ public void ParseStandardPetStoreDocumentShouldSucceed() } context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Fact] @@ -1201,7 +1201,7 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() { Name = "tagName1", Description = "tagDescription1", - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "tagName1", Type = ReferenceType.Tag @@ -1227,7 +1227,7 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() } context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Fact] @@ -1243,7 +1243,7 @@ public void ParsePetStoreExpandedShouldSucceed() } context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Fact] @@ -1269,7 +1269,7 @@ public void HeaderParameterShouldAllowExample() var exampleHeader = openApiDoc.Components?.Headers?["example-header"]; Assert.NotNull(exampleHeader); exampleHeader.Should().BeEquivalentTo( - new OpenApiHeader() + new OpenApiHeader { Description = "Test header with example", Required = true, @@ -1279,12 +1279,12 @@ public void HeaderParameterShouldAllowExample() Style = ParameterStyle.Simple, Explode = true, Example = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721"), - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", Format = "uuid" }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Header, Id = "example-header" @@ -1294,7 +1294,7 @@ public void HeaderParameterShouldAllowExample() var examplesHeader = openApiDoc.Components?.Headers?["examples-header"]; Assert.NotNull(examplesHeader); examplesHeader.Should().BeEquivalentTo( - new OpenApiHeader() + new OpenApiHeader { Description = "Test header with example", Required = true, @@ -1303,25 +1303,25 @@ public void HeaderParameterShouldAllowExample() AllowReserved = true, Style = ParameterStyle.Simple, Explode = true, - Examples = new Dictionary() + Examples = new Dictionary { - { "uuid1", new OpenApiExample() + { "uuid1", new OpenApiExample { Value = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721") } }, - { "uuid2", new OpenApiExample() + { "uuid2", new OpenApiExample { Value = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721") } } }, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", Format = "uuid" }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Header, Id = "examples-header" diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs index e62eabb53..47983a9a1 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs @@ -61,11 +61,11 @@ public void ParseMediaTypeWithExamplesShouldSucceed() { Examples = { - ["example1"] = new OpenApiExample() + ["example1"] = new OpenApiExample { Value = new OpenApiFloat(5), }, - ["example2"] = new OpenApiExample() + ["example2"] = new OpenApiExample { Value = new OpenApiFloat((float)7.5), } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs index a74c64154..37053c2a4 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs @@ -42,14 +42,14 @@ public void ParseOperationWithParameterWithNoLocationShouldSucceed() var operation = OpenApiV3Deserializer.LoadOperation(node); // Assert - operation.Should().BeEquivalentTo(new OpenApiOperation() + operation.Should().BeEquivalentTo(new OpenApiOperation { Tags = { new OpenApiTag { UnresolvedReference = true, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "user", Type = ReferenceType.Tag diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs index 44ba3316d..3234195e5 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs @@ -329,11 +329,11 @@ public void ParseParameterWithExamplesShouldSucceed() Required = true, Examples = { - ["example1"] = new OpenApiExample() + ["example1"] = new OpenApiExample { Value = new OpenApiFloat(5), }, - ["example2"] = new OpenApiExample() + ["example2"] = new OpenApiExample { Value = new OpenApiFloat((float)7.5), } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index 0101d9c6e..54553d5a5 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -119,7 +119,8 @@ public void ParseExampleStringFragmentShouldSucceed() new OpenApiObject { ["foo"] = new OpenApiString("bar"), - ["baz"] = new OpenApiArray() { + ["baz"] = new OpenApiArray + { new OpenApiInteger(1), new OpenApiInteger(2) } @@ -226,7 +227,7 @@ public void ParsePathFragmentShouldSucceed() Summary = "externally referenced path item", Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [OperationType.Get] = new OpenApiOperation { Responses = new OpenApiResponses { @@ -333,7 +334,7 @@ public void ParseBasicSchemaWithReferenceShouldSucceed() var components = openApiDoc.Components; diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); components.Should().BeEquivalentTo( new OpenApiComponents @@ -439,7 +440,7 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() var components = openApiDoc.Components; diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); components.Should().BeEquivalentTo( new OpenApiComponents @@ -469,7 +470,7 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() "name", "petType" }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id= "Pet", Type = ReferenceType.Schema, @@ -534,7 +535,7 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() } } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id= "Cat", Type = ReferenceType.Schema, @@ -595,7 +596,7 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() } } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id= "Dog", Type = ReferenceType.Schema, @@ -620,29 +621,31 @@ public void ParseSelfReferencingSchemaShouldNotStackOverflow() var components = openApiDoc.Components; diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); - var schemaExtension = new OpenApiSchema() + var schemaExtension = new OpenApiSchema { - AllOf = { new OpenApiSchema() - { + AllOf = { new OpenApiSchema + { Title = "schemaExtension", Type = "object", Properties = { - ["description"] = new OpenApiSchema() { Type = "string", Nullable = true}, - ["targetTypes"] = new OpenApiSchema() { + ["description"] = new OpenApiSchema { Type = "string", Nullable = true}, + ["targetTypes"] = new OpenApiSchema + { Type = "array", - Items = new OpenApiSchema() { + Items = new OpenApiSchema + { Type = "string" } }, - ["status"] = new OpenApiSchema() { Type = "string"}, - ["owner"] = new OpenApiSchema() { Type = "string"}, + ["status"] = new OpenApiSchema { Type = "string"}, + ["owner"] = new OpenApiSchema { Type = "string"}, ["child"] = null } } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "microsoft.graph.schemaExtension" diff --git a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs index 6d2eafc01..efba7b9b0 100644 --- a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs +++ b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs @@ -28,7 +28,7 @@ public ApisGuruTests(ITestOutputHelper output) static ApisGuruTests() { System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - _httpClient = new HttpClient(new HttpClientHandler() + _httpClient = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip }); diff --git a/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs b/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs index de3101e27..b7881a905 100644 --- a/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs +++ b/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs @@ -24,7 +24,7 @@ public GraphTests(ITestOutputHelper output) { _output = output; System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - _httpClient = new HttpClient(new HttpClientHandler() + _httpClient = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip }); _httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); diff --git a/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs b/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs index 5c91249d3..a5b116faa 100644 --- a/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs +++ b/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs @@ -188,7 +188,7 @@ public void CompositeRuntimeExpressionContainsMultipleExpressions() var compositeExpression = runtimeExpression as CompositeExpression; Assert.Equal(2, compositeExpression.ContainedExpressions.Count); - compositeExpression.ContainedExpressions.Should().BeEquivalentTo(new List() + compositeExpression.ContainedExpressions.Should().BeEquivalentTo(new List { new UrlExpression(), new RequestExpression(new HeaderExpression("foo")) @@ -232,7 +232,7 @@ public void CompositeRuntimeExpressionWithMultipleRuntimeExpressionsAndFakeBrace response.Expression.Should().Be(expression); var compositeExpression = runtimeExpression as CompositeExpression; - compositeExpression.ContainedExpressions.Should().BeEquivalentTo(new List() + compositeExpression.ContainedExpressions.Should().BeEquivalentTo(new List { new UrlExpression(), new RequestExpression(new HeaderExpression("foo")) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs index 7ba6d132c..46a6bb772 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs @@ -170,13 +170,13 @@ public class OpenApiComponentsTests } }; - public static OpenApiComponents TopLevelReferencingComponents = new OpenApiComponents() + public static OpenApiComponents TopLevelReferencingComponents = new OpenApiComponents { Schemas = { ["schema1"] = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema2" @@ -187,7 +187,7 @@ public class OpenApiComponentsTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } @@ -196,7 +196,7 @@ public class OpenApiComponentsTests } }; - public static OpenApiComponents TopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiComponents() + public static OpenApiComponents TopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiComponents { Schemas = { @@ -205,12 +205,12 @@ public class OpenApiComponentsTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema1" @@ -221,7 +221,7 @@ public class OpenApiComponentsTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } @@ -230,13 +230,13 @@ public class OpenApiComponentsTests } }; - public static OpenApiComponents TopLevelSelfReferencingComponents = new OpenApiComponents() + public static OpenApiComponents TopLevelSelfReferencingComponents = new OpenApiComponents { Schemas = { ["schema1"] = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema1" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 924699bdf..becc91d97 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -24,13 +24,13 @@ namespace Microsoft.OpenApi.Tests.Models [UsesVerify] public class OpenApiDocumentTests { - public static OpenApiComponents TopLevelReferencingComponents = new OpenApiComponents() + public static OpenApiComponents TopLevelReferencingComponents = new OpenApiComponents { Schemas = { ["schema1"] = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema2" @@ -41,7 +41,7 @@ public class OpenApiDocumentTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } @@ -50,7 +50,7 @@ public class OpenApiDocumentTests } }; - public static OpenApiComponents TopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiComponents() + public static OpenApiComponents TopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiComponents { Schemas = { @@ -59,12 +59,12 @@ public class OpenApiDocumentTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema1" @@ -75,7 +75,7 @@ public class OpenApiDocumentTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } @@ -84,13 +84,13 @@ public class OpenApiDocumentTests } }; - public static OpenApiComponents TopLevelSelfReferencingComponents = new OpenApiComponents() + public static OpenApiComponents TopLevelSelfReferencingComponents = new OpenApiComponents { Schemas = { ["schema1"] = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema1" @@ -99,27 +99,27 @@ public class OpenApiDocumentTests } }; - public static OpenApiDocument SimpleDocumentWithTopLevelReferencingComponents = new OpenApiDocument() + public static OpenApiDocument SimpleDocumentWithTopLevelReferencingComponents = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Version = "1.0.0" }, Components = TopLevelReferencingComponents }; - public static OpenApiDocument SimpleDocumentWithTopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiDocument() + public static OpenApiDocument SimpleDocumentWithTopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Version = "1.0.0" }, Components = TopLevelSelfReferencingComponentsWithOtherProperties }; - public static OpenApiDocument SimpleDocumentWithTopLevelSelfReferencingComponents = new OpenApiDocument() + public static OpenApiDocument SimpleDocumentWithTopLevelSelfReferencingComponents = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Version = "1.0.0" }, @@ -1485,7 +1485,7 @@ public void SerializeSimpleDocumentWithTopLevelSelfReferencingWithOtherPropertie public void SerializeDocumentWithReferenceButNoComponents() { // Arrange - var document = new OpenApiDocument() + var document = new OpenApiDocument { Info = new OpenApiInfo { @@ -1504,7 +1504,7 @@ public void SerializeDocumentWithReferenceButNoComponents() { ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new Dictionary { ["application/json"] = new OpenApiMediaType { @@ -1546,11 +1546,12 @@ public void SerializeRelativePathAsV2JsonWorks() version: 1.0.0 basePath: /server1 paths: { }"; - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Info = new OpenApiInfo() { Version = "1.0.0" }, - Servers = new List() { - new OpenApiServer() + Info = new OpenApiInfo { Version = "1.0.0" }, + Servers = new List + { + new OpenApiServer { Url = "/server1" } @@ -1577,11 +1578,12 @@ public void SerializeRelativePathWithHostAsV2JsonWorks() host: //example.org basePath: /server1 paths: { }"; - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Info = new OpenApiInfo() { Version = "1.0.0" }, - Servers = new List() { - new OpenApiServer() + Info = new OpenApiInfo { Version = "1.0.0" }, + Servers = new List + { + new OpenApiServer { Url = "//example.org/server1" } @@ -1607,11 +1609,12 @@ public void SerializeRelativeRootPathWithHostAsV2JsonWorks() version: 1.0.0 host: //example.org paths: { }"; - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Info = new OpenApiInfo() { Version = "1.0.0" }, - Servers = new List() { - new OpenApiServer() + Info = new OpenApiInfo { Version = "1.0.0" }, + Servers = new List + { + new OpenApiServer { Url = "//example.org/" } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index de56df52e..11d8dc517 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -212,70 +212,70 @@ [new OpenApiSecurityScheme }; private static readonly OpenApiOperation _operationWithFormData = - new OpenApiOperation() + new OpenApiOperation { Summary = "Updates a pet in the store with form data", Description = "", OperationId = "updatePetWithForm", - Parameters = new List() + Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "petId", In = ParameterLocation.Path, Description = "ID of pet that needs to be updated", Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } } }, - RequestBody = new OpenApiRequestBody() + RequestBody = new OpenApiRequestBody { Content = { - ["application/x-www-form-urlencoded"] = new OpenApiMediaType() + ["application/x-www-form-urlencoded"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Properties = { - ["name"] = new OpenApiSchema() + ["name"] = new OpenApiSchema { Description = "Updated name of the pet", Type = "string" }, - ["status"] = new OpenApiSchema() + ["status"] = new OpenApiSchema { Description = "Updated status of the pet", Type = "string" } }, - Required = new HashSet() + Required = new HashSet { "name" } } }, - ["multipart/form-data"] = new OpenApiMediaType() + ["multipart/form-data"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Properties = { - ["name"] = new OpenApiSchema() + ["name"] = new OpenApiSchema { Description = "Updated name of the pet", Type = "string" }, - ["status"] = new OpenApiSchema() + ["status"] = new OpenApiSchema { Description = "Updated status of the pet", Type = "string" } }, - Required = new HashSet() + Required = new HashSet { "name" } @@ -283,13 +283,13 @@ [new OpenApiSecurityScheme } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { Description = "Pet updated." }, - ["405"] = new OpenApiResponse() + ["405"] = new OpenApiResponse { Description = "Invalid input" } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 9d84ab63d..d59c026e3 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -168,12 +168,12 @@ public class OpenApiSchemaTests public static OpenApiSchema AdvancedSchemaWithRequiredPropertiesObject = new OpenApiSchema { Title = "title1", - Required = new HashSet() { "property1" }, + Required = new HashSet { "property1" }, Properties = new Dictionary { ["property1"] = new OpenApiSchema { - Required = new HashSet() { "property3" }, + Required = new HashSet { "property3" }, Properties = new Dictionary { ["property2"] = new OpenApiSchema @@ -425,7 +425,7 @@ public async Task SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync(bool prod public void SerializeAsV2ShouldSetFormatPropertyInParentSchemaIfPresentInChildrenSchema() { // Arrange - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { OneOf = new List { @@ -465,7 +465,7 @@ public void SerializeAsV2ShouldSetFormatPropertyInParentSchemaIfPresentInChildre [Fact] public void OpenApiSchemaCopyConstructorSucceeds() { - var baseSchema = new OpenApiSchema() + var baseSchema = new OpenApiSchema { Type = "string", Format = "date" diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApiTests.cs b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApiTests.cs index 418a526d0..8bb4901a0 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApiTests.cs +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApiTests.cs @@ -26,7 +26,7 @@ public void ReviewPublicApiChanges() // It takes a human to read the change, determine if it is breaking and update the PublicApi.approved.txt with the new approved API surface // Arrange - var publicApi = typeof(OpenApiSpecVersion).Assembly.GeneratePublicApi(new ApiGeneratorOptions() { AllowNamespacePrefixes = new[] { "Microsoft.OpenApi" } } ); + var publicApi = typeof(OpenApiSpecVersion).Assembly.GeneratePublicApi(new ApiGeneratorOptions { AllowNamespacePrefixes = new[] { "Microsoft.OpenApi" } } ); // Act var approvedFilePath = Path.Combine("PublicApi", "PublicApi.approved.txt"); diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index cf9f0b0c6..0110cadf0 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -15,27 +15,28 @@ namespace Microsoft.OpenApi.Tests.Services [UsesVerify] public class OpenApiUrlTreeNodeTests { - private OpenApiDocument OpenApiDocumentSample_1 => new OpenApiDocument() + private OpenApiDocument OpenApiDocumentSample_1 => new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { - ["/"] = new OpenApiPathItem() { - Operations = new Dictionary() + ["/"] = new OpenApiPathItem + { + Operations = new Dictionary { [OperationType.Get] = new OpenApiOperation(), } }, - ["/houses"] = new OpenApiPathItem() + ["/houses"] = new OpenApiPathItem { - Operations = new Dictionary() + Operations = new Dictionary { [OperationType.Get] = new OpenApiOperation(), [OperationType.Post] = new OpenApiOperation() } }, - ["/cars"] = new OpenApiPathItem() + ["/cars"] = new OpenApiPathItem { - Operations = new Dictionary() + Operations = new Dictionary { [OperationType.Post] = new OpenApiOperation() } @@ -43,9 +44,9 @@ public class OpenApiUrlTreeNodeTests } }; - private OpenApiDocument OpenApiDocumentSample_2 => new OpenApiDocument() + private OpenApiDocument OpenApiDocumentSample_2 => new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem(), ["/hotels"] = new OpenApiPathItem(), @@ -64,9 +65,9 @@ public void CreateUrlSpaceWithoutOpenApiDocument() [Fact] public void CreateSingleRootWorks() { - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem() } @@ -84,9 +85,9 @@ public void CreateSingleRootWorks() [Fact] public void CreatePathWithoutRootWorks() { - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/houses"] = new OpenApiPathItem() } @@ -154,10 +155,10 @@ public void AttachPathWorks() OperationType.Get, new OpenApiOperation { OperationId = "motorcycles.ListMotorcycle", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entities" } @@ -179,10 +180,10 @@ public void AttachPathWorks() OperationType.Get, new OpenApiOperation { OperationId = "computers.ListComputer", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entities" } @@ -207,9 +208,9 @@ public void AttachPathWorks() [Fact] public void CreatePathsWithMultipleSegmentsWorks() { - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem(), ["/houses/apartments/{apartment-id}"] = new OpenApiPathItem(), @@ -232,13 +233,13 @@ public void CreatePathsWithMultipleSegmentsWorks() [Fact] public void HasOperationsWorks() { - var doc1 = new OpenApiDocument() + var doc1 = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem(), ["/houses"] = new OpenApiPathItem(), - ["/cars/{car-id}"] = new OpenApiPathItem() + ["/cars/{car-id}"] = new OpenApiPathItem { Operations = new Dictionary { @@ -246,10 +247,10 @@ public void HasOperationsWorks() OperationType.Get, new OpenApiOperation { OperationId = "cars.GetCar", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entity" } @@ -262,11 +263,11 @@ public void HasOperationsWorks() } }; - var doc2 = new OpenApiDocument() + var doc2 = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { - ["/cars/{car-id}"] = new OpenApiPathItem() + ["/cars/{car-id}"] = new OpenApiPathItem { Operations = new Dictionary { @@ -274,10 +275,10 @@ public void HasOperationsWorks() OperationType.Get, new OpenApiOperation { OperationId = "cars.GetCar", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entity" } @@ -289,10 +290,10 @@ public void HasOperationsWorks() OperationType.Put, new OpenApiOperation { OperationId = "cars.UpdateCar", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "204", new OpenApiResponse() + "204", new OpenApiResponse { Description = "Success." } @@ -326,9 +327,9 @@ public void HasOperationsWorks() [Fact] public void SegmentIsParameterWorks() { - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem(), ["/houses/apartments/{apartment-id}"] = new OpenApiPathItem() diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs index 45cc9c3d9..813cb9517 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs @@ -30,7 +30,7 @@ public OpenApiValidatorTests(ITestOutputHelper output) public void ResponseMustHaveADescription() { var openApiDocument = new OpenApiDocument(); - openApiDocument.Info = new OpenApiInfo() + openApiDocument.Info = new OpenApiInfo { Title = "foo", Version = "1.2.2" @@ -69,7 +69,7 @@ public void ServersShouldBeReferencedByIndex() { var openApiDocument = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = "foo", Version = "1.2.2" @@ -117,7 +117,7 @@ public void ValidateCustomExtension() var openApiDocument = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = "foo", Version = "1.2.2" @@ -125,7 +125,7 @@ public void ValidateCustomExtension() Paths = new OpenApiPaths() }; - var fooExtension = new FooExtension() + var fooExtension = new FooExtension { Bar = "hey", Baz = "baz" diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs index d10eaf590..8188d6334 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs @@ -21,7 +21,7 @@ public void ValidateKeyMustMatchRegularExpressionInComponents() // Arrange const string key = "%@abc"; - OpenApiComponents components = new OpenApiComponents() + OpenApiComponents components = new OpenApiComponents { Responses = new Dictionary { diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs index ec6bba7b5..221c245a5 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs @@ -20,7 +20,7 @@ public void ValidateEmailFieldIsEmailAddressInContact() // Arrange const string testEmail = "support/example.com"; - OpenApiContact contact = new OpenApiContact() + OpenApiContact contact = new OpenApiContact { Email = testEmail }; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs index 6a082ec0f..429c460a4 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs @@ -22,11 +22,11 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange IEnumerable errors; - var header = new OpenApiHeader() + var header = new OpenApiHeader { Required = true, Example = new OpenApiInteger(55), - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", } @@ -59,43 +59,43 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() // Arrange IEnumerable warnings; - var header = new OpenApiHeader() + var header = new OpenApiHeader { Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "integer", } }, Examples = { - ["example0"] = new OpenApiExample() + ["example0"] = new OpenApiExample { Value = new OpenApiString("1"), }, - ["example1"] = new OpenApiExample() + ["example1"] = new OpenApiExample { - Value = new OpenApiObject() - { + Value = new OpenApiObject + { ["x"] = new OpenApiInteger(2), ["y"] = new OpenApiString("20"), ["z"] = new OpenApiString("200") } }, - ["example2"] = new OpenApiExample() + ["example2"] = new OpenApiExample { Value = - new OpenApiArray() + new OpenApiArray { new OpenApiInteger(3) } }, - ["example3"] = new OpenApiExample() + ["example3"] = new OpenApiExample { - Value = new OpenApiObject() + Value = new OpenApiObject { ["x"] = new OpenApiInteger(4), ["y"] = new OpenApiInteger(40), diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs index bdffaff28..a68d91578 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs @@ -22,10 +22,10 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange IEnumerable warnings; - var mediaType = new OpenApiMediaType() + var mediaType = new OpenApiMediaType { Example = new OpenApiInteger(55), - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", } @@ -58,42 +58,42 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() // Arrange IEnumerable warnings; - var mediaType = new OpenApiMediaType() + var mediaType = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "integer", } }, Examples = { - ["example0"] = new OpenApiExample() + ["example0"] = new OpenApiExample { Value = new OpenApiString("1"), }, - ["example1"] = new OpenApiExample() + ["example1"] = new OpenApiExample { - Value = new OpenApiObject() - { + Value = new OpenApiObject + { ["x"] = new OpenApiInteger(2), ["y"] = new OpenApiString("20"), ["z"] = new OpenApiString("200") } }, - ["example2"] = new OpenApiExample() + ["example2"] = new OpenApiExample { Value = - new OpenApiArray() + new OpenApiArray { new OpenApiInteger(3) } }, - ["example3"] = new OpenApiExample() + ["example3"] = new OpenApiExample { - Value = new OpenApiObject() + Value = new OpenApiObject { ["x"] = new OpenApiInteger(4), ["y"] = new OpenApiInteger(40), diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs index 89be676c5..24f28e4eb 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs @@ -41,7 +41,7 @@ public void ValidateFieldIsRequiredInParameter() public void ValidateRequiredIsTrueWhenInIsPathInParameter() { // Arrange - var parameter = new OpenApiParameter() + var parameter = new OpenApiParameter { Name = "name", In = ParameterLocation.Path @@ -66,13 +66,13 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange IEnumerable warnings; - var parameter = new OpenApiParameter() + var parameter = new OpenApiParameter { Name = "parameter1", In = ParameterLocation.Path, Required = true, Example = new OpenApiInteger(55), - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", } @@ -105,45 +105,45 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() // Arrange IEnumerable warnings; - var parameter = new OpenApiParameter() + var parameter = new OpenApiParameter { Name = "parameter1", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "integer", } }, Examples = { - ["example0"] = new OpenApiExample() + ["example0"] = new OpenApiExample { Value = new OpenApiString("1"), }, - ["example1"] = new OpenApiExample() + ["example1"] = new OpenApiExample { - Value = new OpenApiObject() - { + Value = new OpenApiObject + { ["x"] = new OpenApiInteger(2), ["y"] = new OpenApiString("20"), ["z"] = new OpenApiString("200") } }, - ["example2"] = new OpenApiExample() + ["example2"] = new OpenApiExample { Value = - new OpenApiArray() + new OpenApiArray { new OpenApiInteger(3) } }, - ["example3"] = new OpenApiExample() + ["example3"] = new OpenApiExample { - Value = new OpenApiObject() + Value = new OpenApiObject { ["x"] = new OpenApiInteger(4), ["y"] = new OpenApiInteger(40), @@ -185,12 +185,12 @@ public void PathParameterNotInThePathShouldReturnAnError() // Arrange IEnumerable errors; - var parameter = new OpenApiParameter() + var parameter = new OpenApiParameter { Name = "parameter1", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", } @@ -223,12 +223,12 @@ public void PathParameterInThePathShouldBeOk() // Arrange IEnumerable errors; - var parameter = new OpenApiParameter() + var parameter = new OpenApiParameter { Name = "parameter1", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs index 3ed365c8d..57f9f2cae 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs @@ -24,7 +24,7 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() var sharedSchema = new OpenApiSchema { Type = "string", - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "test" }, @@ -32,29 +32,29 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() }; OpenApiDocument document = new OpenApiDocument(); - document.Components = new OpenApiComponents() + document.Components = new OpenApiComponents { - Schemas = new Dictionary() + Schemas = new Dictionary { [sharedSchema.Reference.Id] = sharedSchema } }; - document.Paths = new OpenApiPaths() + document.Paths = new OpenApiPaths { - ["/"] = new OpenApiPathItem() + ["/"] = new OpenApiPathItem { Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [OperationType.Get] = new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new Dictionary { - ["application/json"] = new OpenApiMediaType() + ["application/json"] = new OpenApiMediaType { Schema = sharedSchema } @@ -67,7 +67,7 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() }; // Act - var errors = document.Validate(new ValidationRuleSet() { new AlwaysFailRule() }); + var errors = document.Validate(new ValidationRuleSet { new AlwaysFailRule() }); // Assert @@ -81,7 +81,7 @@ public void UnresolvedReferenceSchemaShouldNotBeValidated() var sharedSchema = new OpenApiSchema { Type = "string", - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "test" }, @@ -89,16 +89,16 @@ public void UnresolvedReferenceSchemaShouldNotBeValidated() }; OpenApiDocument document = new OpenApiDocument(); - document.Components = new OpenApiComponents() + document.Components = new OpenApiComponents { - Schemas = new Dictionary() + Schemas = new Dictionary { [sharedSchema.Reference.Id] = sharedSchema } }; // Act - var errors = document.Validate(new ValidationRuleSet() { new AlwaysFailRule() }); + var errors = document.Validate(new ValidationRuleSet { new AlwaysFailRule() }); // Assert Assert.True(errors.Count() == 0); @@ -111,7 +111,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() var sharedSchema = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "test" }, @@ -120,21 +120,21 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() OpenApiDocument document = new OpenApiDocument(); - document.Paths = new OpenApiPaths() + document.Paths = new OpenApiPaths { - ["/"] = new OpenApiPathItem() + ["/"] = new OpenApiPathItem { Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [OperationType.Get] = new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new Dictionary { - ["application/json"] = new OpenApiMediaType() + ["application/json"] = new OpenApiMediaType { Schema = sharedSchema } @@ -147,7 +147,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() }; // Act - var errors = document.Validate(new ValidationRuleSet() { new AlwaysFailRule() }); + var errors = document.Validate(new ValidationRuleSet { new AlwaysFailRule() }); // Assert Assert.True(errors.Count() == 0); diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs index 04acf7737..3ea545af9 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs @@ -22,7 +22,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange IEnumerable warnings; - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Default = new OpenApiInteger(55), Type = "string", @@ -53,7 +53,7 @@ public void ValidateExampleAndDefaultShouldNotHaveDataTypeMismatchForSimpleSchem { // Arrange IEnumerable warnings; - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Example = new OpenApiLong(55), Default = new OpenApiPassword("1234"), @@ -87,29 +87,29 @@ public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange IEnumerable warnings; - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Enum = { new OpenApiString("1"), - new OpenApiObject() + new OpenApiObject { ["x"] = new OpenApiInteger(2), ["y"] = new OpenApiString("20"), ["z"] = new OpenApiString("200") }, - new OpenApiArray() + new OpenApiArray { new OpenApiInteger(3) }, - new OpenApiObject() + new OpenApiObject { ["x"] = new OpenApiInteger(4), ["y"] = new OpenApiInteger(40), }, }, Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "integer", } @@ -146,54 +146,54 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema() { // Arrange IEnumerable warnings; - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "integer", Format = "int64" } }, - ["property2"] = new OpenApiSchema() + ["property2"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "boolean" } } }, - ["property3"] = new OpenApiSchema() + ["property3"] = new OpenApiSchema { Type = "string", Format = "password" }, - ["property4"] = new OpenApiSchema() + ["property4"] = new OpenApiSchema { Type = "string" } }, - Default = new OpenApiObject() + Default = new OpenApiObject { - ["property1"] = new OpenApiArray() + ["property1"] = new OpenApiArray { new OpenApiInteger(12), new OpenApiLong(13), new OpenApiString("1"), }, - ["property2"] = new OpenApiArray() + ["property2"] = new OpenApiArray { new OpenApiInteger(2), - new OpenApiObject() + new OpenApiObject { ["x"] = new OpenApiBoolean(true), ["y"] = new OpenApiBoolean(false), diff --git a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs index fc947da20..58d4d3d4c 100644 --- a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs @@ -32,14 +32,15 @@ public void LocateTopLevelObjects() [Fact] public void LocateTopLevelArrayItems() { - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Servers = new List() { + Servers = new List + { new OpenApiServer(), new OpenApiServer() }, Paths = new OpenApiPaths(), - Tags = new List() + Tags = new List { new OpenApiTag() } @@ -66,15 +67,15 @@ public void LocatePathOperationContentSchema() { Paths = new OpenApiPaths() }; - doc.Paths.Add("/test", new OpenApiPathItem() + doc.Paths.Add("/test", new OpenApiPathItem { - Operations = new Dictionary() + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [OperationType.Get] = new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { Content = new Dictionary { @@ -117,21 +118,21 @@ public void LocatePathOperationContentSchema() [Fact] public void WalkDOMWithCycles() { - var loopySchema = new OpenApiSchema() + var loopySchema = new OpenApiSchema { Type = "object", - Properties = new Dictionary() + Properties = new Dictionary { - ["name"] = new OpenApiSchema() { Type = "string" } + ["name"] = new OpenApiSchema { Type = "string" } } }; loopySchema.Properties.Add("parent", loopySchema); - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { Paths = new OpenApiPaths(), - Components = new OpenApiComponents() + Components = new OpenApiComponents { Schemas = new Dictionary { @@ -161,9 +162,9 @@ public void WalkDOMWithCycles() public void LocateReferences() { - var baseSchema = new OpenApiSchema() + var baseSchema = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "base", Type = ReferenceType.Schema @@ -173,8 +174,8 @@ public void LocateReferences() var derivedSchema = new OpenApiSchema { - AnyOf = new List() { baseSchema }, - Reference = new OpenApiReference() + AnyOf = new List { baseSchema }, + Reference = new OpenApiReference { Id = "derived", Type = ReferenceType.Schema @@ -182,10 +183,10 @@ public void LocateReferences() UnresolvedReference = false }; - var testHeader = new OpenApiHeader() + var testHeader = new OpenApiHeader { Schema = derivedSchema, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "test-header", Type = ReferenceType.Header @@ -195,26 +196,26 @@ public void LocateReferences() var doc = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { - ["/"] = new OpenApiPathItem() + ["/"] = new OpenApiPathItem { - Operations = new Dictionary() + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [OperationType.Get] = new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new Dictionary { - ["application/json"] = new OpenApiMediaType() + ["application/json"] = new OpenApiMediaType { Schema = derivedSchema } }, - Headers = new Dictionary() + Headers = new Dictionary { ["test-header"] = testHeader } @@ -224,14 +225,14 @@ public void LocateReferences() } } }, - Components = new OpenApiComponents() + Components = new OpenApiComponents { - Schemas = new Dictionary() + Schemas = new Dictionary { ["derived"] = derivedSchema, ["base"] = baseSchema, }, - Headers = new Dictionary() + Headers = new Dictionary { ["test-header"] = testHeader } diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs index 2bae02b1f..d3c44c29b 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs @@ -18,7 +18,7 @@ public class OpenApiReferencableTests private static readonly OpenApiCallback _callbackFragment = new OpenApiCallback(); private static readonly OpenApiExample _exampleFragment = new OpenApiExample(); private static readonly OpenApiLink _linkFragment = new OpenApiLink(); - private static readonly OpenApiHeader _headerFragment = new OpenApiHeader() + private static readonly OpenApiHeader _headerFragment = new OpenApiHeader { Schema = new OpenApiSchema(), Examples = new Dictionary @@ -35,7 +35,7 @@ public class OpenApiReferencableTests } }; private static readonly OpenApiRequestBody _requestBodyFragment = new OpenApiRequestBody(); - private static readonly OpenApiResponse _responseFragment = new OpenApiResponse() + private static readonly OpenApiResponse _responseFragment = new OpenApiResponse { Headers = new Dictionary { diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs index 63045847b..6e1ff7bf8 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs @@ -31,25 +31,27 @@ public void OpenApiWorkspacesAllowDocumentsToReferenceEachOther() { var workspace = new OpenApiWorkspace(); - workspace.AddDocument("root", new OpenApiDocument() { - Paths = new OpenApiPaths() + workspace.AddDocument("root", new OpenApiDocument + { + Paths = new OpenApiPaths { - ["/"] = new OpenApiPathItem() + ["/"] = new OpenApiPathItem { - Operations = new Dictionary() + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() { - Responses = new OpenApiResponses() + [OperationType.Get] = new OpenApiOperation + { + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new Dictionary { - ["application/json"] = new OpenApiMediaType() + ["application/json"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "test", Type = ReferenceType.Schema @@ -64,11 +66,13 @@ public void OpenApiWorkspacesAllowDocumentsToReferenceEachOther() } } }); - workspace.AddDocument("common", new OpenApiDocument() { - Components = new OpenApiComponents() + workspace.AddDocument("common", new OpenApiDocument + { + Components = new OpenApiComponents { Schemas = { - ["test"] = new OpenApiSchema() { + ["test"] = new OpenApiSchema + { Type = "string", Description = "The referenced one" } @@ -84,7 +88,7 @@ public void OpenApiWorkspacesCanResolveExternalReferences() { var workspace = new OpenApiWorkspace(); workspace.AddDocument("common", CreateCommonDocument()); - var schema = workspace.ResolveReference(new OpenApiReference() + var schema = workspace.ResolveReference(new OpenApiReference { Id = "test", Type = ReferenceType.Schema, @@ -109,7 +113,7 @@ public void OpenApiWorkspacesAllowDocumentsToReferenceEachOther_short() { re.Description = "Success"; re.CreateContent("application/json", co => - co.Schema = new OpenApiSchema() + co.Schema = new OpenApiSchema { Reference = new OpenApiReference() // Reference { @@ -165,7 +169,7 @@ public void OpenApiWorkspacesCanResolveReferencesToDocumentFragments() workspace.AddFragment("fragment", schemaFragment); // Act - var schema = workspace.ResolveReference(new OpenApiReference() + var schema = workspace.ResolveReference(new OpenApiReference { ExternalResource = "fragment" }) as OpenApiSchema; @@ -180,7 +184,7 @@ public void OpenApiWorkspacesCanResolveReferencesToDocumentFragmentsWithJsonPoin { // Arrange var workspace = new OpenApiWorkspace(); - var responseFragment = new OpenApiResponse() + var responseFragment = new OpenApiResponse { Headers = new Dictionary { @@ -190,7 +194,7 @@ public void OpenApiWorkspacesCanResolveReferencesToDocumentFragmentsWithJsonPoin workspace.AddFragment("fragment", responseFragment); // Act - var resolvedElement = workspace.ResolveReference(new OpenApiReference() + var resolvedElement = workspace.ResolveReference(new OpenApiReference { Id = "headers/header1", ExternalResource = "fragment" @@ -205,12 +209,13 @@ public void OpenApiWorkspacesCanResolveReferencesToDocumentFragmentsWithJsonPoin private static OpenApiDocument CreateCommonDocument() { - return new OpenApiDocument() + return new OpenApiDocument { - Components = new OpenApiComponents() + Components = new OpenApiComponents { Schemas = { - ["test"] = new OpenApiSchema() { + ["test"] = new OpenApiSchema + { Type = "string", Description = "The referenced one" } diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs index 1a15ea3b4..13f70f1e9 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs @@ -424,7 +424,7 @@ public void WriteInlineSchemaV2() private static OpenApiDocument CreateDocWithSimpleSchemaToInline() { // Arrange - var thingSchema = new OpenApiSchema() + var thingSchema = new OpenApiSchema { Type = "object", UnresolvedReference = false, @@ -435,24 +435,26 @@ private static OpenApiDocument CreateDocWithSimpleSchemaToInline() } }; - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = "Demo", Version = "1.0.0" }, - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem { Operations = { - [OperationType.Get] = new OpenApiOperation() { + [OperationType.Get] = new OpenApiOperation + { Responses = { ["200"] = new OpenApiResponse { Description = "OK", Content = { - ["application/json"] = new OpenApiMediaType() { + ["application/json"] = new OpenApiMediaType + { Schema = thingSchema } } @@ -531,7 +533,7 @@ public void WriteInlineRecursiveSchema() private static OpenApiDocument CreateDocWithRecursiveSchemaReference() { - var thingSchema = new OpenApiSchema() + var thingSchema = new OpenApiSchema { Type = "object", UnresolvedReference = false, @@ -543,31 +545,33 @@ private static OpenApiDocument CreateDocWithRecursiveSchemaReference() }; thingSchema.Properties["children"] = thingSchema; - var relatedSchema = new OpenApiSchema() + var relatedSchema = new OpenApiSchema { Type = "integer", }; thingSchema.Properties["related"] = relatedSchema; - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = "Demo", Version = "1.0.0" }, - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem { Operations = { - [OperationType.Get] = new OpenApiOperation() { + [OperationType.Get] = new OpenApiOperation + { Responses = { ["200"] = new OpenApiResponse { Description = "OK", Content = { - ["application/json"] = new OpenApiMediaType() { + ["application/json"] = new OpenApiMediaType + { Schema = thingSchema } } From 545d4b392bfc273fa5e182d130738a9f5a36d82f Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 19:20:00 +1100 Subject: [PATCH 22/69] remove some usings --- src/Microsoft.OpenApi.Hidi/Program.cs | 1 - .../Interface/IOpenApiVersionService.cs | 1 - .../OpenApiYamlDocumentReader.cs | 1 - .../ParseNodes/AnyMapFieldMapParameter.cs | 1 - src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs | 2 -- src/Microsoft.OpenApi.Readers/ReadResult.cs | 5 ----- .../Services/OpenApiWorkspaceLoader.cs | 4 ---- .../V2/OpenApiInfoDeserializer.cs | 1 - .../V2/OpenApiXmlDeserializer.cs | 1 - .../V3/OpenApiComponentsDeserializer.cs | 2 -- .../V3/OpenApiDocumentDeserializer.cs | 3 --- .../V3/OpenApiEncodingDeserializer.cs | 1 - .../V3/OpenApiMediaTypeDeserializer.cs | 4 ---- .../V3/OpenApiSchemaDeserializer.cs | 1 - src/Microsoft.OpenApi.Workbench/MainModel.cs | 1 - src/Microsoft.OpenApi.Workbench/StatsVisitor.cs | 3 --- src/Microsoft.OpenApi/Any/OpenApiArray.cs | 1 - .../Extensions/OpenAPIWriterExtensions.cs | 5 ----- src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiContact.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiInfo.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiLicense.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiLink.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs | 2 -- src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiTag.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiXml.cs | 1 - src/Microsoft.OpenApi/Services/LoopDetector.cs | 3 --- src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs | 5 ----- src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs | 1 - src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs | 3 --- .../Validations/OpenApiValidatiorWarning.cs | 6 +----- src/Microsoft.OpenApi/Validations/OpenApiValidator.cs | 1 - .../Validations/OpenApiValidatorError.cs | 5 ----- .../Validations/Rules/OpenApiExtensionRules.cs | 1 - .../Validations/Rules/OpenApiHeaderRules.cs | 2 -- src/Microsoft.OpenApi/Validations/ValidationExtensions.cs | 7 ------- src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs | 1 - .../Services/OpenApiServiceTests.cs | 1 - .../UtilityFiles/OpenApiDocumentMock.cs | 2 -- .../OpenApiReaderTests/OpenApiDiagnosticTests.cs | 1 - .../ReferenceService/TryLoadReferenceV2Tests.cs | 5 ----- .../V2Tests/OpenApiDocumentTests.cs | 3 --- .../V2Tests/OpenApiHeaderTests.cs | 1 - .../V2Tests/OpenApiOperationTests.cs | 1 - .../V2Tests/OpenApiPathItemTests.cs | 2 -- .../V2Tests/OpenApiSchemaTests.cs | 1 - .../V3Tests/OpenApiDocumentTests.cs | 4 ---- .../V3Tests/OpenApiResponseTests.cs | 5 ----- test/Microsoft.OpenApi.SmokeTests/GraphTests.cs | 4 ---- test/Microsoft.OpenApi.SmokeTests/WorkspaceTests.cs | 8 +------- .../OpenApiEnumValuesDescriptionExtensionTests.cs | 4 +--- .../OpenApiPrimaryErrorMessageExtensionTests.cs | 1 - .../Models/OpenApiDocumentTests.cs | 2 -- .../Models/OpenApiOperationTests.cs | 1 - .../Validations/OpenApiComponentsValidationTests.cs | 1 - .../Validations/OpenApiContactValidationTests.cs | 2 -- .../Validations/OpenApiExternalDocsValidationTests.cs | 2 -- .../Validations/OpenApiHeaderValidationTests.cs | 3 --- .../Validations/OpenApiInfoValidationTests.cs | 2 -- .../Validations/OpenApiMediaTypeValidationTests.cs | 3 --- .../Validations/OpenApiReferenceValidationTests.cs | 3 --- .../Validations/OpenApiServerValidationTests.cs | 1 - .../Validations/OpenApiTagValidationTests.cs | 1 - test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs | 5 +---- .../Workspaces/OpenApiWorkspaceTests.cs | 2 -- 69 files changed, 4 insertions(+), 153 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index b8508ab5f..13c355cce 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using System.CommandLine; -using System.CommandLine.Parsing; using System.Threading.Tasks; using Microsoft.OpenApi.Hidi.Handlers; using Microsoft.OpenApi.Hidi.Options; diff --git a/src/Microsoft.OpenApi.Readers/Interface/IOpenApiVersionService.cs b/src/Microsoft.OpenApi.Readers/Interface/IOpenApiVersionService.cs index a7a98d781..9ba9e83a5 100644 --- a/src/Microsoft.OpenApi.Readers/Interface/IOpenApiVersionService.cs +++ b/src/Microsoft.OpenApi.Readers/Interface/IOpenApiVersionService.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs index 4a120cbbf..5a5d81d8e 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMapParameter.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMapParameter.cs index 1aa899978..a50c46324 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMapParameter.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMapParameter.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Readers.ParseNodes diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs index 295b02bf3..f57f4927c 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs @@ -3,9 +3,7 @@ using System; using System.Collections.Generic; -using System.Text.RegularExpressions; using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.Exceptions; diff --git a/src/Microsoft.OpenApi.Readers/ReadResult.cs b/src/Microsoft.OpenApi.Readers/ReadResult.cs index 7479d345f..80b31316a 100644 --- a/src/Microsoft.OpenApi.Readers/ReadResult.cs +++ b/src/Microsoft.OpenApi.Readers/ReadResult.cs @@ -1,11 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Readers diff --git a/src/Microsoft.OpenApi.Readers/Services/OpenApiWorkspaceLoader.cs b/src/Microsoft.OpenApi.Readers/Services/OpenApiWorkspaceLoader.cs index 79f6206d0..3ba8ed2a3 100644 --- a/src/Microsoft.OpenApi.Readers/Services/OpenApiWorkspaceLoader.cs +++ b/src/Microsoft.OpenApi.Readers/Services/OpenApiWorkspaceLoader.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiInfoDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiInfoDeserializer.cs index 5854672d3..ea17c850d 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiInfoDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiInfoDeserializer.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using System; -using System.Collections.Generic; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiXmlDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiXmlDeserializer.cs index ac7db2db6..9824bc477 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiXmlDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiXmlDeserializer.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using System; -using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.Exceptions; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiComponentsDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiComponentsDeserializer.cs index 30d711d33..b7f78a355 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiComponentsDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiComponentsDeserializer.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs index df1434cd9..8eced2903 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs @@ -1,10 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs index fc2f990e7..d965a7a58 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs index c8bd3d240..c0e9ffd75 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs @@ -1,10 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs index 60727c4bb..480b69fb4 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; diff --git a/src/Microsoft.OpenApi.Workbench/MainModel.cs b/src/Microsoft.OpenApi.Workbench/MainModel.cs index 70074736b..f28d4fcee 100644 --- a/src/Microsoft.OpenApi.Workbench/MainModel.cs +++ b/src/Microsoft.OpenApi.Workbench/MainModel.cs @@ -4,7 +4,6 @@ using System; using System.ComponentModel; using System.Diagnostics; -using System.Globalization; using System.IO; using System.Net.Http; using System.Text; diff --git a/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs b/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs index 85faef630..c8cf28799 100644 --- a/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs +++ b/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs @@ -3,9 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; diff --git a/src/Microsoft.OpenApi/Any/OpenApiArray.cs b/src/Microsoft.OpenApi/Any/OpenApiArray.cs index 2c877d631..4e0317437 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiArray.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiArray.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using Microsoft.OpenApi.Writers; -using System; using System.Collections.Generic; namespace Microsoft.OpenApi.Any diff --git a/src/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs index a32807ab6..7181c3b38 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs @@ -1,9 +1,4 @@ using Microsoft.OpenApi.Writers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.OpenApi { diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs index 7abd1bfdd..2969168c8 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using System.Collections.Generic; -using Microsoft.OpenApi.Any; namespace Microsoft.OpenApi.Interfaces { diff --git a/src/Microsoft.OpenApi/Models/OpenApiContact.cs b/src/Microsoft.OpenApi/Models/OpenApiContact.cs index 93cb11bca..113c91b13 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiContact.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiContact.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs index 345f07d59..91d750e6c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs index df0aa0a49..e903c8947 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs index 866515835..e22441dc3 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs index b682744e9..801ef2ce1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs index 9c12fb5a9..a9cd2b7df 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs index 8443e6730..d9e71510c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 616a6a022..64a65bf83 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -3,8 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs index 70164bc59..4512f76dc 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Models/OpenApiTag.cs b/src/Microsoft.OpenApi/Models/OpenApiTag.cs index ba4129142..a0bae5015 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiTag.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiTag.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Models/OpenApiXml.cs b/src/Microsoft.OpenApi/Models/OpenApiXml.cs index c6719d85e..1fb18d508 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiXml.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiXml.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Services/LoopDetector.cs b/src/Microsoft.OpenApi/Services/LoopDetector.cs index 249cab51d..1a796f60b 100644 --- a/src/Microsoft.OpenApi/Services/LoopDetector.cs +++ b/src/Microsoft.OpenApi/Services/LoopDetector.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.OpenApi.Services { diff --git a/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs b/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs index 7e2ebdcac..d27a0a47a 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs @@ -1,11 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs index 9f4ccb8be..9a2db5883 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.IO; using System.Linq; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs index 7827a50c1..c2ee18870 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs @@ -4,9 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs index 77480584d..5a22ff621 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.OpenApi.Exceptions; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Validations { diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs index a0aee12e7..997da26e2 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidatorError.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidatorError.cs index c24d48fe3..95f60dedd 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidatorError.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidatorError.cs @@ -1,11 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Validations diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs index c44983ffb..ef11e23e2 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs @@ -3,7 +3,6 @@ using System; using Microsoft.OpenApi.Interfaces; -using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; namespace Microsoft.OpenApi.Validations.Rules diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs index 9ffbc38f4..b5e66134b 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Properties; namespace Microsoft.OpenApi.Validations.Rules { diff --git a/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs b/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs index 195df89cd..b951cc393 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs @@ -1,13 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.OpenApi.Models; - namespace Microsoft.OpenApi.Validations { /// diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs index 4d7f11032..fe24f460c 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IO; using Microsoft.OpenApi.Exceptions; -using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; namespace Microsoft.OpenApi.Writers diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 9d73c8db6..fd620502d 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -3,7 +3,6 @@ using System.CommandLine; using System.CommandLine.Invocation; -using System.CommandLine.Parsing; using System.Text.Json; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs index 58b85d91d..3f5604ff0 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System.Collections.Generic; -using System.Security.Policy; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs index 23c23b4d6..bb555b264 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs @@ -7,7 +7,6 @@ using FluentAssertions; using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Readers.Tests.OpenApiWorkspaceTests; using Xunit; using Microsoft.OpenApi.Readers.Interface; using System.IO; diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs index a641b7d6f..420314f07 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs @@ -1,15 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; using System.Collections.Generic; using System.IO; -using System.Linq; using FluentAssertions; using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Readers.ParseNodes; -using Microsoft.OpenApi.Readers.V2; -using SharpYaml.Serialization; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.ReferenceService diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index ac5f99a86..5a0d6c734 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -8,10 +8,7 @@ using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Exceptions; -using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Writers; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V2Tests diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs index 7a98c7a6d..7de477ce9 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System.Collections.Generic; using System.IO; using FluentAssertions; using Microsoft.OpenApi.Any; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index 3b0f32871..e6667a51e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -7,7 +7,6 @@ using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; using Microsoft.OpenApi.Readers.V2; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs index a11497cdf..29b4c7a4e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs @@ -4,9 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using FluentAssertions; -using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; using Microsoft.OpenApi.Readers.V2; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs index 9a75e5c8d..9179964bf 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System.Collections.Generic; using System.IO; using FluentAssertions; using Microsoft.OpenApi.Any; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 8a0da3481..699e8b749 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -3,21 +3,17 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; using System.Globalization; using System.IO; using System.Linq; -using System.Text; using System.Threading; using FluentAssertions; using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Validations; using Microsoft.OpenApi.Validations.Rules; using Microsoft.OpenApi.Writers; -using Newtonsoft.Json; using Xunit; using Xunit.Abstractions; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs index 60e3db6e4..f73bc1608 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs @@ -3,11 +3,6 @@ using System.IO; using System.Linq; -using FluentAssertions; -using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Readers.ParseNodes; -using Microsoft.OpenApi.Readers.V3; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V3Tests diff --git a/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs b/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs index de3101e27..8308102dd 100644 --- a/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs +++ b/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs @@ -2,12 +2,8 @@ using Microsoft.OpenApi.Readers; using Microsoft.OpenApi.Services; using System; -using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; -using System.Text; -using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; diff --git a/test/Microsoft.OpenApi.SmokeTests/WorkspaceTests.cs b/test/Microsoft.OpenApi.SmokeTests/WorkspaceTests.cs index 84f9d74ad..0d0056fe3 100644 --- a/test/Microsoft.OpenApi.SmokeTests/WorkspaceTests.cs +++ b/test/Microsoft.OpenApi.SmokeTests/WorkspaceTests.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Microsoft.OpenApi.SmokeTests +namespace Microsoft.OpenApi.SmokeTests { public class WorkspaceTests { diff --git a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtensionTests.cs b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtensionTests.cs index 571c28461..e8ea2fe07 100644 --- a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtensionTests.cs +++ b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtensionTests.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; -using System.IO; +using System.IO; using Microsoft.OpenApi.MicrosoftExtensions; using Microsoft.OpenApi.Writers; -using Moq; using Xunit; namespace Microsoft.OpenApi.Tests.MicrosoftExtensions; diff --git a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtensionTests.cs b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtensionTests.cs index 6b400671b..89c427935 100644 --- a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtensionTests.cs +++ b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtensionTests.cs @@ -3,7 +3,6 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------ -using System; using System.IO; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Writers; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 924699bdf..7c017c2ce 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -5,14 +5,12 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Threading; using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers; -using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index de56df52e..ef28ecb8f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -6,7 +6,6 @@ using FluentAssertions; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; -using NuGet.Frameworks; using Xunit; using Xunit.Abstractions; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs index d10eaf590..b9c230d92 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs @@ -7,7 +7,6 @@ using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; -using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Validations.Rules; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs index ec6bba7b5..157967037 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs @@ -2,12 +2,10 @@ // Licensed under the MIT license. using System; -using System.Collections.Generic; using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; -using Microsoft.OpenApi.Services; using Xunit; namespace Microsoft.OpenApi.Validations.Tests diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiExternalDocsValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiExternalDocsValidationTests.cs index fee728f76..d93951f12 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiExternalDocsValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiExternalDocsValidationTests.cs @@ -2,12 +2,10 @@ // Licensed under the MIT license. using System; -using System.Collections.Generic; using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; -using Microsoft.OpenApi.Services; using Xunit; namespace Microsoft.OpenApi.Validations.Tests diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs index 6a082ec0f..897de89b1 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs @@ -1,14 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; using System.Collections.Generic; using System.Linq; using FluentAssertions; using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Properties; using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Validations.Rules; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiInfoValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiInfoValidationTests.cs index 1a58fff04..f3006d2cd 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiInfoValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiInfoValidationTests.cs @@ -2,12 +2,10 @@ // Licensed under the MIT license. using System; -using System.Collections.Generic; using System.Linq; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; -using Microsoft.OpenApi.Services; using Xunit; namespace Microsoft.OpenApi.Validations.Tests diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs index bdffaff28..aacb83f42 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs @@ -1,14 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; using System.Collections.Generic; using System.Linq; using FluentAssertions; using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Properties; using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Validations.Rules; using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs index 3ed365c8d..eb8809f18 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs @@ -1,11 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiServerValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiServerValidationTests.cs index bbc4c7e10..b09b14f3b 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiServerValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiServerValidationTests.cs @@ -6,7 +6,6 @@ using System.Linq; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; -using Microsoft.OpenApi.Services; using Xunit; namespace Microsoft.OpenApi.Validations.Tests diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs index a039b39c2..49f5643d8 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs @@ -8,7 +8,6 @@ using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; -using Microsoft.OpenApi.Services; using Xunit; namespace Microsoft.OpenApi.Validations.Tests diff --git a/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs b/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs index 102100019..4adfe9da4 100644 --- a/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs index 63045847b..a01d720cb 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; using Xunit; From b23a53a66f77dceba3e8b251639847c5d080947d Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 19:48:02 +1100 Subject: [PATCH 23/69] use some raw strings --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 55 +- .../OpenApiWorkspaceStreamTests.cs | 12 +- .../ParseNodeTests.cs | 44 +- .../ParseNodes/OpenApiAnyConverterTests.cs | 162 ++-- .../ParseNodes/OpenApiAnyTests.cs | 34 +- .../TestCustomExtension.cs | 21 +- .../V2Tests/OpenApiContactTests.cs | 15 +- .../V2Tests/OpenApiDocumentTests.cs | 98 +-- .../V2Tests/OpenApiServerTests.cs | 234 +++--- .../V3Tests/OpenApiContactTests.cs | 15 +- .../V3Tests/OpenApiDocumentTests.cs | 49 +- .../V3Tests/OpenApiSchemaTests.cs | 53 +- .../Models/OpenApiComponentsTests.cs | 383 ++++----- .../Models/OpenApiContactTests.cs | 24 +- .../Models/OpenApiDocumentTests.cs | 179 +++-- .../Models/OpenApiEncodingTests.cs | 24 +- .../Models/OpenApiExternalDocsTests.cs | 16 +- .../Models/OpenApiInfoTests.cs | 90 ++- .../Models/OpenApiLicenseTests.cs | 28 +- .../Models/OpenApiMediaTypeTests.cs | 311 ++++---- .../Models/OpenApiOAuthFlowTests.cs | 44 +- .../Models/OpenApiOAuthFlowsTests.cs | 56 +- .../Models/OpenApiOperationTests.cs | 727 +++++++++--------- .../Models/OpenApiParameterTests.cs | 85 +- .../Models/OpenApiReferenceTests.cs | 36 +- .../Models/OpenApiResponseTests.cs | 189 ++--- .../Models/OpenApiSchemaTests.cs | 202 ++--- .../Models/OpenApiSecurityRequirementTests.cs | 88 ++- .../Models/OpenApiSecuritySchemeTests.cs | 150 ++-- .../Models/OpenApiServerTests.cs | 54 +- .../Models/OpenApiServerVariableTests.cs | 30 +- .../Models/OpenApiTagTests.cs | 28 +- .../Models/OpenApiXmlTests.cs | 32 +- .../Writers/OpenApiYamlWriterTests.cs | 326 ++++---- 34 files changed, 2089 insertions(+), 1805 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index b3e66cfe2..79c427e27 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -662,18 +662,21 @@ internal static void WriteTreeDocumentAsHtml(string sourceUrl, OpenApiDocument d { var rootNode = OpenApiUrlTreeNode.Create(document, "main"); - writer.WriteLine(@" - - - - - - -"); + writer.WriteLine( + """ + + + + + + + + + """); writer.WriteLine("

" + document.Info.Title + "

"); writer.WriteLine(); writer.WriteLine($"

API Description: {sourceUrl}

"); @@ -684,6 +687,7 @@ internal static void WriteTreeDocumentAsHtml(string sourceUrl, OpenApiDocument d { writer.WriteLine($"{style.Key.Replace("_", " ", StringComparison.OrdinalIgnoreCase)}"); } + writer.WriteLine(""); writer.WriteLine("
"); writer.WriteLine(""); @@ -691,18 +695,21 @@ internal static void WriteTreeDocumentAsHtml(string sourceUrl, OpenApiDocument d writer.WriteLine(""); // Write script tag to include JS library for rendering markdown - writer.WriteLine(@""); + writer.WriteLine( + """ + + """); // Write script tag to include JS library for rendering mermaid writer.WriteLine(" { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs index 71489d39f..c80c05a4f 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs @@ -13,13 +13,14 @@ public class OpenApiContactTests [Fact] public void ParseStringContactFragmentShouldSucceed() { - var input = @" -{ - ""name"": ""API Support"", - ""url"": ""http://www.swagger.io/support"", - ""email"": ""support@swagger.io"" -} -"; + var input = + """ + { + "name": "API Support", + "url": "http://www.swagger.io/support", + "email": "support@swagger.io" + } + """; var reader = new OpenApiStringReader(); var diagnostic = new OpenApiDiagnostic(); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index ac5f99a86..b53be6f28 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -22,26 +22,24 @@ public class OpenApiDocumentTests { private const string SampleFolderPath = "V2Tests/Samples/"; - - - [Fact] public void ShouldThrowWhenReferenceTypeIsInvalid() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -paths: - '/': - get: - responses: - '200': - description: ok - schema: - $ref: '#/defi888nition/does/notexist' -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + paths: + '/': + get: + responses: + '200': + description: ok + schema: + $ref: '#/defi888nition/does/notexist' + """; var reader = new OpenApiStringReader(); var doc = reader.Read(input, out var diagnostic); @@ -54,21 +52,22 @@ public void ShouldThrowWhenReferenceTypeIsInvalid() [Fact] public void ShouldThrowWhenReferenceDoesNotExist() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -paths: - '/': - get: - produces: ['application/json'] - responses: - '200': - description: ok - schema: - $ref: '#/definitions/doesnotexist' -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + paths: + '/': + get: + produces: ['application/json'] + responses: + '200': + description: ok + schema: + $ref: '#/definitions/doesnotexist' + """; var reader = new OpenApiStringReader(); @@ -91,23 +90,24 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); var openApiDoc = new OpenApiStringReader().Read( - @" -swagger: 2.0 -info: - title: Simple Document - version: 0.9.1 - x-extension: 2.335 -definitions: - sampleSchema: - type: object - properties: - sampleProperty: - type: double - minimum: 100.54 - maximum: 60000000.35 - exclusiveMaximum: true - exclusiveMinimum: false -paths: {}", + """ + swagger: 2.0 + info: + title: Simple Document + version: 0.9.1 + x-extension: 2.335 + definitions: + sampleSchema: + type: object + properties: + sampleProperty: + type: double + minimum: 100.54 + maximum: 60000000.35 + exclusiveMaximum: true + exclusiveMinimum: false + paths: {} + """, out var context); openApiDoc.Should().BeEquivalentTo( diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs index bf0fe7b78..7b0983d3d 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs @@ -11,13 +11,14 @@ public class OpenApiServerTests [Fact] public void NoServer() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { }); @@ -30,15 +31,16 @@ public void NoServer() [Fact] public void JustSchemeNoDefault() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -schemes: - - http -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + schemes: + - http + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { }); @@ -51,14 +53,16 @@ public void JustSchemeNoDefault() [Fact] public void JustHostNoDefault() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -host: www.foo.com -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + host: www.foo.com + paths: {} + + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { }); @@ -73,16 +77,17 @@ public void JustHostNoDefault() [Fact] public void NoBasePath() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -host: www.foo.com -schemes: - - http -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + host: www.foo.com + schemes: + - http + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { BaseUrl = new Uri("https://www.foo.com/spec.yaml") @@ -98,14 +103,15 @@ public void NoBasePath() [Fact] public void JustBasePathNoDefault() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -basePath: /baz -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + basePath: /baz + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { }); @@ -120,15 +126,16 @@ public void JustBasePathNoDefault() [Fact] public void JustSchemeWithCustomHost() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -schemes: - - http -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + schemes: + - http + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { BaseUrl = new Uri("https://bing.com/foo") @@ -144,15 +151,16 @@ public void JustSchemeWithCustomHost() [Fact] public void JustSchemeWithCustomHostWithEmptyPath() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -schemes: - - http -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + schemes: + - http + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { BaseUrl = new Uri("https://bing.com") @@ -168,14 +176,15 @@ public void JustSchemeWithCustomHostWithEmptyPath() [Fact] public void JustBasePathWithCustomHost() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -basePath: /api -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + basePath: /api + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { BaseUrl = new Uri("https://bing.com") @@ -191,14 +200,15 @@ public void JustBasePathWithCustomHost() [Fact] public void JustHostWithCustomHost() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -host: www.example.com -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + host: www.example.com + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { BaseUrl = new Uri("https://bing.com") @@ -214,14 +224,15 @@ public void JustHostWithCustomHost() [Fact] public void JustHostWithCustomHostWithApi() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -host: prod.bing.com -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + host: prod.bing.com + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { BaseUrl = new Uri("https://dev.bing.com/api/description.yaml") @@ -237,16 +248,17 @@ public void JustHostWithCustomHostWithApi() [Fact] public void MultipleServers() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -schemes: - - http - - https -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + schemes: + - http + - https + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { BaseUrl = new Uri("https://dev.bing.com/api") @@ -263,14 +275,15 @@ public void MultipleServers() [Fact] public void LocalHostWithCustomHost() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -host: localhost:23232 -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + host: localhost:23232 + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { BaseUrl = new Uri("https://bing.com") @@ -286,14 +299,15 @@ public void LocalHostWithCustomHost() [Fact] public void InvalidHostShouldYieldError() { - var input = @" -swagger: 2.0 -info: - title: test - version: 1.0.0 -host: http://test.microsoft.com -paths: {} -"; + var input = + """ + swagger: 2.0 + info: + title: test + version: 1.0.0 + host: http://test.microsoft.com + paths: {} + """; var reader = new OpenApiStringReader(new OpenApiReaderSettings() { BaseUrl = new Uri("https://bing.com") diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs index be78f942b..7e4cfad75 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs @@ -13,13 +13,14 @@ public class OpenApiContactTests [Fact] public void ParseStringContactFragmentShouldSucceed() { - var input = @" -{ - ""name"": ""API Support"", - ""url"": ""http://www.swagger.io/support"", - ""email"": ""support@swagger.io"" -} -"; + var input = + """ + { + "name": "API Support", + "url": "http://www.swagger.io/support", + "email": "support@swagger.io" + } + """; var reader = new OpenApiStringReader(); var diagnostic = new OpenApiDiagnostic(); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 8a0da3481..6356b105c 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -84,12 +84,14 @@ public OpenApiDocumentTests(ITestOutputHelper output) public void ParseDocumentFromInlineStringShouldSucceed() { var openApiDoc = new OpenApiStringReader().Read( - @" -openapi : 3.0.0 -info: - title: Simple Document - version: 0.9.1 -paths: {}", + """ + + openapi : 3.0.0 + info: + title: Simple Document + version: 0.9.1 + paths: {} + """, out var context); openApiDoc.Should().BeEquivalentTo( @@ -119,23 +121,24 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); var openApiDoc = new OpenApiStringReader().Read( - @" -openapi : 3.0.0 -info: - title: Simple Document - version: 0.9.1 -components: - schemas: - sampleSchema: - type: object - properties: - sampleProperty: - type: double - minimum: 100.54 - maximum: 60000000.35 - exclusiveMaximum: true - exclusiveMinimum: false -paths: {}", + """ + openapi : 3.0.0 + info: + title: Simple Document + version: 0.9.1 + components: + schemas: + sampleSchema: + type: object + properties: + sampleProperty: + type: double + minimum: 100.54 + maximum: 60000000.35 + exclusiveMaximum: true + exclusiveMinimum: false + paths: {} + """, out var context); openApiDoc.Should().BeEquivalentTo( diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index 0101d9c6e..c20aee105 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -74,12 +74,14 @@ public void ParsePrimitiveSchemaFragmentShouldSucceed() [Fact] public void ParsePrimitiveStringSchemaFragmentShouldSucceed() { - var input = @" -{ ""type"": ""integer"", -""format"": ""int64"", -""default"": 88 -} -"; + var input = + """ + { + "type": "integer", + "format": "int64", + "default": 88 + } + """; var reader = new OpenApiStringReader(); var diagnostic = new OpenApiDiagnostic(); @@ -101,11 +103,13 @@ public void ParsePrimitiveStringSchemaFragmentShouldSucceed() [Fact] public void ParseExampleStringFragmentShouldSucceed() { - var input = @" -{ - ""foo"": ""bar"", - ""baz"": [ 1,2] -}"; + var input = + """ + { + "foo": "bar", + "baz": [ 1,2] + } + """; var reader = new OpenApiStringReader(); var diagnostic = new OpenApiDiagnostic(); @@ -129,11 +133,13 @@ public void ParseExampleStringFragmentShouldSucceed() [Fact] public void ParseEnumFragmentShouldSucceed() { - var input = @" -[ - ""foo"", - ""baz"" -]"; + var input = + """ + [ + "foo", + "baz" + ] + """; var reader = new OpenApiStringReader(); var diagnostic = new OpenApiDiagnostic(); @@ -204,13 +210,14 @@ public void ParseSimpleSchemaShouldSucceed() [Fact] public void ParsePathFragmentShouldSucceed() { - var input = @" -summary: externally referenced path item -get: - responses: - '200': - description: Ok -"; + var input = + """ + summary: externally referenced path item + get: + responses: + '200': + description: Ok + """; var reader = new OpenApiStringReader(); var diagnostic = new OpenApiDiagnostic(); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs index 7ba6d132c..7713c3dd1 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs @@ -286,41 +286,44 @@ public void SerializeBasicComponentsAsYamlWorks() public void SerializeAdvancedComponentsAsJsonV3Works() { // Arrange - var expected = @"{ - ""schemas"": { - ""schema1"": { - ""properties"": { - ""property2"": { - ""type"": ""integer"" - }, - ""property3"": { - ""maxLength"": 15, - ""type"": ""string"" - } - } - } - }, - ""securitySchemes"": { - ""securityScheme1"": { - ""type"": ""oauth2"", - ""description"": ""description1"", - ""flows"": { - ""implicit"": { - ""authorizationUrl"": ""https://example.com/api/oauth"", - ""scopes"": { - ""operation1:object1"": ""operation 1 on object 1"", - ""operation2:object2"": ""operation 2 on object 2"" - } - } - } - }, - ""securityScheme2"": { - ""type"": ""openIdConnect"", - ""description"": ""description1"", - ""openIdConnectUrl"": ""https://example.com/openIdConnect"" - } - } -}"; + var expected = + """ + { + "schemas": { + "schema1": { + "properties": { + "property2": { + "type": "integer" + }, + "property3": { + "maxLength": 15, + "type": "string" + } + } + } + }, + "securitySchemes": { + "securityScheme1": { + "type": "oauth2", + "description": "description1", + "flows": { + "implicit": { + "authorizationUrl": "https://example.com/api/oauth", + "scopes": { + "operation1:object1": "operation 1 on object 1", + "operation2:object2": "operation 2 on object 2" + } + } + } + }, + "securityScheme2": { + "type": "openIdConnect", + "description": "description1", + "openIdConnectUrl": "https://example.com/openIdConnect" + } + } + } + """; // Act var actual = AdvancedComponents.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -335,47 +338,50 @@ public void SerializeAdvancedComponentsAsJsonV3Works() public void SerializeAdvancedComponentsWithReferenceAsJsonV3Works() { // Arrange - var expected = @"{ - ""schemas"": { - ""schema1"": { - ""properties"": { - ""property2"": { - ""type"": ""integer"" - }, - ""property3"": { - ""$ref"": ""#/components/schemas/schema2"" - } - } - }, - ""schema2"": { - ""properties"": { - ""property2"": { - ""type"": ""integer"" - } - } - } - }, - ""securitySchemes"": { - ""securityScheme1"": { - ""type"": ""oauth2"", - ""description"": ""description1"", - ""flows"": { - ""implicit"": { - ""authorizationUrl"": ""https://example.com/api/oauth"", - ""scopes"": { - ""operation1:object1"": ""operation 1 on object 1"", - ""operation2:object2"": ""operation 2 on object 2"" - } - } - } - }, - ""securityScheme2"": { - ""type"": ""openIdConnect"", - ""description"": ""description1"", - ""openIdConnectUrl"": ""https://example.com/openIdConnect"" - } - } -}"; + var expected = + """ + { + "schemas": { + "schema1": { + "properties": { + "property2": { + "type": "integer" + }, + "property3": { + "$ref": "#/components/schemas/schema2" + } + } + }, + "schema2": { + "properties": { + "property2": { + "type": "integer" + } + } + } + }, + "securitySchemes": { + "securityScheme1": { + "type": "oauth2", + "description": "description1", + "flows": { + "implicit": { + "authorizationUrl": "https://example.com/api/oauth", + "scopes": { + "operation1:object1": "operation 1 on object 1", + "operation2:object2": "operation 2 on object 2" + } + } + } + }, + "securityScheme2": { + "type": "openIdConnect", + "description": "description1", + "openIdConnectUrl": "https://example.com/openIdConnect" + } + } + } + """; // Act var actual = AdvancedComponentsWithReference.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -390,28 +396,31 @@ public void SerializeAdvancedComponentsWithReferenceAsJsonV3Works() public void SerializeAdvancedComponentsAsYamlV3Works() { // Arrange - var expected = @"schemas: - schema1: - properties: - property2: - type: integer - property3: - maxLength: 15 - type: string -securitySchemes: - securityScheme1: - type: oauth2 - description: description1 - flows: - implicit: - authorizationUrl: https://example.com/api/oauth - scopes: - operation1:object1: operation 1 on object 1 - operation2:object2: operation 2 on object 2 - securityScheme2: - type: openIdConnect - description: description1 - openIdConnectUrl: https://example.com/openIdConnect"; + var expected = + """ + schemas: + schema1: + properties: + property2: + type: integer + property3: + maxLength: 15 + type: string + securitySchemes: + securityScheme1: + type: oauth2 + description: description1 + flows: + implicit: + authorizationUrl: https://example.com/api/oauth + scopes: + operation1:object1: operation 1 on object 1 + operation2:object2: operation 2 on object 2 + securityScheme2: + type: openIdConnect + description: description1 + openIdConnectUrl: https://example.com/openIdConnect + """; // Act var actual = AdvancedComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -426,31 +435,34 @@ public void SerializeAdvancedComponentsAsYamlV3Works() public void SerializeAdvancedComponentsWithReferenceAsYamlV3Works() { // Arrange - var expected = @"schemas: - schema1: - properties: - property2: - type: integer - property3: - $ref: '#/components/schemas/schema2' - schema2: - properties: - property2: - type: integer -securitySchemes: - securityScheme1: - type: oauth2 - description: description1 - flows: - implicit: - authorizationUrl: https://example.com/api/oauth - scopes: - operation1:object1: operation 1 on object 1 - operation2:object2: operation 2 on object 2 - securityScheme2: - type: openIdConnect - description: description1 - openIdConnectUrl: https://example.com/openIdConnect"; + var expected = + """ + schemas: + schema1: + properties: + property2: + type: integer + property3: + $ref: '#/components/schemas/schema2' + schema2: + properties: + property2: + type: integer + securitySchemes: + securityScheme1: + type: oauth2 + description: description1 + flows: + implicit: + authorizationUrl: https://example.com/api/oauth + scopes: + operation1:object1: operation 1 on object 1 + operation2:object2: operation 2 on object 2 + securityScheme2: + type: openIdConnect + description: description1 + openIdConnectUrl: https://example.com/openIdConnect + """; // Act var actual = AdvancedComponentsWithReference.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -465,27 +477,30 @@ public void SerializeAdvancedComponentsWithReferenceAsYamlV3Works() public void SerializeBrokenComponentsAsJsonV3Works() { // Arrange - var expected = @"{ - ""schemas"": { - ""schema1"": { - ""type"": ""string"" - }, - ""schema2"": null, - ""schema3"": null, - ""schema4"": { - ""type"": ""string"", - ""allOf"": [ - null, - null, - { - ""type"": ""string"" - }, - null, - null - ] - } - } -}"; + var expected = + """ + { + "schemas": { + "schema1": { + "type": "string" + }, + "schema2": null, + "schema3": null, + "schema4": { + "type": "string", + "allOf": [ + null, + null, + { + "type": "string" + }, + null, + null + ] + } + } + } + """; // Act var actual = BrokenComponents.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -500,19 +515,22 @@ public void SerializeBrokenComponentsAsJsonV3Works() public void SerializeBrokenComponentsAsYamlV3Works() { // Arrange - var expected = @"schemas: - schema1: - type: string - schema2: - schema3: - schema4: - type: string - allOf: - - - - - - type: string - - - - "; + var expected = + """ + schemas: + schema1: + type: string + schema2: + schema3: + schema4: + type: string + allOf: + - + - + - type: string + - + - + """; // Act var actual = BrokenComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -527,14 +545,17 @@ public void SerializeBrokenComponentsAsYamlV3Works() public void SerializeTopLevelReferencingComponentsAsYamlV3Works() { // Arrange - var expected = @"schemas: - schema1: - $ref: '#/components/schemas/schema2' - schema2: - type: object - properties: - property1: - type: string"; + var expected = + """ + schemas: + schema1: + $ref: '#/components/schemas/schema2' + schema2: + type: object + properties: + property1: + type: string + """; // Act var actual = TopLevelReferencingComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -549,8 +570,11 @@ public void SerializeTopLevelReferencingComponentsAsYamlV3Works() public void SerializeTopLevelSelfReferencingComponentsAsYamlV3Works() { // Arrange - var expected = @"schemas: - schema1: { }"; + var expected = + """ + schemas: + schema1: { } + """; // Act var actual = TopLevelSelfReferencingComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -565,17 +589,20 @@ public void SerializeTopLevelSelfReferencingComponentsAsYamlV3Works() public void SerializeTopLevelSelfReferencingWithOtherPropertiesComponentsAsYamlV3Works() { // Arrange - var expected = @"schemas: - schema1: - type: object - properties: - property1: - type: string - schema2: - type: object - properties: - property1: - type: string"; + var expected = + """ + schemas: + schema1: + type: object + properties: + property1: + type: string + schema2: + type: object + properties: + property1: + type: string + """; // Act var actual = TopLevelSelfReferencingComponentsWithOtherProperties.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs index 1a99241d1..d1ffab249 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs @@ -54,12 +54,14 @@ public void SerializeAdvanceContactAsJsonWorks(OpenApiSpecVersion version) { // Arrange var expected = - @"{ - ""name"": ""API Support"", - ""url"": ""http://www.example.com/support"", - ""email"": ""support@example.com"", - ""x-internal-id"": 42 -}"; + """ + { + "name": "API Support", + "url": "http://www.example.com/support", + "email": "support@example.com", + "x-internal-id": 42 + } + """; // Act var actual = AdvanceContact.SerializeAsJson(version); @@ -77,10 +79,12 @@ public void SerializeAdvanceContactAsYamlWorks(OpenApiSpecVersion version) { // Arrange var expected = - @"name: API Support -url: http://www.example.com/support -email: support@example.com -x-internal-id: 42"; + """ + name: API Support + url: http://www.example.com/support + email: support@example.com + x-internal-id: 42 + """; // Act var actual = AdvanceContact.SerializeAsYaml(version); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 924699bdf..e5d27348b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -1410,18 +1410,21 @@ public async Task SerializeAdvancedDocumentWithReferenceAsV2JsonWorks(bool produ public void SerializeSimpleDocumentWithTopLevelReferencingComponentsAsYamlV2Works() { // Arrange - var expected = @"swagger: '2.0' -info: - version: 1.0.0 -paths: { } -definitions: - schema1: - $ref: '#/definitions/schema2' - schema2: - type: object - properties: - property1: - type: string"; + var expected = + """ + swagger: '2.0' + info: + version: 1.0.0 + paths: { } + definitions: + schema1: + $ref: '#/definitions/schema2' + schema2: + type: object + properties: + property1: + type: string + """; // Act var actual = SimpleDocumentWithTopLevelReferencingComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0); @@ -1436,12 +1439,15 @@ public void SerializeSimpleDocumentWithTopLevelReferencingComponentsAsYamlV2Work public void SerializeSimpleDocumentWithTopLevelSelfReferencingComponentsAsYamlV3Works() { // Arrange - var expected = @"swagger: '2.0' -info: - version: 1.0.0 -paths: { } -definitions: - schema1: { }"; + var expected = + """ + swagger: '2.0' + info: + version: 1.0.0 + paths: { } + definitions: + schema1: { } + """; // Act var actual = SimpleDocumentWithTopLevelSelfReferencingComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0); @@ -1456,21 +1462,24 @@ public void SerializeSimpleDocumentWithTopLevelSelfReferencingComponentsAsYamlV3 public void SerializeSimpleDocumentWithTopLevelSelfReferencingWithOtherPropertiesComponentsAsYamlV3Works() { // Arrange - var expected = @"swagger: '2.0' -info: - version: 1.0.0 -paths: { } -definitions: - schema1: - type: object - properties: - property1: - type: string - schema2: - type: object - properties: - property1: - type: string"; + var expected = + """ + swagger: '2.0' + info: + version: 1.0.0 + paths: { } + definitions: + schema1: + type: object + properties: + property1: + type: string + schema2: + type: object + properties: + property1: + type: string + """; // Act var actual = SimpleDocumentWithTopLevelSelfReferencingComponentsWithOtherProperties.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0); @@ -1541,11 +1550,13 @@ public void SerializeRelativePathAsV2JsonWorks() { // Arrange var expected = - @"swagger: '2.0' -info: - version: 1.0.0 -basePath: /server1 -paths: { }"; + """ + swagger: '2.0' + info: + version: 1.0.0 + basePath: /server1 + paths: { } + """; var doc = new OpenApiDocument() { Info = new OpenApiInfo() { Version = "1.0.0" }, @@ -1571,12 +1582,14 @@ public void SerializeRelativePathWithHostAsV2JsonWorks() { // Arrange var expected = - @"swagger: '2.0' -info: - version: 1.0.0 -host: //example.org -basePath: /server1 -paths: { }"; + """ + swagger: '2.0' + info: + version: 1.0.0 + host: //example.org + basePath: /server1 + paths: { } + """; var doc = new OpenApiDocument() { Info = new OpenApiInfo() { Version = "1.0.0" }, @@ -1602,11 +1615,13 @@ public void SerializeRelativeRootPathWithHostAsV2JsonWorks() { // Arrange var expected = - @"swagger: '2.0' -info: - version: 1.0.0 -host: //example.org -paths: { }"; + """ + swagger: '2.0' + info: + version: 1.0.0 + host: //example.org + paths: { } + """; var doc = new OpenApiDocument() { Info = new OpenApiInfo() { Version = "1.0.0" }, @@ -1680,15 +1695,18 @@ private static OpenApiDocument ParseInputFile(string filePath) public void SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollectionFormat() { // Arrange - var expected = @"swagger: '2.0' -info: { } -paths: - /foo: - get: - parameters: - - in: query - type: string - responses: { }"; + var expected = + """ + swagger: '2.0' + info: { } + paths: + /foo: + get: + parameters: + - in: query + type: string + responses: { } + """; var doc = new OpenApiDocument { @@ -1732,27 +1750,30 @@ public void SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollectionFo public void SerializeV2DocumentWithStyleAsNullDoesNotWriteOutStyleValue() { // Arrange - var expected = @"openapi: 3.0.1 -info: - 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 expected = + """ + openapi: 3.0.1 + info: + 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 { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs index 24bfca242..9f273f280 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs @@ -40,12 +40,14 @@ public void SerializeAdvanceEncodingAsV3JsonWorks() { // Arrange var expected = - @"{ - ""contentType"": ""image/png, image/jpeg"", - ""style"": ""simple"", - ""explode"": true, - ""allowReserved"": true -}"; + """ + { + "contentType": "image/png, image/jpeg", + "style": "simple", + "explode": true, + "allowReserved": true + } + """; // Act var actual = AdvanceEncoding.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -61,10 +63,12 @@ public void SerializeAdvanceEncodingAsV3YamlWorks() { // Arrange var expected = - @"contentType: 'image/png, image/jpeg' -style: simple -explode: true -allowReserved: true"; + """ + contentType: 'image/png, image/jpeg' + style: simple + explode: true + allowReserved: true + """; // Act var actual = AdvanceEncoding.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs index 7d37fc9a4..a9ba66e88 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs @@ -41,10 +41,12 @@ public void SerializeAdvanceExDocsAsV3JsonWorks() { // Arrange var expected = - @"{ - ""description"": ""Find more info here"", - ""url"": ""https://example.com"" -}"; + """ + { + "description": "Find more info here", + "url": "https://example.com" + } + """; // Act var actual = AdvanceExDocs.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -60,8 +62,10 @@ public void SerializeAdvanceExDocsAsV3YamlWorks() { // Arrange var expected = - @"description: Find more info here -url: https://example.com"; + """ + description: Find more info here + url: https://example.com + """; // Act var actual = AdvanceExDocs.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs index b2395a9ed..a28ea2598 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs @@ -43,10 +43,12 @@ public static IEnumerable BasicInfoJsonExpected() yield return new object[] { specVersion, - @"{ - ""title"": ""Sample Pet Store App"", - ""version"": ""1.0"" -}" + """ + { + "title": "Sample Pet Store App", + "version": "1.0" + } + """ }; } } @@ -72,8 +74,10 @@ public static IEnumerable BasicInfoYamlExpected() yield return new object[] { specVersion, - @"title: Sample Pet Store App -version: '1.0'" + """ + title: Sample Pet Store App + version: '1.0' + """ }; } } @@ -99,24 +103,26 @@ public static IEnumerable AdvanceInfoJsonExpect() yield return new object[] { specVersion, - @"{ - ""title"": ""Sample Pet Store App"", - ""description"": ""This is a sample server for a pet store."", - ""termsOfService"": ""http://example.com/terms/"", - ""contact"": { - ""name"": ""API Support"", - ""url"": ""http://www.example.com/support"", - ""email"": ""support@example.com"", - ""x-internal-id"": 42 - }, - ""license"": { - ""name"": ""Apache 2.0"", - ""url"": ""http://www.apache.org/licenses/LICENSE-2.0.html"", - ""x-copyright"": ""Abc"" - }, - ""version"": ""1.1.1"", - ""x-updated"": ""metadata"" -}" + """ + { + "title": "Sample Pet Store App", + "description": "This is a sample server for a pet store.", + "termsOfService": "http://example.com/terms/", + "contact": { + "name": "API Support", + "url": "http://www.example.com/support", + "email": "support@example.com", + "x-internal-id": 42 + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html", + "x-copyright": "Abc" + }, + "version": "1.1.1", + "x-updated": "metadata" + } + """ }; } } @@ -142,20 +148,22 @@ public static IEnumerable AdvanceInfoYamlExpect() yield return new object[] { specVersion, - @"title: Sample Pet Store App -description: This is a sample server for a pet store. -termsOfService: http://example.com/terms/ -contact: - name: API Support - url: http://www.example.com/support - email: support@example.com - x-internal-id: 42 -license: - name: Apache 2.0 - url: http://www.apache.org/licenses/LICENSE-2.0.html - x-copyright: Abc -version: '1.1.1' -x-updated: metadata" + """ + title: Sample Pet Store App + description: This is a sample server for a pet store. + termsOfService: http://example.com/terms/ + contact: + name: API Support + url: http://www.example.com/support + email: support@example.com + x-internal-id: 42 + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + x-copyright: Abc + version: '1.1.1' + x-updated: metadata + """ }; } } @@ -184,8 +192,10 @@ public void InfoVersionShouldAcceptDateStyledAsVersions() }; var expected = - @"title: Sample Pet Store App -version: '2017-03-01'"; + """ + title: Sample Pet Store App + version: '2017-03-01' + """; // Act var actual = info.Serialize(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Yaml); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs index 46717ecec..1f5bb1d5b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs @@ -37,9 +37,11 @@ public void SerializeBasicLicenseAsJsonWorks(OpenApiSpecVersion version) { // Arrange var expected = - @"{ - ""name"": ""Apache 2.0"" -}"; + """ + { + "name": "Apache 2.0" + } + """; // Act var actual = BasicLicense.SerializeAsJson(version); @@ -74,11 +76,13 @@ public void SerializeAdvanceLicenseAsJsonWorks(OpenApiSpecVersion version) { // Arrange var expected = - @"{ - ""name"": ""Apache 2.0"", - ""url"": ""http://www.apache.org/licenses/LICENSE-2.0.html"", - ""x-copyright"": ""Abc"" -}"; + """ + { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html", + "x-copyright": "Abc" + } + """; // Act var actual = AdvanceLicense.SerializeAsJson(version); @@ -96,9 +100,11 @@ public void SerializeAdvanceLicenseAsYamlWorks(OpenApiSpecVersion version) { // Arrange var expected = - @"name: Apache 2.0 -url: http://www.apache.org/licenses/LICENSE-2.0.html -x-copyright: Abc"; + """ + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + x-copyright: Abc + """; // Act var actual = AdvanceLicense.SerializeAsYaml(version); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs index c59da1e86..161be20d9 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs @@ -147,17 +147,19 @@ public void SerializeAdvanceMediaTypeAsV3JsonWorks() { // Arrange var expected = - @"{ - ""example"": 42, - ""encoding"": { - ""testEncoding"": { - ""contentType"": ""image/png, image/jpeg"", - ""style"": ""simple"", - ""explode"": true, - ""allowReserved"": true - } - } -}"; + """ + { + "example": 42, + "encoding": { + "testEncoding": { + "contentType": "image/png, image/jpeg", + "style": "simple", + "explode": true, + "allowReserved": true + } + } + } + """; // Act var actual = AdvanceMediaType.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -173,13 +175,15 @@ public void SerializeAdvanceMediaTypeAsV3YamlWorks() { // Arrange var expected = - @"example: 42 -encoding: - testEncoding: - contentType: 'image/png, image/jpeg' - style: simple - explode: true - allowReserved: true"; + """ + example: 42 + encoding: + testEncoding: + contentType: 'image/png, image/jpeg' + style: simple + explode: true + allowReserved: true + """; // Act var actual = AdvanceMediaType.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -195,24 +199,26 @@ public void SerializeMediaTypeWithObjectExampleAsV3YamlWorks() { // Arrange var expected = - @"example: - 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 -encoding: - testEncoding: - contentType: 'image/png, image/jpeg' - style: simple - explode: true - allowReserved: true"; + """ + example: + 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 + encoding: + testEncoding: + contentType: 'image/png, image/jpeg' + style: simple + explode: true + allowReserved: true + """; // Act var actual = MediaTypeWithObjectExample.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -228,40 +234,42 @@ public void SerializeMediaTypeWithObjectExampleAsV3JsonWorks() { // Arrange var expected = - @"{ - ""example"": { - ""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"" - } - ] - } - ] - }, - ""encoding"": { - ""testEncoding"": { - ""contentType"": ""image/png, image/jpeg"", - ""style"": ""simple"", - ""explode"": true, - ""allowReserved"": true - } - } -}"; + """ + { + "example": { + "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" + } + ] + } + ] + }, + "encoding": { + "testEncoding": { + "contentType": "image/png, image/jpeg", + "style": "simple", + "explode": true, + "allowReserved": true + } + } + } + """; // Act var actual = MediaTypeWithObjectExample.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -277,13 +285,15 @@ public void SerializeMediaTypeWithXmlExampleAsV3YamlWorks() { // Arrange var expected = - @"example: 123 -encoding: - testEncoding: - contentType: 'image/png, image/jpeg' - style: simple - explode: true - allowReserved: true"; + """ + example: 123 + encoding: + testEncoding: + contentType: 'image/png, image/jpeg' + style: simple + explode: true + allowReserved: true + """; // Act var actual = MediaTypeWithXmlExample.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -298,17 +308,20 @@ public void SerializeMediaTypeWithXmlExampleAsV3YamlWorks() public void SerializeMediaTypeWithXmlExampleAsV3JsonWorks() { // Arrange - var expected = @"{ - ""example"": ""123"", - ""encoding"": { - ""testEncoding"": { - ""contentType"": ""image/png, image/jpeg"", - ""style"": ""simple"", - ""explode"": true, - ""allowReserved"": true - } - } -}"; + var expected = + """ + { + "example": "123", + "encoding": { + "testEncoding": { + "contentType": "image/png, image/jpeg", + "style": "simple", + "explode": true, + "allowReserved": true + } + } + } + """; // Act var actual = MediaTypeWithXmlExample.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -323,26 +336,29 @@ public void SerializeMediaTypeWithXmlExampleAsV3JsonWorks() public void SerializeMediaTypeWithObjectExamplesAsV3YamlWorks() { // Arrange - var expected = @"examples: - object1: - 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 -encoding: - testEncoding: - contentType: 'image/png, image/jpeg' - style: simple - explode: true - allowReserved: true"; + var expected = + """ + examples: + object1: + 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 + encoding: + testEncoding: + contentType: 'image/png, image/jpeg' + style: simple + explode: true + allowReserved: true + """; // Act var actual = MediaTypeWithObjectExamples.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -358,44 +374,47 @@ public void SerializeMediaTypeWithObjectExamplesAsV3YamlWorks() public void SerializeMediaTypeWithObjectExamplesAsV3JsonWorks() { // Arrange - var expected = @"{ - ""examples"": { - ""object1"": { - ""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"" - } - ] - } - ] - } - } - }, - ""encoding"": { - ""testEncoding"": { - ""contentType"": ""image/png, image/jpeg"", - ""style"": ""simple"", - ""explode"": true, - ""allowReserved"": true - } - } -}"; + var expected = + """ + { + "examples": { + "object1": { + "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" + } + ] + } + ] + } + } + }, + "encoding": { + "testEncoding": { + "contentType": "image/png, image/jpeg", + "style": "simple", + "explode": true, + "allowReserved": true + } + } + } + """; // Act var actual = MediaTypeWithObjectExamples.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs index 80040f566..cd46ae02a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs @@ -50,9 +50,11 @@ public void SerializeBasicOAuthFlowAsV3JsonWorks() { // Arrange var expected = - @"{ - ""scopes"": { } -}"; + """ + { + "scopes": { } + } + """; // Act var actual = BasicOAuthFlow.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -84,13 +86,15 @@ public void SerializePartialOAuthFlowAsV3JsonWorks() { // Arrange var expected = - @"{ - ""authorizationUrl"": ""http://example.com/authorization"", - ""scopes"": { - ""scopeName3"": ""description3"", - ""scopeName4"": ""description4"" - } -}"; + """ + { + "authorizationUrl": "http://example.com/authorization", + "scopes": { + "scopeName3": "description3", + "scopeName4": "description4" + } + } + """; // Act var actual = PartialOAuthFlow.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -106,15 +110,17 @@ public void SerializeCompleteOAuthFlowAsV3JsonWorks() { // Arrange var expected = - @"{ - ""authorizationUrl"": ""http://example.com/authorization"", - ""tokenUrl"": ""http://example.com/token"", - ""refreshUrl"": ""http://example.com/refresh"", - ""scopes"": { - ""scopeName3"": ""description3"", - ""scopeName4"": ""description4"" - } -}"; + """ + { + "authorizationUrl": "http://example.com/authorization", + "tokenUrl": "http://example.com/token", + "refreshUrl": "http://example.com/refresh", + "scopes": { + "scopeName3": "description3", + "scopeName4": "description4" + } + } + """; // Act var actual = CompleteOAuthFlow.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs index 7d4882bbb..9860a926a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs @@ -96,15 +96,17 @@ public void SerializeOAuthFlowsWithSingleFlowAsV3JsonWorks() { // Arrange var expected = - @"{ - ""implicit"": { - ""authorizationUrl"": ""http://example.com/authorization"", - ""scopes"": { - ""scopeName1"": ""description1"", - ""scopeName2"": ""description2"" - } - } -}"; + """ + { + "implicit": { + "authorizationUrl": "http://example.com/authorization", + "scopes": { + "scopeName1": "description1", + "scopeName2": "description2" + } + } + } + """; // Act var actual = OAuthFlowsWithSingleFlow.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -120,23 +122,25 @@ public void SerializeOAuthFlowsWithMultipleFlowsAsV3JsonWorks() { // Arrange var expected = - @"{ - ""implicit"": { - ""authorizationUrl"": ""http://example.com/authorization"", - ""scopes"": { - ""scopeName1"": ""description1"", - ""scopeName2"": ""description2"" - } - }, - ""password"": { - ""tokenUrl"": ""http://example.com/token"", - ""refreshUrl"": ""http://example.com/refresh"", - ""scopes"": { - ""scopeName3"": ""description3"", - ""scopeName4"": ""description4"" - } - } -}"; + """ + { + "implicit": { + "authorizationUrl": "http://example.com/authorization", + "scopes": { + "scopeName1": "description1", + "scopeName2": "description2" + } + }, + "password": { + "tokenUrl": "http://example.com/token", + "refreshUrl": "http://example.com/refresh", + "scopes": { + "scopeName3": "description3", + "scopeName4": "description4" + } + } + } + """; // Act var actual = OAuthFlowsWithMultipleFlows.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index de56df52e..d87b55820 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -307,9 +307,12 @@ public OpenApiOperationTests(ITestOutputHelper output) public void SerializeBasicOperationAsV3JsonWorks() { // Arrange - var expected = @"{ - ""responses"": { } -}"; + var expected = + """ + { + "responses": { } + } + """; // Act var actual = _basicOperation.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -324,61 +327,64 @@ public void SerializeBasicOperationAsV3JsonWorks() public void SerializeOperationWithBodyAsV3JsonWorks() { // Arrange - var expected = @"{ - ""summary"": ""summary1"", - ""description"": ""operationDescription"", - ""externalDocs"": { - ""description"": ""externalDocsDescription"", - ""url"": ""http://external.com"" - }, - ""operationId"": ""operationId1"", - ""parameters"": [ - { - ""name"": ""parameter1"", - ""in"": ""path"" - }, - { - ""name"": ""parameter2"", - ""in"": ""header"" - } - ], - ""requestBody"": { - ""description"": ""description2"", - ""content"": { - ""application/json"": { - ""schema"": { - ""maximum"": 10, - ""minimum"": 5, - ""type"": ""number"" - } - } - }, - ""required"": true - }, - ""responses"": { - ""200"": { - ""$ref"": ""#/components/responses/response1"" - }, - ""400"": { - ""description"": null, - ""content"": { - ""application/json"": { - ""schema"": { - ""maximum"": 10, - ""minimum"": 5, - ""type"": ""number"" - } - } - } - } - }, - ""servers"": [ - { - ""url"": ""http://server.com"", - ""description"": ""serverDescription"" - } - ] -}"; + var expected = + """ + { + "summary": "summary1", + "description": "operationDescription", + "externalDocs": { + "description": "externalDocsDescription", + "url": "http://external.com" + }, + "operationId": "operationId1", + "parameters": [ + { + "name": "parameter1", + "in": "path" + }, + { + "name": "parameter2", + "in": "header" + } + ], + "requestBody": { + "description": "description2", + "content": { + "application/json": { + "schema": { + "maximum": 10, + "minimum": 5, + "type": "number" + } + } + }, + "required": true + }, + "responses": { + "200": { + "$ref": "#/components/responses/response1" + }, + "400": { + "description": null, + "content": { + "application/json": { + "schema": { + "maximum": 10, + "minimum": 5, + "type": "number" + } + } + } + } + }, + "servers": [ + { + "url": "http://server.com", + "description": "serverDescription" + } + ] + } + """; // Act var actual = _operationWithBody.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -393,74 +399,77 @@ public void SerializeOperationWithBodyAsV3JsonWorks() public void SerializeAdvancedOperationWithTagAndSecurityAsV3JsonWorks() { // Arrange - var expected = @"{ - ""tags"": [ - ""tagName1"", - ""tagId1"" - ], - ""summary"": ""summary1"", - ""description"": ""operationDescription"", - ""externalDocs"": { - ""description"": ""externalDocsDescription"", - ""url"": ""http://external.com"" - }, - ""operationId"": ""operationId1"", - ""parameters"": [ - { - ""name"": ""parameter1"", - ""in"": ""path"" - }, - { - ""name"": ""parameter2"", - ""in"": ""header"" - } - ], - ""requestBody"": { - ""description"": ""description2"", - ""content"": { - ""application/json"": { - ""schema"": { - ""maximum"": 10, - ""minimum"": 5, - ""type"": ""number"" - } - } - }, - ""required"": true - }, - ""responses"": { - ""200"": { - ""$ref"": ""#/components/responses/response1"" - }, - ""400"": { - ""description"": null, - ""content"": { - ""application/json"": { - ""schema"": { - ""maximum"": 10, - ""minimum"": 5, - ""type"": ""number"" - } - } - } - } - }, - ""security"": [ - { - ""securitySchemeId1"": [ ], - ""securitySchemeId2"": [ - ""scopeName1"", - ""scopeName2"" - ] - } - ], - ""servers"": [ - { - ""url"": ""http://server.com"", - ""description"": ""serverDescription"" - } - ] -}"; + var expected = + """ + { + "tags": [ + "tagName1", + "tagId1" + ], + "summary": "summary1", + "description": "operationDescription", + "externalDocs": { + "description": "externalDocsDescription", + "url": "http://external.com" + }, + "operationId": "operationId1", + "parameters": [ + { + "name": "parameter1", + "in": "path" + }, + { + "name": "parameter2", + "in": "header" + } + ], + "requestBody": { + "description": "description2", + "content": { + "application/json": { + "schema": { + "maximum": 10, + "minimum": 5, + "type": "number" + } + } + }, + "required": true + }, + "responses": { + "200": { + "$ref": "#/components/responses/response1" + }, + "400": { + "description": null, + "content": { + "application/json": { + "schema": { + "maximum": 10, + "minimum": 5, + "type": "number" + } + } + } + } + }, + "security": [ + { + "securitySchemeId1": [ ], + "securitySchemeId2": [ + "scopeName1", + "scopeName2" + ] + } + ], + "servers": [ + { + "url": "http://server.com", + "description": "serverDescription" + } + ] + } + """; // Act var actual = _advancedOperationWithTagsAndSecurity.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -475,9 +484,12 @@ public void SerializeAdvancedOperationWithTagAndSecurityAsV3JsonWorks() public void SerializeBasicOperationAsV2JsonWorks() { // Arrange - var expected = @"{ - ""responses"": { } -}"; + var expected = + """ + { + "responses": { } + } + """; // Act var actual = _basicOperation.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0); @@ -492,68 +504,71 @@ public void SerializeBasicOperationAsV2JsonWorks() public void SerializeOperationWithFormDataAsV3JsonWorks() { // Arrange - var expected = @"{ - ""summary"": ""Updates a pet in the store with form data"", - ""description"": """", - ""operationId"": ""updatePetWithForm"", - ""parameters"": [ - { - ""name"": ""petId"", - ""in"": ""path"", - ""description"": ""ID of pet that needs to be updated"", - ""required"": true, - ""schema"": { - ""type"": ""string"" - } - } - ], - ""requestBody"": { - ""content"": { - ""application/x-www-form-urlencoded"": { - ""schema"": { - ""required"": [ - ""name"" - ], - ""properties"": { - ""name"": { - ""type"": ""string"", - ""description"": ""Updated name of the pet"" - }, - ""status"": { - ""type"": ""string"", - ""description"": ""Updated status of the pet"" - } - } - } - }, - ""multipart/form-data"": { - ""schema"": { - ""required"": [ - ""name"" - ], - ""properties"": { - ""name"": { - ""type"": ""string"", - ""description"": ""Updated name of the pet"" - }, - ""status"": { - ""type"": ""string"", - ""description"": ""Updated status of the pet"" - } - } - } - } - } - }, - ""responses"": { - ""200"": { - ""description"": ""Pet updated."" - }, - ""405"": { - ""description"": ""Invalid input"" - } - } -}"; + var expected = + """ + { + "summary": "Updates a pet in the store with form data", + "description": "", + "operationId": "updatePetWithForm", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet that needs to be updated", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string", + "description": "Updated name of the pet" + }, + "status": { + "type": "string", + "description": "Updated status of the pet" + } + } + } + }, + "multipart/form-data": { + "schema": { + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string", + "description": "Updated name of the pet" + }, + "status": { + "type": "string", + "description": "Updated status of the pet" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Pet updated." + }, + "405": { + "description": "Invalid input" + } + } + } + """; // Act var actual = _operationWithFormData.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -568,45 +583,48 @@ public void SerializeOperationWithFormDataAsV3JsonWorks() public void SerializeOperationWithFormDataAsV2JsonWorks() { // Arrange - var expected = @"{ - ""summary"": ""Updates a pet in the store with form data"", - ""description"": """", - ""operationId"": ""updatePetWithForm"", - ""consumes"": [ - ""application/x-www-form-urlencoded"", - ""multipart/form-data"" - ], - ""parameters"": [ - { - ""in"": ""path"", - ""name"": ""petId"", - ""description"": ""ID of pet that needs to be updated"", - ""required"": true, - ""type"": ""string"" - }, - { - ""in"": ""formData"", - ""name"": ""name"", - ""description"": ""Updated name of the pet"", - ""required"": true, - ""type"": ""string"" - }, - { - ""in"": ""formData"", - ""name"": ""status"", - ""description"": ""Updated status of the pet"", - ""type"": ""string"" - } - ], - ""responses"": { - ""200"": { - ""description"": ""Pet updated."" - }, - ""405"": { - ""description"": ""Invalid input"" - } - } -}"; + var expected = + """ + { + "summary": "Updates a pet in the store with form data", + "description": "", + "operationId": "updatePetWithForm", + "consumes": [ + "application/x-www-form-urlencoded", + "multipart/form-data" + ], + "parameters": [ + { + "in": "path", + "name": "petId", + "description": "ID of pet that needs to be updated", + "required": true, + "type": "string" + }, + { + "in": "formData", + "name": "name", + "description": "Updated name of the pet", + "required": true, + "type": "string" + }, + { + "in": "formData", + "name": "status", + "description": "Updated status of the pet", + "type": "string" + } + ], + "responses": { + "200": { + "description": "Pet updated." + }, + "405": { + "description": "Invalid input" + } + } + } + """; // Act var actual = _operationWithFormData.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0); @@ -621,58 +639,61 @@ public void SerializeOperationWithFormDataAsV2JsonWorks() public void SerializeOperationWithBodyAsV2JsonWorks() { // Arrange - var expected = @"{ - ""summary"": ""summary1"", - ""description"": ""operationDescription"", - ""externalDocs"": { - ""description"": ""externalDocsDescription"", - ""url"": ""http://external.com"" - }, - ""operationId"": ""operationId1"", - ""consumes"": [ - ""application/json"" - ], - ""produces"": [ - ""application/json"" - ], - ""parameters"": [ - { - ""in"": ""path"", - ""name"": ""parameter1"" - }, - { - ""in"": ""header"", - ""name"": ""parameter2"" - }, - { - ""in"": ""body"", - ""name"": ""body"", - ""description"": ""description2"", - ""required"": true, - ""schema"": { - ""maximum"": 10, - ""minimum"": 5, - ""type"": ""number"" - } - } - ], - ""responses"": { - ""200"": { - ""$ref"": ""#/responses/response1"" - }, - ""400"": { - ""description"": null, - ""schema"": { - ""maximum"": 10, - ""minimum"": 5, - ""type"": ""number"" - } - } - }, - ""schemes"": [ - ""http"" - ] -}"; + var expected = + """ + { + "summary": "summary1", + "description": "operationDescription", + "externalDocs": { + "description": "externalDocsDescription", + "url": "http://external.com" + }, + "operationId": "operationId1", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "parameter1" + }, + { + "in": "header", + "name": "parameter2" + }, + { + "in": "body", + "name": "body", + "description": "description2", + "required": true, + "schema": { + "maximum": 10, + "minimum": 5, + "type": "number" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/response1" + }, + "400": { + "description": null, + "schema": { + "maximum": 10, + "minimum": 5, + "type": "number" + } + } + }, + "schemes": [ + "http" + ] + } + """; // Act var actual = _operationWithBody.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0); @@ -687,71 +708,74 @@ public void SerializeOperationWithBodyAsV2JsonWorks() public void SerializeAdvancedOperationWithTagAndSecurityAsV2JsonWorks() { // Arrange - var expected = @"{ - ""tags"": [ - ""tagName1"", - ""tagId1"" - ], - ""summary"": ""summary1"", - ""description"": ""operationDescription"", - ""externalDocs"": { - ""description"": ""externalDocsDescription"", - ""url"": ""http://external.com"" - }, - ""operationId"": ""operationId1"", - ""consumes"": [ - ""application/json"" - ], - ""produces"": [ - ""application/json"" - ], - ""parameters"": [ - { - ""in"": ""path"", - ""name"": ""parameter1"" - }, - { - ""in"": ""header"", - ""name"": ""parameter2"" - }, - { - ""in"": ""body"", - ""name"": ""body"", - ""description"": ""description2"", - ""required"": true, - ""schema"": { - ""maximum"": 10, - ""minimum"": 5, - ""type"": ""number"" - } - } - ], - ""responses"": { - ""200"": { - ""$ref"": ""#/responses/response1"" - }, - ""400"": { - ""description"": null, - ""schema"": { - ""maximum"": 10, - ""minimum"": 5, - ""type"": ""number"" - } - } - }, - ""schemes"": [ - ""http"" - ], - ""security"": [ - { - ""securitySchemeId1"": [ ], - ""securitySchemeId2"": [ - ""scopeName1"", - ""scopeName2"" - ] - } - ] -}"; + var expected = + """ + { + "tags": [ + "tagName1", + "tagId1" + ], + "summary": "summary1", + "description": "operationDescription", + "externalDocs": { + "description": "externalDocsDescription", + "url": "http://external.com" + }, + "operationId": "operationId1", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "parameter1" + }, + { + "in": "header", + "name": "parameter2" + }, + { + "in": "body", + "name": "body", + "description": "description2", + "required": true, + "schema": { + "maximum": 10, + "minimum": 5, + "type": "number" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/response1" + }, + "400": { + "description": null, + "schema": { + "maximum": 10, + "minimum": 5, + "type": "number" + } + } + }, + "schemes": [ + "http" + ], + "security": [ + { + "securitySchemeId1": [ ], + "securitySchemeId2": [ + "scopeName1", + "scopeName2" + ] + } + ] + } + """; // Act var actual = _advancedOperationWithTagsAndSecurity.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0); @@ -766,9 +790,12 @@ public void SerializeAdvancedOperationWithTagAndSecurityAsV2JsonWorks() public void SerializeOperationWithNullCollectionAsV2JsonWorks() { // Arrange - var expected = @"{ - ""responses"": { } -}"; + var expected = + """ + { + "responses": { } + } + """; var operation = new OpenApiOperation { Parameters = null, diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs index 2a2c65202..8ffb122ef 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs @@ -211,10 +211,13 @@ public void WhenStyleAndInIsNullTheDefaultValueOfStyleShouldBeSimple(ParameterLo public void SerializeBasicParameterAsV3JsonWorks() { // Arrange - var expected = @"{ - ""name"": ""name1"", - ""in"": ""path"" -}"; + var expected = + """ + { + "name": "name1", + "in": "path" + } + """; // Act var actual = BasicParameter.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -229,33 +232,36 @@ public void SerializeBasicParameterAsV3JsonWorks() public void SerializeAdvancedParameterAsV3JsonWorks() { // Arrange - var expected = @"{ - ""name"": ""name1"", - ""in"": ""path"", - ""description"": ""description1"", - ""required"": true, - ""style"": ""simple"", - ""explode"": true, - ""schema"": { - ""title"": ""title2"", - ""oneOf"": [ - { - ""type"": ""number"", - ""format"": ""double"" - }, - { - ""type"": ""string"" - } - ], - ""description"": ""description2"" - }, - ""examples"": { - ""test"": { - ""summary"": ""summary3"", - ""description"": ""description3"" - } - } -}"; + var expected = + """ + { + "name": "name1", + "in": "path", + "description": "description1", + "required": true, + "style": "simple", + "explode": true, + "schema": { + "title": "title2", + "oneOf": [ + { + "type": "number", + "format": "double" + }, + { + "type": "string" + } + ], + "description": "description2" + }, + "examples": { + "test": { + "summary": "summary3", + "description": "description3" + } + } + } + """; // Act var actual = AdvancedPathParameterWithSchema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -270,13 +276,16 @@ public void SerializeAdvancedParameterAsV3JsonWorks() public void SerializeAdvancedParameterAsV2JsonWorks() { // Arrange - var expected = @"{ - ""in"": ""path"", - ""name"": ""name1"", - ""description"": ""description1"", - ""required"": true, - ""format"": ""double"" -}"; + var expected = + """ + { + "in": "path", + "name": "name1", + "description": "description1", + "required": true, + "format": "double" + } + """; // Act var actual = AdvancedPathParameterWithSchema.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs index b9edd2a32..5b7426fca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs @@ -90,9 +90,12 @@ public void SerializeSchemaReferenceAsJsonV3Works() { // Arrange var reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "Pet" }; - var expected = @"{ - ""$ref"": ""#/components/schemas/Pet"" -}"; + var expected = + """ + { + "$ref": "#/components/schemas/Pet" + } + """; // Act var actual = reference.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -132,9 +135,12 @@ public void SerializeSchemaReferenceAsJsonV2Works() Id = "Pet" }; - var expected = @"{ - ""$ref"": ""#/definitions/Pet"" -}".MakeLineBreaksEnvironmentNeutral(); + var expected = + """ + { + "$ref": "#/definitions/Pet" + } + """.MakeLineBreaksEnvironmentNeutral(); // Act var actual = reference.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0); @@ -172,9 +178,12 @@ public void SerializeExternalReferenceAsJsonV2Works() Id = "Pets" }; - var expected = @"{ - ""$ref"": ""main.json#/definitions/Pets"" -}"; + var expected = + """ + { + "$ref": "main.json#/definitions/Pets" + } + """; // Act var actual = reference.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0); @@ -210,9 +219,12 @@ public void SerializeExternalReferenceAsJsonV3Works() // Arrange var reference = new OpenApiReference { ExternalResource = "main.json", Type = ReferenceType.Schema,Id = "Pets" }; - var expected = @"{ - ""$ref"": ""main.json#/components/schemas/Pets"" -}"; + var expected = + """ + { + "$ref": "main.json#/components/schemas/Pets" + } + """; // Act var actual = reference.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs index 0010e8cb6..373305603 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs @@ -126,9 +126,13 @@ public void SerializeBasicResponseWorks( OpenApiFormat format) { // Arrange - var expected = format == OpenApiFormat.Json ? @"{ - ""description"": null -}" : @"description: "; + var expected = format == OpenApiFormat.Json ? + """ + { + "description": null + } + """ : + @"description: "; // Act var actual = BasicResponse.Serialize(version, format); @@ -143,35 +147,37 @@ public void SerializeBasicResponseWorks( public void SerializeAdvancedResponseAsV3JsonWorks() { // Arrange - var expected = @"{ - ""description"": ""A complex object array response"", - ""headers"": { - ""X-Rate-Limit-Limit"": { - ""description"": ""The number of allowed requests in the current period"", - ""schema"": { - ""type"": ""integer"" - } - }, - ""X-Rate-Limit-Reset"": { - ""description"": ""The number of seconds left in the current period"", - ""schema"": { - ""type"": ""integer"" - } - } - }, - ""content"": { - ""text/plain"": { - ""schema"": { - ""type"": ""array"", - ""items"": { - ""$ref"": ""#/components/schemas/customType"" - } - }, - ""example"": ""Blabla"", - ""myextension"": ""myextensionvalue"" - } - } -}"; + var expected = """ + { + "description": "A complex object array response", + "headers": { + "X-Rate-Limit-Limit": { + "description": "The number of allowed requests in the current period", + "schema": { + "type": "integer" + } + }, + "X-Rate-Limit-Reset": { + "description": "The number of seconds left in the current period", + "schema": { + "type": "integer" + } + } + }, + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/customType" + } + }, + "example": "Blabla", + "myextension": "myextensionvalue" + } + } + } + """; // Act var actual = AdvancedResponse.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -187,24 +193,26 @@ public void SerializeAdvancedResponseAsV3YamlWorks() { // Arrange var expected = - @"description: A complex object array response -headers: - X-Rate-Limit-Limit: - description: The number of allowed requests in the current period - schema: - type: integer - X-Rate-Limit-Reset: - description: The number of seconds left in the current period - schema: - type: integer -content: - text/plain: - schema: - type: array - items: - $ref: '#/components/schemas/customType' - example: Blabla - myextension: myextensionvalue"; + """ + description: A complex object array response + headers: + X-Rate-Limit-Limit: + description: The number of allowed requests in the current period + schema: + type: integer + X-Rate-Limit-Reset: + description: The number of seconds left in the current period + schema: + type: integer + content: + text/plain: + schema: + type: array + items: + $ref: '#/components/schemas/customType' + example: Blabla + myextension: myextensionvalue + """; // Act var actual = AdvancedResponse.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -219,29 +227,32 @@ public void SerializeAdvancedResponseAsV3YamlWorks() public void SerializeAdvancedResponseAsV2JsonWorks() { // Arrange - var expected = @"{ - ""description"": ""A complex object array response"", - ""schema"": { - ""type"": ""array"", - ""items"": { - ""$ref"": ""#/definitions/customType"" - } - }, - ""examples"": { - ""text/plain"": ""Blabla"" - }, - ""myextension"": ""myextensionvalue"", - ""headers"": { - ""X-Rate-Limit-Limit"": { - ""description"": ""The number of allowed requests in the current period"", - ""type"": ""integer"" - }, - ""X-Rate-Limit-Reset"": { - ""description"": ""The number of seconds left in the current period"", - ""type"": ""integer"" - } - } -}"; + var expected = + """ + { + "description": "A complex object array response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/customType" + } + }, + "examples": { + "text/plain": "Blabla" + }, + "myextension": "myextensionvalue", + "headers": { + "X-Rate-Limit-Limit": { + "description": "The number of allowed requests in the current period", + "type": "integer" + }, + "X-Rate-Limit-Reset": { + "description": "The number of seconds left in the current period", + "type": "integer" + } + } + } + """; // Act var actual = AdvancedResponse.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0); @@ -257,21 +268,23 @@ public void SerializeAdvancedResponseAsV2YamlWorks() { // Arrange var expected = - @"description: A complex object array response -schema: - type: array - items: - $ref: '#/definitions/customType' -examples: - text/plain: Blabla -myextension: myextensionvalue -headers: - X-Rate-Limit-Limit: - description: The number of allowed requests in the current period - type: integer - X-Rate-Limit-Reset: - description: The number of seconds left in the current period - type: integer"; + """ + description: A complex object array response + schema: + type: array + items: + $ref: '#/definitions/customType' + examples: + text/plain: Blabla + myextension: myextensionvalue + headers: + X-Rate-Limit-Limit: + description: The number of allowed requests in the current period + type: integer + X-Rate-Limit-Reset: + description: The number of seconds left in the current period + type: integer + """; // Act var actual = AdvancedResponse.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 9d84ab63d..63767c498 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -245,19 +245,22 @@ public void SerializeBasicSchemaAsV3JsonWorks() public void SerializeAdvancedSchemaNumberAsV3JsonWorks() { // Arrange - var expected = @"{ - ""title"": ""title1"", - ""multipleOf"": 3, - ""maximum"": 42, - ""minimum"": 10, - ""exclusiveMinimum"": true, - ""type"": ""integer"", - ""default"": 15, - ""nullable"": true, - ""externalDocs"": { - ""url"": ""http://example.com/externalDocs"" - } -}"; + var expected = + """ + { + "title": "title1", + "multipleOf": 3, + "maximum": 42, + "minimum": 10, + "exclusiveMinimum": true, + "type": "integer", + "default": 15, + "nullable": true, + "externalDocs": { + "url": "http://example.com/externalDocs" + } + } + """; // Act var actual = AdvancedSchemaNumber.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -272,41 +275,44 @@ public void SerializeAdvancedSchemaNumberAsV3JsonWorks() public void SerializeAdvancedSchemaObjectAsV3JsonWorks() { // Arrange - var expected = @"{ - ""title"": ""title1"", - ""properties"": { - ""property1"": { - ""properties"": { - ""property2"": { - ""type"": ""integer"" - }, - ""property3"": { - ""maxLength"": 15, - ""type"": ""string"" - } - } - }, - ""property4"": { - ""properties"": { - ""property5"": { - ""properties"": { - ""property6"": { - ""type"": ""boolean"" - } - } - }, - ""property7"": { - ""minLength"": 2, - ""type"": ""string"" - } - } - } - }, - ""nullable"": true, - ""externalDocs"": { - ""url"": ""http://example.com/externalDocs"" - } -}"; + var expected = + """ + { + "title": "title1", + "properties": { + "property1": { + "properties": { + "property2": { + "type": "integer" + }, + "property3": { + "maxLength": 15, + "type": "string" + } + } + }, + "property4": { + "properties": { + "property5": { + "properties": { + "property6": { + "type": "boolean" + } + } + }, + "property7": { + "minLength": 2, + "type": "string" + } + } + } + }, + "nullable": true, + "externalDocs": { + "url": "http://example.com/externalDocs" + } + } + """; // Act var actual = AdvancedSchemaObject.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -321,44 +327,47 @@ public void SerializeAdvancedSchemaObjectAsV3JsonWorks() public void SerializeAdvancedSchemaWithAllOfAsV3JsonWorks() { // Arrange - var expected = @"{ - ""title"": ""title1"", - ""allOf"": [ - { - ""title"": ""title2"", - ""properties"": { - ""property1"": { - ""type"": ""integer"" - }, - ""property2"": { - ""maxLength"": 15, - ""type"": ""string"" - } - } - }, - { - ""title"": ""title3"", - ""properties"": { - ""property3"": { - ""properties"": { - ""property4"": { - ""type"": ""boolean"" - } - } - }, - ""property5"": { - ""minLength"": 2, - ""type"": ""string"" - } - }, - ""nullable"": true - } - ], - ""nullable"": true, - ""externalDocs"": { - ""url"": ""http://example.com/externalDocs"" - } -}"; + var expected = + """ + { + "title": "title1", + "allOf": [ + { + "title": "title2", + "properties": { + "property1": { + "type": "integer" + }, + "property2": { + "maxLength": 15, + "type": "string" + } + } + }, + { + "title": "title3", + "properties": { + "property3": { + "properties": { + "property4": { + "type": "boolean" + } + } + }, + "property5": { + "minLength": 2, + "type": "string" + } + }, + "nullable": true + } + ], + "nullable": true, + "externalDocs": { + "url": "http://example.com/externalDocs" + } + } + """; // Act var actual = AdvancedSchemaWithAllOf.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -448,15 +457,18 @@ public void SerializeAsV2ShouldSetFormatPropertyInParentSchemaIfPresentInChildre var v2Schema = outputStringWriter.GetStringBuilder().ToString().MakeLineBreaksEnvironmentNeutral(); - var expectedV2Schema = @"{ - ""format"": ""decimal"", - ""allOf"": [ - { - ""format"": ""decimal"", - ""type"": ""number"" - } - ] -}".MakeLineBreaksEnvironmentNeutral(); + var expectedV2Schema = + """ + { + "format": "decimal", + "allOf": [ + { + "format": "decimal", + "type": "number" + } + ] + } + """.MakeLineBreaksEnvironmentNeutral(); // Assert Assert.Equal(expectedV2Schema, v2Schema); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs index 7d630c5f6..220837531 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs @@ -100,18 +100,20 @@ public void SerializeSecurityRequirementWithReferencedSecuritySchemeAsV3JsonWork { // Arrange var expected = - @"{ - ""scheme1"": [ - ""scope1"", - ""scope2"", - ""scope3"" - ], - ""scheme2"": [ - ""scope4"", - ""scope5"" - ], - ""scheme3"": [ ] -}"; + """ + { + "scheme1": [ + "scope1", + "scope2", + "scope3" + ], + "scheme2": [ + "scope4", + "scope5" + ], + "scheme3": [ ] + } + """; // Act var actual = @@ -128,18 +130,20 @@ public void SerializeSecurityRequirementWithReferencedSecuritySchemeAsV2JsonWork { // Arrange var expected = - @"{ - ""scheme1"": [ - ""scope1"", - ""scope2"", - ""scope3"" - ], - ""scheme2"": [ - ""scope4"", - ""scope5"" - ], - ""scheme3"": [ ] -}"; + """ + { + "scheme1": [ + "scope1", + "scope2", + "scope3" + ], + "scheme2": [ + "scope4", + "scope5" + ], + "scheme3": [ ] + } + """; // Act var actual = SecurityRequirementWithReferencedSecurityScheme.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0); @@ -156,14 +160,16 @@ public void { // Arrange var expected = - @"{ - ""scheme1"": [ - ""scope1"", - ""scope2"", - ""scope3"" - ], - ""scheme3"": [ ] -}"; + """ + { + "scheme1": [ + "scope1", + "scope2", + "scope3" + ], + "scheme3": [ ] + } + """; // Act var actual = @@ -181,14 +187,16 @@ public void { // Arrange var expected = - @"{ - ""scheme1"": [ - ""scope1"", - ""scope2"", - ""scope3"" - ], - ""scheme3"": [ ] -}"; + """ + { + "scheme1": [ + "scope1", + "scope2", + "scope3" + ], + "scheme3": [ ] + } + """; // Act var actual = diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs index 44a388d90..acb4323f1 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs @@ -133,12 +133,14 @@ public void SerializeApiKeySecuritySchemeAsV3JsonWorks() { // Arrange var expected = - @"{ - ""type"": ""apiKey"", - ""description"": ""description1"", - ""name"": ""parameterName"", - ""in"": ""query"" -}"; + """ + { + "type": "apiKey", + "description": "description1", + "name": "parameterName", + "in": "query" + } + """; // Act var actual = ApiKeySecurityScheme.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -154,10 +156,12 @@ public void SerializeApiKeySecuritySchemeAsV3YamlWorks() { // Arrange var expected = - @"type: apiKey -description: description1 -name: parameterName -in: query"; + """ + type: apiKey + description: description1 + name: parameterName + in: query + """; // Act var actual = ApiKeySecurityScheme.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); @@ -173,11 +177,13 @@ public void SerializeHttpBasicSecuritySchemeAsV3JsonWorks() { // Arrange var expected = - @"{ - ""type"": ""http"", - ""description"": ""description1"", - ""scheme"": ""basic"" -}"; + """ + { + "type": "http", + "description": "description1", + "scheme": "basic" + } + """; // Act var actual = HttpBasicSecurityScheme.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -193,12 +199,14 @@ public void SerializeHttpBearerSecuritySchemeAsV3JsonWorks() { // Arrange var expected = - @"{ - ""type"": ""http"", - ""description"": ""description1"", - ""scheme"": ""bearer"", - ""bearerFormat"": ""JWT"" -}"; + """ + { + "type": "http", + "description": "description1", + "scheme": "bearer", + "bearerFormat": "JWT" + } + """; // Act var actual = HttpBearerSecurityScheme.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -214,19 +222,21 @@ public void SerializeOAuthSingleFlowSecuritySchemeAsV3JsonWorks() { // Arrange var expected = - @"{ - ""type"": ""oauth2"", - ""description"": ""description1"", - ""flows"": { - ""implicit"": { - ""authorizationUrl"": ""https://example.com/api/oauth"", - ""scopes"": { - ""operation1:object1"": ""operation 1 on object 1"", - ""operation2:object2"": ""operation 2 on object 2"" - } - } - } -}"; + """ + { + "type": "oauth2", + "description": "description1", + "flows": { + "implicit": { + "authorizationUrl": "https://example.com/api/oauth", + "scopes": { + "operation1:object1": "operation 1 on object 1", + "operation2:object2": "operation 2 on object 2" + } + } + } + } + """; // Act var actual = OAuth2SingleFlowSecurityScheme.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -242,35 +252,37 @@ public void SerializeOAuthMultipleFlowSecuritySchemeAsV3JsonWorks() { // Arrange var expected = - @"{ - ""type"": ""oauth2"", - ""description"": ""description1"", - ""flows"": { - ""implicit"": { - ""authorizationUrl"": ""https://example.com/api/oauth"", - ""scopes"": { - ""operation1:object1"": ""operation 1 on object 1"", - ""operation2:object2"": ""operation 2 on object 2"" - } - }, - ""clientCredentials"": { - ""tokenUrl"": ""https://example.com/api/token"", - ""refreshUrl"": ""https://example.com/api/refresh"", - ""scopes"": { - ""operation1:object1"": ""operation 1 on object 1"", - ""operation2:object2"": ""operation 2 on object 2"" - } - }, - ""authorizationCode"": { - ""authorizationUrl"": ""https://example.com/api/oauth"", - ""tokenUrl"": ""https://example.com/api/token"", - ""scopes"": { - ""operation1:object1"": ""operation 1 on object 1"", - ""operation2:object2"": ""operation 2 on object 2"" - } - } - } -}"; + """ + { + "type": "oauth2", + "description": "description1", + "flows": { + "implicit": { + "authorizationUrl": "https://example.com/api/oauth", + "scopes": { + "operation1:object1": "operation 1 on object 1", + "operation2:object2": "operation 2 on object 2" + } + }, + "clientCredentials": { + "tokenUrl": "https://example.com/api/token", + "refreshUrl": "https://example.com/api/refresh", + "scopes": { + "operation1:object1": "operation 1 on object 1", + "operation2:object2": "operation 2 on object 2" + } + }, + "authorizationCode": { + "authorizationUrl": "https://example.com/api/oauth", + "tokenUrl": "https://example.com/api/token", + "scopes": { + "operation1:object1": "operation 1 on object 1", + "operation2:object2": "operation 2 on object 2" + } + } + } + } + """; // Act var actual = OAuth2MultipleFlowSecurityScheme.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -286,11 +298,13 @@ public void SerializeOpenIdConnectSecuritySchemeAsV3JsonWorks() { // Arrange var expected = - @"{ - ""type"": ""openIdConnect"", - ""description"": ""description1"", - ""openIdConnectUrl"": ""https://example.com/openIdConnect"" -}"; + """ + { + "type": "openIdConnect", + "description": "description1", + "openIdConnectUrl": "https://example.com/openIdConnect" + } + """; // Act var actual = OpenIdConnectSecurityScheme.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs index e4d4f36fb..a249591ab 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs @@ -51,10 +51,12 @@ public void SerializeBasicServerAsV3JsonWorks() { // Arrange var expected = - @"{ - ""url"": ""https://example.com/server1"", - ""description"": ""description1"" -}"; + """ + { + "url": "https://example.com/server1", + "description": "description1" + } + """; // Act var actual = BasicServer.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -70,27 +72,29 @@ public void SerializeAdvancedServerAsV3JsonWorks() { // Arrange var expected = - @"{ - ""url"": ""https://{username}.example.com:{port}/{basePath}"", - ""description"": ""description1"", - ""variables"": { - ""username"": { - ""default"": ""unknown"", - ""description"": ""variableDescription1"" - }, - ""port"": { - ""default"": ""8443"", - ""description"": ""variableDescription2"", - ""enum"": [ - ""443"", - ""8443"" - ] - }, - ""basePath"": { - ""default"": ""v1"" - } - } -}"; + """ + { + "url": "https://{username}.example.com:{port}/{basePath}", + "description": "description1", + "variables": { + "username": { + "default": "unknown", + "description": "variableDescription1" + }, + "port": { + "default": "8443", + "description": "variableDescription2", + "enum": [ + "443", + "8443" + ] + }, + "basePath": { + "default": "v1" + } + } + } + """; // Act var actual = AdvancedServer.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs index 9d50f76f6..89e341aac 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs @@ -44,14 +44,16 @@ public void SerializeAdvancedServerVariableAsV3JsonWorks() { // Arrange var expected = - @"{ - ""default"": ""8443"", - ""description"": ""test description"", - ""enum"": [ - ""8443"", - ""443"" - ] -}"; + """ + { + "default": "8443", + "description": "test description", + "enum": [ + "8443", + "443" + ] + } + """; // Act var actual = AdvancedServerVariable.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); @@ -67,11 +69,13 @@ public void SerializeAdvancedServerVariableAsV3YamlWorks() { // Arrange var expected = - @"default: '8443' -description: test description -enum: - - '8443' - - '443'"; + """ + default: '8443' + description: test description + enum: + - '8443' + - '443' + """; // Act var actual = AdvancedServerVariable.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs index 66c0dfd70..ceb8620e8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs @@ -160,12 +160,14 @@ public void SerializeAdvancedTagAsV3YamlWithoutReferenceWorks() var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); var writer = new OpenApiYamlWriter(outputStringWriter); var expected = - @"name: pet -description: Pets operations -externalDocs: - description: Find more info here - url: https://example.com -x-tag-extension: "; + """ + name: pet + description: Pets operations + externalDocs: + description: Find more info here + url: https://example.com + x-tag-extension: + """; // Act AdvancedTag.SerializeAsV3WithoutReference(writer); @@ -185,12 +187,14 @@ public void SerializeAdvancedTagAsV2YamlWithoutReferenceWorks() var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); var writer = new OpenApiYamlWriter(outputStringWriter); var expected = - @"name: pet -description: Pets operations -externalDocs: - description: Find more info here - url: https://example.com -x-tag-extension: "; + """ + name: pet + description: Pets operations + externalDocs: + description: Find more info here + url: https://example.com + x-tag-extension: + """; // Act AdvancedTag.SerializeAsV2WithoutReference(writer); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs index 9e79c5211..ebc303fb9 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs @@ -54,14 +54,16 @@ public void SerializeAdvancedXmlAsJsonWorks(OpenApiSpecVersion version) { // Arrange var expected = - @"{ - ""name"": ""animal"", - ""namespace"": ""http://swagger.io/schema/sample"", - ""prefix"": ""sample"", - ""attribute"": true, - ""wrapped"": true, - ""x-xml-extension"": 7 -}"; + """ + { + "name": "animal", + "namespace": "http://swagger.io/schema/sample", + "prefix": "sample", + "attribute": true, + "wrapped": true, + "x-xml-extension": 7 + } + """; // Act var actual = AdvancedXml.SerializeAsJson(version); @@ -79,12 +81,14 @@ public void SerializeAdvancedXmlAsYamlWorks(OpenApiSpecVersion version) { // Arrange var expected = - @"name: animal -namespace: http://swagger.io/schema/sample -prefix: sample -attribute: true -wrapped: true -x-xml-extension: 7"; + """ + name: animal + namespace: http://swagger.io/schema/sample + prefix: sample + attribute: true + wrapped: true + x-xml-extension: 7 + """; // Act var actual = AdvancedXml.SerializeAsYaml(version); diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs index 1a15ea3b4..3992315e8 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs @@ -39,23 +39,27 @@ public static IEnumerable WriteStringListAsYamlShouldMatchExpectedTest "string7", "string8" }, - @"- string1 -- string2 -- string3 -- string4 -- string5 -- string6 -- string7 -- string8" + """ + - string1 + - string2 + - string3 + - string4 + - string5 + - string6 + - string7 + - string8 + """ }; yield return new object[] { new[] {"string1", "string1", "string1", "string1"}, - @"- string1 -- string1 -- string1 -- string1" + """ + - string1 + - string1 + - string1 + - string1 + """ }; } @@ -99,10 +103,12 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesSi ["property3"] = "value3", ["property4"] = "value4" }, - @"property1: value1 -property2: value2 -property3: value3 -property4: value4" + """ + property1: value1 + property2: value2 + property3: value3 + property4: value4 + """ }; // Simple map with duplicate value @@ -115,10 +121,12 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesSi ["property3"] = "value1", ["property4"] = "value1" }, - @"property1: value1 -property2: value1 -property3: value1 -property4: value1" + """ + property1: value1 + property2: value1 + property3: value1 + property4: value1 + """ }; } @@ -137,11 +145,13 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesCo }, ["property4"] = "value4" }, - @"property1: { } -property2: [ ] -property3: - - { } -property4: value4" + """ + property1: { } + property2: [ ] + property3: + - { } + property4: value4 + """ }; // Number, boolean, and null handling @@ -161,17 +171,19 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesCo ["property10"] = "null", ["property11"] = "", }, - @"property1: '10.0' -property2: '10' -property3: '-5' -property4: 10.0 -property5: 10 -property6: -5 -property7: true -property8: 'true' -property9: -property10: 'null' -property11: ''" + """ + property1: '10.0' + property2: '10' + property3: '-5' + property4: 10.0 + property5: 10 + property6: -5 + property7: true + property8: 'true' + property9: + property10: 'null' + property11: '' + """ }; // DateTime @@ -183,9 +195,11 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesCo ["property2"] = new DateTimeOffset(new DateTime(1970, 01, 01), TimeSpan.FromHours(3)), ["property3"] = new DateTime(2018, 04, 03), }, - @"property1: '1970-01-01T00:00:00.0000000' -property2: '1970-01-01T00:00:00.0000000+03:00' -property3: '2018-04-03T00:00:00.0000000'" + """ + property1: '1970-01-01T00:00:00.0000000' + property2: '1970-01-01T00:00:00.0000000+03:00' + property3: '2018-04-03T00:00:00.0000000' + """ }; // Nested map @@ -204,12 +218,14 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesCo }, ["property4"] = "value4" }, - @"property1: - innerProperty1: innerValue1 -property2: value2 -property3: - innerProperty3: innerValue3 -property4: value4" + """ + property1: + innerProperty1: innerValue1 + property2: value2 + property3: + innerProperty3: innerValue3 + property4: value4 + """ }; // Nested map and list @@ -238,17 +254,19 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesCo }, ["property4"] = "value4" }, - @"property1: { } -property2: [ ] -property3: - - { } - - string1 - - innerProperty1: [ ] - innerProperty2: string2 - innerProperty3: - - - - string3 -property4: value4" + """ + property1: { } + property2: [ ] + property3: + - { } + - string1 + - innerProperty1: [ ] + innerProperty2: string2 + innerProperty3: + - + - string3 + property4: value4 + """ }; } @@ -356,21 +374,23 @@ public void WriteInlineSchema() var doc = CreateDocWithSimpleSchemaToInline(); var expected = -@"openapi: 3.0.1 -info: - title: Demo - version: 1.0.0 -paths: - /: - get: - responses: - '200': - description: OK - content: - application/json: - schema: - type: object -components: { }"; + """ + openapi: 3.0.1 + info: + title: Demo + version: 1.0.0 + paths: + /: + get: + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + components: { } + """; var outputString = new StringWriter(CultureInfo.InvariantCulture); var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { InlineLocalReferences = true } ); @@ -393,20 +413,22 @@ public void WriteInlineSchemaV2() var doc = CreateDocWithSimpleSchemaToInline(); var expected = -@"swagger: '2.0' -info: - title: Demo - version: 1.0.0 -paths: - /: - get: - produces: - - application/json - responses: - '200': - description: OK - schema: - type: object"; + """ + swagger: '2.0' + info: + title: Demo + version: 1.0.0 + paths: + /: + get: + produces: + - application/json + responses: + '200': + description: OK + schema: + type: object + """; var outputString = new StringWriter(CultureInfo.InvariantCulture); var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { InlineLocalReferences = true }); @@ -481,39 +503,41 @@ public void WriteInlineRecursiveSchema() var doc = CreateDocWithRecursiveSchemaReference(); var expected = -@"openapi: 3.0.1 -info: - title: Demo - version: 1.0.0 -paths: - /: - get: - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - properties: - children: - $ref: '#/components/schemas/thing' - related: - type: integer -components: - schemas: - thing: - type: object - properties: - children: - type: object - properties: - children: - $ref: '#/components/schemas/thing' - related: - type: integer - related: - type: integer"; + """ + openapi: 3.0.1 + info: + title: Demo + version: 1.0.0 + paths: + /: + get: + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + children: + $ref: '#/components/schemas/thing' + related: + type: integer + components: + schemas: + thing: + type: object + properties: + children: + type: object + properties: + children: + $ref: '#/components/schemas/thing' + related: + type: integer + related: + type: integer + """; // Component schemas that are there due to cycles are still inlined because the items they reference may not exist in the components because they don't have cycles. var outputString = new StringWriter(CultureInfo.InvariantCulture); @@ -594,38 +618,40 @@ public void WriteInlineRecursiveSchemav2() var doc = CreateDocWithRecursiveSchemaReference(); var expected = -@"swagger: '2.0' -info: - title: Demo - version: 1.0.0 -paths: - /: - get: - produces: - - application/json - responses: - '200': - description: OK - schema: - type: object - properties: - children: - $ref: '#/definitions/thing' - related: - type: integer -definitions: - thing: - type: object - properties: - children: - type: object - properties: - children: - $ref: '#/definitions/thing' - related: - type: integer - related: - type: integer"; + """ + swagger: '2.0' + info: + title: Demo + version: 1.0.0 + paths: + /: + get: + produces: + - application/json + responses: + '200': + description: OK + schema: + type: object + properties: + children: + $ref: '#/definitions/thing' + related: + type: integer + definitions: + thing: + type: object + properties: + children: + type: object + properties: + children: + $ref: '#/definitions/thing' + related: + type: integer + related: + type: integer + """; // Component schemas that are there due to cycles are still inlined because the items they reference may not exist in the components because they don't have cycles. var outputString = new StringWriter(CultureInfo.InvariantCulture); From 9aa78970d208b2c6c5221ae8dffb56e06c8a835c Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 19:49:56 +1100 Subject: [PATCH 24/69] inline some out variables --- .../ParseNodes/MapNode.cs | 7 ++----- .../ParseNodes/PropertyNode.cs | 3 +-- src/Microsoft.OpenApi.Readers/ParsingContext.cs | 3 +-- src/Microsoft.OpenApi/Services/LoopDetector.cs | 3 +-- .../Validations/ValidationRuleSet.cs | 3 +-- .../V2Tests/OpenApiContactTests.cs | 3 +-- .../V3Tests/OpenApiContactTests.cs | 3 +-- .../V3Tests/OpenApiSchemaTests.cs | 15 +++++---------- 8 files changed, 13 insertions(+), 27 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs index 0ee5934ce..c822e05dd 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs @@ -47,8 +47,7 @@ public PropertyNode this[string key] { get { - YamlNode node; - if (this._node.Children.TryGetValue(new YamlScalarNode(key), out node)) + if (this._node.Children.TryGetValue(new YamlScalarNode(key), out var node)) { return new PropertyNode(Context, key, node); } @@ -193,9 +192,7 @@ public T GetReferencedObject(ReferenceType referenceType, string referenceId) public string GetReferencePointer() { - YamlNode refNode; - - if (!_node.Children.TryGetValue(new YamlScalarNode("$ref"), out refNode)) + if (!_node.Children.TryGetValue(new YamlScalarNode("$ref"), out var refNode)) { return null; } diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/PropertyNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/PropertyNode.cs index 2dd2c7e8a..0bd42e25f 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/PropertyNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/PropertyNode.cs @@ -30,8 +30,7 @@ public void ParseField( IDictionary> fixedFields, IDictionary, Action> patternFields) { - Action fixedFieldMap; - var found = fixedFields.TryGetValue(Name, out fixedFieldMap); + var found = fixedFields.TryGetValue(Name, out var fixedFieldMap); if (fixedFieldMap != null) { diff --git a/src/Microsoft.OpenApi.Readers/ParsingContext.cs b/src/Microsoft.OpenApi.Readers/ParsingContext.cs index 0cd98c67e..ccf97117d 100644 --- a/src/Microsoft.OpenApi.Readers/ParsingContext.cs +++ b/src/Microsoft.OpenApi.Readers/ParsingContext.cs @@ -206,8 +206,7 @@ public void StartObject(string objectName) /// If method returns false a loop was detected and the key is not added. public bool PushLoop(string loopId, string key) { - Stack stack; - if (!_loopStacks.TryGetValue(loopId, out stack)) + if (!_loopStacks.TryGetValue(loopId, out var stack)) { stack = new Stack(); _loopStacks.Add(loopId, stack); diff --git a/src/Microsoft.OpenApi/Services/LoopDetector.cs b/src/Microsoft.OpenApi/Services/LoopDetector.cs index 249cab51d..4fb1b8b4e 100644 --- a/src/Microsoft.OpenApi/Services/LoopDetector.cs +++ b/src/Microsoft.OpenApi/Services/LoopDetector.cs @@ -17,8 +17,7 @@ internal class LoopDetector /// If method returns false a loop was detected and the key is not added. public bool PushLoop(T key) { - Stack stack; - if (!_loopStacks.TryGetValue(typeof(T), out stack)) + if (!_loopStacks.TryGetValue(typeof(T), out var stack)) { stack = new Stack(); _loopStacks.Add(typeof(T), stack); diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs index eca7bc8de..3d469d3c2 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs @@ -30,8 +30,7 @@ public sealed class ValidationRuleSet : IEnumerable /// Either the rules related to the type, or an empty list. public IList FindRules(Type type) { - IList results = null; - _rules.TryGetValue(type, out results); + _rules.TryGetValue(type, out var results); return results ?? _emptyRules; } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs index 71489d39f..6e0ae0472 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs @@ -21,10 +21,9 @@ public void ParseStringContactFragmentShouldSucceed() } "; var reader = new OpenApiStringReader(); - var diagnostic = new OpenApiDiagnostic(); // Act - var contact = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi2_0, out diagnostic); + var contact = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi2_0, out var diagnostic); // Assert diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs index be78f942b..1e8cd0934 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs @@ -21,10 +21,9 @@ public void ParseStringContactFragmentShouldSucceed() } "; var reader = new OpenApiStringReader(); - var diagnostic = new OpenApiDiagnostic(); // Act - var contact = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic); + var contact = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out var diagnostic); // Assert diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index 0101d9c6e..bcb088c3f 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -54,10 +54,9 @@ public void ParsePrimitiveSchemaFragmentShouldSucceed() using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "primitiveSchema.yaml"))) { var reader = new OpenApiStreamReader(); - var diagnostic = new OpenApiDiagnostic(); // Act - var schema = reader.ReadFragment(stream, OpenApiSpecVersion.OpenApi3_0, out diagnostic); + var schema = reader.ReadFragment(stream, OpenApiSpecVersion.OpenApi3_0, out var diagnostic); // Assert diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); @@ -81,10 +80,9 @@ public void ParsePrimitiveStringSchemaFragmentShouldSucceed() } "; var reader = new OpenApiStringReader(); - var diagnostic = new OpenApiDiagnostic(); // Act - var schema = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic); + var schema = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out var diagnostic); // Assert diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); @@ -107,10 +105,9 @@ public void ParseExampleStringFragmentShouldSucceed() ""baz"": [ 1,2] }"; var reader = new OpenApiStringReader(); - var diagnostic = new OpenApiDiagnostic(); // Act - var openApiAny = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic); + var openApiAny = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out var diagnostic); // Assert diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); @@ -135,10 +132,9 @@ public void ParseEnumFragmentShouldSucceed() ""baz"" ]"; var reader = new OpenApiStringReader(); - var diagnostic = new OpenApiDiagnostic(); // Act - var openApiAny = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic); + var openApiAny = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out var diagnostic); // Assert diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); @@ -212,10 +208,9 @@ public void ParsePathFragmentShouldSucceed() description: Ok "; var reader = new OpenApiStringReader(); - var diagnostic = new OpenApiDiagnostic(); // Act - var openApiAny = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic); + var openApiAny = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out var diagnostic); // Assert diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); From aa80139f16a435291e118b4ae827e3ad90ede762 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 19:51:11 +1100 Subject: [PATCH 25/69] use negation pattern --- .../ParseNodes/MapNode.cs | 2 +- .../ParseNodes/OpenApiAnyConverter.cs | 2 +- .../ParseNodes/ParseNode.cs | 2 +- .../ParseNodes/ValueNode.cs | 2 +- .../Validations/Rules/RuleHelpers.cs | 30 +++++++++---------- .../Validations/ValidationRule.cs | 2 +- test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs index 0ee5934ce..2ce5e3431 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs @@ -30,7 +30,7 @@ public MapNode(ParsingContext context, string yamlString) : public MapNode(ParsingContext context, YamlNode node) : base( context) { - if (!(node is YamlMappingNode mapNode)) + if (node is not YamlMappingNode mapNode) { throw new OpenApiReaderException("Expected map.", Context); } diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs index ae9254fe8..a12142075 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs @@ -50,7 +50,7 @@ public static IOpenApiAny GetSpecificOpenApiAny(IOpenApiAny openApiAny, OpenApiS return newObject; } - if (!(openApiAny is OpenApiString)) + if (openApiAny is not OpenApiString) { return openApiAny; } diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs index 295b02bf3..24a49f6cc 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs @@ -24,7 +24,7 @@ protected ParseNode(ParsingContext parsingContext) public MapNode CheckMapNode(string nodeName) { - if (!(this is MapNode mapNode)) + if (this is not MapNode mapNode) { throw new OpenApiReaderException($"{nodeName} must be a map/object", Context); } diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs index 68f4bd7ea..6efdcf04d 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs @@ -15,7 +15,7 @@ internal class ValueNode : ParseNode public ValueNode(ParsingContext context, YamlNode node) : base( context) { - if (!(node is YamlScalarNode scalarNode)) + if (node is not YamlScalarNode scalarNode) { throw new OpenApiReaderException("Expected a value.", node); } diff --git a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs index 630dc8e65..731bd8693 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs @@ -75,7 +75,7 @@ public static void ValidateDataTypeMismatch( } // If value is not a string and also not an object, there is a data mismatch. - if (!(value is OpenApiObject)) + if (value is not OpenApiObject) { context.CreateWarning( ruleName, @@ -115,7 +115,7 @@ public static void ValidateDataTypeMismatch( } // If value is not a string and also not an array, there is a data mismatch. - if (!(value is OpenApiArray)) + if (value is not OpenApiArray) { context.CreateWarning( ruleName, @@ -139,7 +139,7 @@ public static void ValidateDataTypeMismatch( if (type == "integer" && format == "int32") { - if (!(value is OpenApiInteger)) + if (value is not OpenApiInteger) { context.CreateWarning( ruleName, @@ -151,7 +151,7 @@ public static void ValidateDataTypeMismatch( if (type == "integer" && format == "int64") { - if (!(value is OpenApiLong)) + if (value is not OpenApiLong) { context.CreateWarning( ruleName, @@ -161,9 +161,9 @@ public static void ValidateDataTypeMismatch( return; } - if (type == "integer" && !(value is OpenApiInteger)) + if (type == "integer" && value is not OpenApiInteger) { - if (!(value is OpenApiInteger)) + if (value is not OpenApiInteger) { context.CreateWarning( ruleName, @@ -175,7 +175,7 @@ public static void ValidateDataTypeMismatch( if (type == "number" && format == "float") { - if (!(value is OpenApiFloat)) + if (value is not OpenApiFloat) { context.CreateWarning( ruleName, @@ -187,7 +187,7 @@ public static void ValidateDataTypeMismatch( if (type == "number" && format == "double") { - if (!(value is OpenApiDouble)) + if (value is not OpenApiDouble) { context.CreateWarning( ruleName, @@ -199,7 +199,7 @@ public static void ValidateDataTypeMismatch( if (type == "number") { - if (!(value is OpenApiDouble)) + if (value is not OpenApiDouble) { context.CreateWarning( ruleName, @@ -211,7 +211,7 @@ public static void ValidateDataTypeMismatch( if (type == "string" && format == "byte") { - if (!(value is OpenApiByte)) + if (value is not OpenApiByte) { context.CreateWarning( ruleName, @@ -223,7 +223,7 @@ public static void ValidateDataTypeMismatch( if (type == "string" && format == "date") { - if (!(value is OpenApiDate)) + if (value is not OpenApiDate) { context.CreateWarning( ruleName, @@ -235,7 +235,7 @@ public static void ValidateDataTypeMismatch( if (type == "string" && format == "date-time") { - if (!(value is OpenApiDateTime)) + if (value is not OpenApiDateTime) { context.CreateWarning( ruleName, @@ -247,7 +247,7 @@ public static void ValidateDataTypeMismatch( if (type == "string" && format == "password") { - if (!(value is OpenApiPassword)) + if (value is not OpenApiPassword) { context.CreateWarning( ruleName, @@ -259,7 +259,7 @@ public static void ValidateDataTypeMismatch( if (type == "string") { - if (!(value is OpenApiString)) + if (value is not OpenApiString) { context.CreateWarning( ruleName, @@ -271,7 +271,7 @@ public static void ValidateDataTypeMismatch( if (type == "boolean") { - if (!(value is OpenApiBoolean)) + if (value is not OpenApiBoolean) { context.CreateWarning( ruleName, diff --git a/src/Microsoft.OpenApi/Validations/ValidationRule.cs b/src/Microsoft.OpenApi/Validations/ValidationRule.cs index fdbf5c330..97a66034d 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRule.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRule.cs @@ -59,7 +59,7 @@ internal override void Evaluate(IValidationContext context, object item) return; } - if (!(item is T)) + if (item is not T) { throw Error.Argument(string.Format(SRResource.InputItemShouldBeType, typeof(T).FullName)); } diff --git a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs index 6d2eafc01..e11be6225 100644 --- a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs +++ b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs @@ -62,7 +62,7 @@ public static IEnumerable GetSchemas() JToken GetProp(JToken obj, string prop) { - if (!(obj is JObject jObj)) + if (obj is not JObject jObj) return null; if (!jObj.TryGetValue(prop, out var jToken)) return null; From c4f02dae769e315e8e22b19cc2710a4299a455b0 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 19:57:00 +1100 Subject: [PATCH 26/69] use pattern matching in casts --- .../ParseNodes/JsonPointerExtensions.cs | 7 ++----- src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs | 6 ++---- src/Microsoft.OpenApi.Readers/YamlHelper.cs | 3 +-- src/Microsoft.OpenApi/Validations/OpenApiValidator.cs | 3 +-- src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs | 3 +-- src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs | 3 +-- test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs | 3 +-- 7 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/JsonPointerExtensions.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/JsonPointerExtensions.cs index d30863955..b8db0fad0 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/JsonPointerExtensions.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/JsonPointerExtensions.cs @@ -26,16 +26,13 @@ public static YamlNode Find(this JsonPointer currentPointer, YamlNode baseYamlNo var pointer = baseYamlNode; foreach (var token in currentPointer.Tokens) { - var sequence = pointer as YamlSequenceNode; - - if (sequence != null) + if (pointer is YamlSequenceNode sequence) { pointer = sequence.Children[Convert.ToInt32(token)]; } else { - var map = pointer as YamlMappingNode; - if (map != null) + if (pointer is YamlMappingNode map) { if (!map.Children.TryGetValue(new YamlScalarNode(token), out pointer)) { diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs index 0ee5934ce..61a833143 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs @@ -152,8 +152,7 @@ public override Dictionary CreateSimpleMap(Func map) try { Context.StartObject(key); - YamlScalarNode scalarNode = n.Value as YamlScalarNode; - if (scalarNode == null) + if (n.Value is not YamlScalarNode scalarNode) { throw new OpenApiReaderException($"Expected scalar while parsing {typeof(T).Name}", Context); } @@ -205,8 +204,7 @@ public string GetReferencePointer() public string GetScalarValue(ValueNode key) { - var scalarNode = _node.Children[new YamlScalarNode(key.GetScalarValue())] as YamlScalarNode; - if (scalarNode == null) + if (_node.Children[new YamlScalarNode(key.GetScalarValue())] is not YamlScalarNode scalarNode) { throw new OpenApiReaderException($"Expected scalar at line {_node.Start.Line} for key {key.GetScalarValue()}", Context); } diff --git a/src/Microsoft.OpenApi.Readers/YamlHelper.cs b/src/Microsoft.OpenApi.Readers/YamlHelper.cs index 90794b080..e49f05e7b 100644 --- a/src/Microsoft.OpenApi.Readers/YamlHelper.cs +++ b/src/Microsoft.OpenApi.Readers/YamlHelper.cs @@ -12,8 +12,7 @@ internal static class YamlHelper { public static string GetScalarValue(this YamlNode node) { - var scalarNode = node as YamlScalarNode; - if (scalarNode == null) + if (node is not YamlScalarNode scalarNode) { throw new OpenApiException($"Expected scalar at line {node.Start.Line}"); } diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs index a0aee12e7..838450cc0 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs @@ -311,8 +311,7 @@ private void Validate(object item, Type type) } // Validate unresolved references as references - var potentialReference = item as IOpenApiReferenceable; - if (potentialReference != null && potentialReference.UnresolvedReference) + if (item is IOpenApiReferenceable potentialReference && potentialReference.UnresolvedReference) { type = typeof(IOpenApiReferenceable); } diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs index eca7bc8de..26d9cf0e3 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs @@ -176,8 +176,7 @@ private static ValidationRuleSet BuildDefaultRuleSet() foreach (var property in rules) { var propertyValue = property.GetValue(null); // static property - ValidationRule rule = propertyValue as ValidationRule; - if (rule != null) + if (propertyValue is ValidationRule rule) { ruleSet.Add(rule); } diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs index 537273cac..08aeb4efd 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs @@ -142,8 +142,7 @@ public static void WriteOptionalObject( { if (value != null) { - var values = value as IEnumerable; - if (values != null && !values.GetEnumerator().MoveNext()) + if (value is IEnumerable values && !values.GetEnumerator().MoveNext()) { return; // Don't render optional empty collections } diff --git a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs index 6d2eafc01..c268dbaf0 100644 --- a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs +++ b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs @@ -45,8 +45,7 @@ public static IEnumerable GetSchemas() var json = JObject.Parse(listJsonStr); foreach (var item in json.Properties()) { - var versions = GetProp(item.Value, "versions") as JObject; - if (versions == null) + if (GetProp(item.Value, "versions") is not JObject versions) continue; foreach (var prop in versions.Properties()) { From a2f6198dd295fbe950e4f98c6edf7370f578432c Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 20:01:24 +1100 Subject: [PATCH 27/69] remove some trailing whitespace --- .../Extensions/CommandExtensions.cs | 2 +- .../Formatters/PowerShellFormatter.cs | 2 +- src/Microsoft.OpenApi.Hidi/Logger.cs | 2 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 6 +++--- .../Options/FilterOptions.cs | 4 ++-- src/Microsoft.OpenApi.Hidi/Options/HidiOptions.cs | 2 +- src/Microsoft.OpenApi.Hidi/StatsVisitor.cs | 2 +- .../Utilities/SettingsUtilities.cs | 2 +- .../Exceptions/OpenApiReaderException.cs | 2 +- .../OpenApiUnsupportedSpecVersionException.cs | 2 +- .../Interface/IDiagnostic.cs | 2 +- .../Interface/IOpenApiReader.cs | 2 +- .../Interface/IOpenApiVersionService.cs | 2 +- .../Interface/IStreamLoader.cs | 2 +- src/Microsoft.OpenApi.Readers/OpenApiDiagnostic.cs | 2 +- .../OpenApiReaderSettings.cs | 14 +++++++------- .../OpenApiStringReader.cs | 2 +- .../OpenApiTextReaderReader.cs | 2 +- .../OpenApiYamlDocumentReader.cs | 2 +- .../ParseNodes/AnyFieldMap.cs | 2 +- .../ParseNodes/AnyFieldMapParameter.cs | 2 +- .../ParseNodes/AnyListFieldMap.cs | 2 +- .../ParseNodes/AnyListFieldMapParameter.cs | 2 +- .../ParseNodes/AnyMapFieldMap.cs | 2 +- .../ParseNodes/AnyMapFieldMapParameter.cs | 2 +- .../ParseNodes/FixedFieldMap.cs | 2 +- .../ParseNodes/JsonPointerExtensions.cs | 2 +- .../ParseNodes/ListNode.cs | 2 +- .../ParseNodes/MapNode.cs | 10 +++++----- .../ParseNodes/OpenApiAnyConverter.cs | 4 ++-- .../ParseNodes/ParseNode.cs | 2 +- .../ParseNodes/PatternFieldMap.cs | 2 +- .../ParseNodes/PropertyNode.cs | 2 +- .../ParseNodes/RootNode.cs | 2 +- .../ParseNodes/ValueNode.cs | 2 +- src/Microsoft.OpenApi.Readers/ParsingContext.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- src/Microsoft.OpenApi.Readers/ReadResult.cs | 2 +- .../Services/DefaultStreamLoader.cs | 2 +- .../Services/OpenApiRemoteReferenceCollector.cs | 6 +++--- .../Services/OpenApiWorkspaceLoader.cs | 2 +- .../V2/OpenApiContactDeserializer.cs | 2 +- .../V2/OpenApiDocumentDeserializer.cs | 4 ++-- .../V2/OpenApiExternalDocsDeserializer.cs | 2 +- .../V2/OpenApiHeaderDeserializer.cs | 8 ++++---- .../V2/OpenApiInfoDeserializer.cs | 2 +- .../V2/OpenApiLicenseDeserializer.cs | 2 +- .../V2/OpenApiOperationDeserializer.cs | 2 +- .../V2/OpenApiParameterDeserializer.cs | 2 +- .../V2/OpenApiPathItemDeserializer.cs | 2 +- .../V2/OpenApiPathsDeserializer.cs | 2 +- .../V2/OpenApiResponseDeserializer.cs | 4 ++-- .../V2/OpenApiSchemaDeserializer.cs | 2 +- .../V2/OpenApiSecurityRequirementDeserializer.cs | 2 +- .../V2/OpenApiSecuritySchemeDeserializer.cs | 2 +- .../V2/OpenApiTagDeserializer.cs | 2 +- .../V2/OpenApiV2Deserializer.cs | 2 +- .../V2/OpenApiV2VersionService.cs | 2 +- .../V2/OpenApiXmlDeserializer.cs | 2 +- .../V2/TempStorageKeys.cs | 2 +- .../V3/OpenApiCallbackDeserializer.cs | 2 +- .../V3/OpenApiComponentsDeserializer.cs | 2 +- .../V3/OpenApiContactDeserializer.cs | 2 +- .../V3/OpenApiDiscriminatorDeserializer.cs | 2 +- .../V3/OpenApiDocumentDeserializer.cs | 2 +- .../V3/OpenApiEncodingDeserializer.cs | 2 +- .../V3/OpenApiExampleDeserializer.cs | 2 +- .../V3/OpenApiExternalDocsDeserializer.cs | 2 +- .../V3/OpenApiHeaderDeserializer.cs | 2 +- .../V3/OpenApiInfoDeserializer.cs | 2 +- .../V3/OpenApiLicenseDeserializer.cs | 2 +- .../V3/OpenApiLinkDeserializer.cs | 2 +- .../V3/OpenApiMediaTypeDeserializer.cs | 2 +- .../V3/OpenApiOAuthFlowDeserializer.cs | 2 +- .../V3/OpenApiOAuthFlowsDeserializer.cs | 2 +- .../V3/OpenApiOperationDeserializer.cs | 2 +- .../V3/OpenApiParameterDeserializer.cs | 2 +- .../V3/OpenApiPathItemDeserializer.cs | 6 +++--- .../V3/OpenApiPathsDeserializer.cs | 2 +- .../V3/OpenApiRequestBodyDeserializer.cs | 2 +- .../V3/OpenApiResponseDeserializer.cs | 2 +- .../V3/OpenApiResponsesDeserializer.cs | 2 +- .../V3/OpenApiSchemaDeserializer.cs | 4 ++-- .../V3/OpenApiSecurityRequirementDeserializer.cs | 2 +- .../V3/OpenApiSecuritySchemeDeserializer.cs | 2 +- .../V3/OpenApiServerDeserializer.cs | 2 +- .../V3/OpenApiServerVariableDeserializer.cs | 2 +- .../V3/OpenApiTagDeserializer.cs | 2 +- .../V3/OpenApiV3Deserializer.cs | 2 +- .../V3/OpenApiV3VersionService.cs | 4 ++-- .../V3/OpenApiXmlDeserializer.cs | 2 +- src/Microsoft.OpenApi.Readers/YamlHelper.cs | 2 +- src/Microsoft.OpenApi.Workbench/App.xaml.cs | 2 +- src/Microsoft.OpenApi.Workbench/MainModel.cs | 6 +++--- src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- src/Microsoft.OpenApi.Workbench/StatsVisitor.cs | 2 +- src/Microsoft.OpenApi/Any/AnyType.cs | 2 +- src/Microsoft.OpenApi/Any/IOpenApiAny.cs | 2 +- src/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiArray.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiBinary.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiBoolean.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiByte.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiDate.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiDateTime.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiDouble.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiFloat.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiInteger.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiLong.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiNull.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiObject.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiPassword.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiString.cs | 4 ++-- .../Attributes/DisplayAttribute.cs | 2 +- src/Microsoft.OpenApi/Error.cs | 2 +- .../Exceptions/OpenApiException.cs | 6 +++--- .../Exceptions/OpenApiWriterException.cs | 2 +- .../Expressions/BodyExpression.cs | 2 +- .../Expressions/CompositeExpression.cs | 2 +- .../Expressions/HeaderExpression.cs | 2 +- .../Expressions/MethodExpression.cs | 2 +- .../Expressions/PathExpression.cs | 2 +- .../Expressions/QueryExpression.cs | 2 +- .../Expressions/RequestExpression.cs | 2 +- .../Expressions/ResponseExpression.cs | 2 +- .../Expressions/RuntimeExpression.cs | 2 +- .../Expressions/SourceExpression.cs | 2 +- .../Expressions/StatusCodeExpression.cs | 2 +- src/Microsoft.OpenApi/Expressions/UrlExpression.cs | 2 +- src/Microsoft.OpenApi/Extensions/EnumExtensions.cs | 2 +- .../Extensions/OpenAPIWriterExtensions.cs | 2 +- .../Extensions/OpenApiElementExtensions.cs | 2 +- .../Extensions/OpenApiExtensibleExtensions.cs | 2 +- .../Extensions/OpenApiReferencableExtensions.cs | 2 +- .../Extensions/OpenApiSerializableExtensions.cs | 4 ++-- .../Extensions/OpenApiTypeMapper.cs | 6 +++--- src/Microsoft.OpenApi/Interfaces/IEffective.cs | 6 +++--- .../Interfaces/IOpenApiElement.cs | 2 +- .../Interfaces/IOpenApiExtensible.cs | 2 +- .../Interfaces/IOpenApiExtension.cs | 2 +- .../Interfaces/IOpenApiReferenceable.cs | 2 +- .../Interfaces/IOpenApiSerializable.cs | 2 +- src/Microsoft.OpenApi/JsonPointer.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiCallback.cs | 4 ++-- src/Microsoft.OpenApi/Models/OpenApiComponents.cs | 4 ++-- src/Microsoft.OpenApi/Models/OpenApiConstants.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiContact.cs | 2 +- .../Models/OpenApiDiscriminator.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 14 +++++++------- src/Microsoft.OpenApi/Models/OpenApiEncoding.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiError.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiExample.cs | 4 ++-- .../Models/OpenApiExtensibleDictionary.cs | 4 ++-- .../Models/OpenApiExternalDocs.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 4 ++-- src/Microsoft.OpenApi/Models/OpenApiInfo.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiLicense.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiLink.cs | 4 ++-- src/Microsoft.OpenApi/Models/OpenApiMediaType.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiOperation.cs | 4 ++-- src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 10 +++++----- src/Microsoft.OpenApi/Models/OpenApiPathItem.cs | 8 ++++---- src/Microsoft.OpenApi/Models/OpenApiPaths.cs | 4 ++-- src/Microsoft.OpenApi/Models/OpenApiReference.cs | 4 ++-- src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs | 6 +++--- src/Microsoft.OpenApi/Models/OpenApiResponse.cs | 4 ++-- src/Microsoft.OpenApi/Models/OpenApiResponses.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 8 ++++---- .../Models/OpenApiSecurityRequirement.cs | 2 +- .../Models/OpenApiSecurityScheme.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiServer.cs | 2 +- .../Models/OpenApiServerVariable.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiTag.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiXml.cs | 2 +- src/Microsoft.OpenApi/Models/OperationType.cs | 2 +- src/Microsoft.OpenApi/Models/ParameterLocation.cs | 2 +- src/Microsoft.OpenApi/Models/ParameterStyle.cs | 2 +- src/Microsoft.OpenApi/Models/ReferenceType.cs | 2 +- .../Models/RuntimeExpressionAnyWrapper.cs | 2 +- src/Microsoft.OpenApi/Models/SecuritySchemeType.cs | 2 +- src/Microsoft.OpenApi/OpenApiFormat.cs | 2 +- src/Microsoft.OpenApi/OpenApiSpecVersion.cs | 4 ++-- src/Microsoft.OpenApi/Properties/AssemblyInfo.cs | 2 +- .../Services/OpenApiReferenceError.cs | 2 +- .../Services/OpenApiReferenceResolver.cs | 2 +- .../Services/OpenApiUrlTreeNode.cs | 4 ++-- .../Services/OpenApiVisitorBase.cs | 4 ++-- src/Microsoft.OpenApi/Services/OpenApiWalker.cs | 4 ++-- src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs | 8 ++++---- .../Validations/IValidationContext.cs | 4 ++-- .../Validations/OpenApiValidatiorWarning.cs | 2 +- .../Validations/OpenApiValidator.cs | 4 ++-- .../Validations/OpenApiValidatorError.cs | 2 +- .../Validations/Rules/OpenApiComponentsRules.cs | 2 +- .../Validations/Rules/OpenApiContactRules.cs | 2 +- .../Validations/Rules/OpenApiDocumentRules.cs | 2 +- .../Validations/Rules/OpenApiExtensionRules.cs | 2 +- .../Validations/Rules/OpenApiExternalDocsRules.cs | 2 +- .../Validations/Rules/OpenApiHeaderRules.cs | 2 +- .../Validations/Rules/OpenApiInfoRules.cs | 2 +- .../Validations/Rules/OpenApiLicenseRules.cs | 2 +- .../Validations/Rules/OpenApiMediaTypeRules.cs | 2 +- .../Validations/Rules/OpenApiOAuthFlowRules.cs | 2 +- .../Validations/Rules/OpenApiParameterRules.cs | 6 +++--- .../Validations/Rules/OpenApiPathsRules.cs | 2 +- .../Validations/Rules/OpenApiResponseRules.cs | 2 +- .../Validations/Rules/OpenApiResponsesRules.cs | 2 +- .../Validations/Rules/OpenApiSchemaRules.cs | 2 +- .../Validations/Rules/OpenApiServerRules.cs | 2 +- .../Validations/Rules/OpenApiTagRules.cs | 2 +- .../Validations/Rules/RuleHelpers.cs | 2 +- .../Validations/ValidationExtensions.cs | 2 +- .../Validations/ValidationRule.cs | 2 +- .../Validations/ValidationRuleSet.cs | 2 +- .../Writers/FormattingStreamWriter.cs | 2 +- src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs | 2 +- src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs | 2 +- .../Writers/OpenApiWriterAnyExtensions.cs | 2 +- src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs | 6 +++--- .../Writers/OpenApiWriterExtensions.cs | 2 +- .../Writers/OpenApiWriterSettings.cs | 4 ++-- src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs | 8 ++++---- src/Microsoft.OpenApi/Writers/Scope.cs | 2 +- .../Writers/SpecialCharacterStringExtensions.cs | 8 ++++---- src/Microsoft.OpenApi/Writers/WriterConstants.cs | 2 +- .../UtilityFiles/OpenApiDocumentMock.cs | 2 +- .../DefaultSettingsFixture.cs | 2 +- .../DefaultSettingsFixtureCollection.cs | 2 +- .../OpenApiReaderTests/OpenApiDiagnosticTests.cs | 2 +- .../UnsupportedSpecVersionTests.cs | 2 +- .../OpenApiWorkspaceStreamTests.cs | 2 +- .../ParseNodeTests.cs | 2 +- .../ParseNodes/OpenApiAnyConverterTests.cs | 2 +- .../ParseNodes/OpenApiAnyTests.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../ConvertToOpenApiReferenceV2Tests.cs | 2 +- .../ConvertToOpenApiReferenceV3Tests.cs | 2 +- .../ReferenceService/TryLoadReferenceV2Tests.cs | 2 +- .../TestCustomExtension.cs | 2 +- test/Microsoft.OpenApi.Readers.Tests/TestHelper.cs | 2 +- .../V2Tests/ComparisonTests.cs | 2 +- .../V2Tests/OpenApiContactTests.cs | 2 +- .../V2Tests/OpenApiDocumentTests.cs | 2 +- .../V2Tests/OpenApiHeaderTests.cs | 2 +- .../V2Tests/OpenApiOperationTests.cs | 2 +- .../V2Tests/OpenApiParameterTests.cs | 2 +- .../V2Tests/OpenApiPathItemTests.cs | 2 +- .../V2Tests/OpenApiSchemaTests.cs | 2 +- .../V2Tests/OpenApiSecuritySchemeTests.cs | 2 +- .../V3Tests/OpenApiCallbackTests.cs | 2 +- .../V3Tests/OpenApiContactTests.cs | 2 +- .../V3Tests/OpenApiDiscriminatorTests.cs | 2 +- .../V3Tests/OpenApiDocumentTests.cs | 2 +- .../V3Tests/OpenApiEncodingTests.cs | 2 +- .../V3Tests/OpenApiExampleTests.cs | 2 +- .../V3Tests/OpenApiInfoTests.cs | 2 +- .../V3Tests/OpenApiMediaTypeTests.cs | 2 +- .../V3Tests/OpenApiOperationTests.cs | 2 +- .../V3Tests/OpenApiParameterTests.cs | 2 +- .../V3Tests/OpenApiSchemaTests.cs | 2 +- .../V3Tests/OpenApiSecuritySchemeTests.cs | 2 +- .../V3Tests/OpenApiXmlTests.cs | 2 +- test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs | 2 +- .../DefaultSettingsFixture.cs | 2 +- .../DefaultSettingsFixtureCollection.cs | 2 +- .../Extensions/OpenApiTypeMapperTests.cs | 4 ++-- .../Models/OpenApiCallbackTests.cs | 2 +- .../Models/OpenApiComponentsTests.cs | 2 +- .../Models/OpenApiContactTests.cs | 2 +- .../Models/OpenApiDocumentTests.cs | 10 +++++----- .../Models/OpenApiEncodingTests.cs | 2 +- .../Models/OpenApiExampleTests.cs | 2 +- .../Models/OpenApiExternalDocsTests.cs | 2 +- .../Models/OpenApiHeaderTests.cs | 2 +- .../Models/OpenApiInfoTests.cs | 2 +- .../Models/OpenApiLicenseTests.cs | 2 +- .../Models/OpenApiLinkTests.cs | 2 +- .../Models/OpenApiMediaTypeTests.cs | 2 +- .../Models/OpenApiOAuthFlowTests.cs | 2 +- .../Models/OpenApiOAuthFlowsTests.cs | 2 +- .../Models/OpenApiOperationTests.cs | 2 +- .../Models/OpenApiParameterTests.cs | 4 ++-- .../Models/OpenApiReferenceTests.cs | 2 +- .../Models/OpenApiRequestBodyTests.cs | 2 +- .../Models/OpenApiResponseTests.cs | 2 +- .../Models/OpenApiSchemaTests.cs | 4 ++-- .../Models/OpenApiSecurityRequirementTests.cs | 2 +- .../Models/OpenApiSecuritySchemeTests.cs | 6 +++--- .../Models/OpenApiServerTests.cs | 2 +- .../Models/OpenApiServerVariableTests.cs | 2 +- .../Models/OpenApiTagTests.cs | 2 +- .../Models/OpenApiXmlTests.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../Services/OpenApiValidatorTests.cs | 2 +- test/Microsoft.OpenApi.Tests/StringExtensions.cs | 2 +- .../OpenApiComponentsValidationTests.cs | 2 +- .../Validations/OpenApiContactValidationTests.cs | 2 +- .../OpenApiExternalDocsValidationTests.cs | 2 +- .../Validations/OpenApiHeaderValidationTests.cs | 2 +- .../Validations/OpenApiInfoValidationTests.cs | 2 +- .../Validations/OpenApiLicenseValidationTests.cs | 2 +- .../Validations/OpenApiMediaTypeValidationTests.cs | 2 +- .../Validations/OpenApiOAuthFlowValidationTests.cs | 2 +- .../Validations/OpenApiParameterValidationTests.cs | 2 +- .../Validations/OpenApiReferenceValidationTests.cs | 2 +- .../Validations/OpenApiResponseValidationTests.cs | 2 +- .../Validations/OpenApiSchemaValidationTests.cs | 6 +++--- .../Validations/OpenApiServerValidationTests.cs | 2 +- .../Validations/OpenApiTagValidationTests.cs | 2 +- .../Walkers/WalkerLocationTests.cs | 2 +- .../Workspaces/OpenApiReferencableTests.cs | 2 +- .../Writers/OpenApiJsonWriterTests.cs | 2 +- .../Writers/OpenApiWriterAnyExtensionsTests.cs | 4 ++-- .../Writers/OpenApiWriterSpecialCharacterTests.cs | 2 +- .../Writers/OpenApiYamlWriterTests.cs | 2 +- 320 files changed, 415 insertions(+), 415 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs b/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs index 9d5077432..5b83212d5 100644 --- a/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs +++ b/src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.CommandLine; diff --git a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs index 4db55a05e..260119188 100644 --- a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs +++ b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs @@ -24,7 +24,7 @@ static PowerShellFormatter() { // Add singularization exclusions. // Enhancement: Read exclusions from a user provided file. - Vocabularies.Default.AddSingular("(drive)s$", "$1"); // drives does not properly singularize to drive. + Vocabularies.Default.AddSingular("(drive)s$", "$1"); // drives does not properly singularize to drive. Vocabularies.Default.AddSingular("(data)$", "$1"); // exclude the following from singularization. Vocabularies.Default.AddSingular("(delta)$", "$1"); Vocabularies.Default.AddSingular("(quota)$", "$1"); diff --git a/src/Microsoft.OpenApi.Hidi/Logger.cs b/src/Microsoft.OpenApi.Hidi/Logger.cs index 717ca1a41..dec4a5f8e 100644 --- a/src/Microsoft.OpenApi.Hidi/Logger.cs +++ b/src/Microsoft.OpenApi.Hidi/Logger.cs @@ -21,7 +21,7 @@ public static ILoggerFactory ConfigureLogger(LogLevel logLevel) { c.IncludeScopes = true; }) -#if DEBUG +#if DEBUG .AddDebug() #endif .SetMinimumLevel(logLevel); diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index d698bd5b2..fc70d409b 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -154,7 +154,7 @@ private static OpenApiDocument ApplyFilters(HidiOptions options, ILogger logger, requestUrls = EnumerateJsonDocument(postmanCollection.RootElement, new()); logger.LogTrace("Finished fetching the list of paths and Http methods defined in the Postman collection."); } - else + else { requestUrls = new(); logger.LogTrace("No filter options provided."); @@ -211,7 +211,7 @@ private static void WriteOpenApi(HidiOptions options, OpenApiFormat openApiForma } } - // Get OpenAPI document either from OpenAPI or CSDL + // Get OpenAPI document either from OpenAPI or CSDL private static async Task GetOpenApi(HidiOptions options, ILogger logger, CancellationToken cancellationToken, string? metadataVersion = null) { @@ -285,7 +285,7 @@ private static async Task GetOpenApi(HidiOptions options, ILogg private static Dictionary> GetRequestUrlsFromManifest(ApiDependency apiDependency) { - // Get the request URLs from the API Dependencies in the API manifest + // Get the request URLs from the API Dependencies in the API manifest var requests = apiDependency .Requests.Where(static r => !r.Exclude && !string.IsNullOrEmpty(r.UriTemplate) && !string.IsNullOrEmpty(r.Method)) .Select(static r => new { UriTemplate = r.UriTemplate!, Method = r.Method! }) diff --git a/src/Microsoft.OpenApi.Hidi/Options/FilterOptions.cs b/src/Microsoft.OpenApi.Hidi/Options/FilterOptions.cs index d82a064f7..1abf5a6bf 100644 --- a/src/Microsoft.OpenApi.Hidi/Options/FilterOptions.cs +++ b/src/Microsoft.OpenApi.Hidi/Options/FilterOptions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Hidi.Options { @@ -8,6 +8,6 @@ internal class FilterOptions public string? FilterByOperationIds { get; internal set; } public string? FilterByTags { get; internal set; } public string? FilterByCollection { get; internal set; } - public string? FilterByApiManifest { get; internal set; } + public string? FilterByApiManifest { get; internal set; } } } diff --git a/src/Microsoft.OpenApi.Hidi/Options/HidiOptions.cs b/src/Microsoft.OpenApi.Hidi/Options/HidiOptions.cs index 9f5a109f7..9b12b73f3 100644 --- a/src/Microsoft.OpenApi.Hidi/Options/HidiOptions.cs +++ b/src/Microsoft.OpenApi.Hidi/Options/HidiOptions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.CommandLine.Parsing; using System.IO; diff --git a/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs b/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs index 871f88dca..b6af07778 100644 --- a/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs +++ b/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs b/src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs index 6264270a6..6ec32f488 100644 --- a/src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs +++ b/src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.Extensions.Configuration; using Microsoft.OpenApi.OData; diff --git a/src/Microsoft.OpenApi.Readers/Exceptions/OpenApiReaderException.cs b/src/Microsoft.OpenApi.Readers/Exceptions/OpenApiReaderException.cs index e90137ad3..36db10127 100644 --- a/src/Microsoft.OpenApi.Readers/Exceptions/OpenApiReaderException.cs +++ b/src/Microsoft.OpenApi.Readers/Exceptions/OpenApiReaderException.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Exceptions; diff --git a/src/Microsoft.OpenApi.Readers/Exceptions/OpenApiUnsupportedSpecVersionException.cs b/src/Microsoft.OpenApi.Readers/Exceptions/OpenApiUnsupportedSpecVersionException.cs index 705b212d0..2d125c259 100644 --- a/src/Microsoft.OpenApi.Readers/Exceptions/OpenApiUnsupportedSpecVersionException.cs +++ b/src/Microsoft.OpenApi.Readers/Exceptions/OpenApiUnsupportedSpecVersionException.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Globalization; diff --git a/src/Microsoft.OpenApi.Readers/Interface/IDiagnostic.cs b/src/Microsoft.OpenApi.Readers/Interface/IDiagnostic.cs index da3381f7e..65511ce11 100644 --- a/src/Microsoft.OpenApi.Readers/Interface/IDiagnostic.cs +++ b/src/Microsoft.OpenApi.Readers/Interface/IDiagnostic.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Readers.Interface { diff --git a/src/Microsoft.OpenApi.Readers/Interface/IOpenApiReader.cs b/src/Microsoft.OpenApi.Readers/Interface/IOpenApiReader.cs index 39724b3c6..8991c9b59 100644 --- a/src/Microsoft.OpenApi.Readers/Interface/IOpenApiReader.cs +++ b/src/Microsoft.OpenApi.Readers/Interface/IOpenApiReader.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/Interface/IOpenApiVersionService.cs b/src/Microsoft.OpenApi.Readers/Interface/IOpenApiVersionService.cs index a7a98d781..a3b3c7fa5 100644 --- a/src/Microsoft.OpenApi.Readers/Interface/IOpenApiVersionService.cs +++ b/src/Microsoft.OpenApi.Readers/Interface/IOpenApiVersionService.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Interfaces; diff --git a/src/Microsoft.OpenApi.Readers/Interface/IStreamLoader.cs b/src/Microsoft.OpenApi.Readers/Interface/IStreamLoader.cs index b93c69f39..b3c0c4613 100644 --- a/src/Microsoft.OpenApi.Readers/Interface/IStreamLoader.cs +++ b/src/Microsoft.OpenApi.Readers/Interface/IStreamLoader.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.IO; diff --git a/src/Microsoft.OpenApi.Readers/OpenApiDiagnostic.cs b/src/Microsoft.OpenApi.Readers/OpenApiDiagnostic.cs index 0ffac77e7..1c70db887 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiDiagnostic.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiDiagnostic.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs b/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs index 25bcbca6f..71a18e137 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs @@ -80,7 +80,7 @@ public class OpenApiReaderSettings /// from an object. /// public bool LeaveStreamOpen { get; set; } - + /// /// Adds parsers for Microsoft OpenAPI extensions: /// - @@ -93,17 +93,17 @@ public class OpenApiReaderSettings /// public void AddMicrosoftExtensionParsers() { - if (!ExtensionParsers.ContainsKey(OpenApiPagingExtension.Name)) + if (!ExtensionParsers.ContainsKey(OpenApiPagingExtension.Name)) ExtensionParsers.Add(OpenApiPagingExtension.Name, static (i, _) => OpenApiPagingExtension.Parse(i)); - if (!ExtensionParsers.ContainsKey(OpenApiEnumValuesDescriptionExtension.Name)) + if (!ExtensionParsers.ContainsKey(OpenApiEnumValuesDescriptionExtension.Name)) ExtensionParsers.Add(OpenApiEnumValuesDescriptionExtension.Name, static (i, _ ) => OpenApiEnumValuesDescriptionExtension.Parse(i)); - if (!ExtensionParsers.ContainsKey(OpenApiPrimaryErrorMessageExtension.Name)) + if (!ExtensionParsers.ContainsKey(OpenApiPrimaryErrorMessageExtension.Name)) ExtensionParsers.Add(OpenApiPrimaryErrorMessageExtension.Name, static (i, _ ) => OpenApiPrimaryErrorMessageExtension.Parse(i)); - if (!ExtensionParsers.ContainsKey(OpenApiDeprecationExtension.Name)) + if (!ExtensionParsers.ContainsKey(OpenApiDeprecationExtension.Name)) ExtensionParsers.Add(OpenApiDeprecationExtension.Name, static (i, _ ) => OpenApiDeprecationExtension.Parse(i)); - if (!ExtensionParsers.ContainsKey(OpenApiReservedParameterExtension.Name)) + if (!ExtensionParsers.ContainsKey(OpenApiReservedParameterExtension.Name)) ExtensionParsers.Add(OpenApiReservedParameterExtension.Name, static (i, _ ) => OpenApiReservedParameterExtension.Parse(i)); - if (!ExtensionParsers.ContainsKey(OpenApiEnumFlagsExtension.Name)) + if (!ExtensionParsers.ContainsKey(OpenApiEnumFlagsExtension.Name)) ExtensionParsers.Add(OpenApiEnumFlagsExtension.Name, static (i, _ ) => OpenApiEnumFlagsExtension.Parse(i)); } } diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStringReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStringReader.cs index 0cb9605dd..0d2dbd241 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStringReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStringReader.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using Microsoft.OpenApi.Interfaces; diff --git a/src/Microsoft.OpenApi.Readers/OpenApiTextReaderReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiTextReaderReader.cs index d6722d440..74566fd58 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiTextReaderReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiTextReaderReader.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using System.Linq; diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs index 5537366d0..4f9dee12c 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyFieldMap.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyFieldMap.cs index a135f7f02..479417bdb 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyFieldMap.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyFieldMap.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyFieldMapParameter.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyFieldMapParameter.cs index 30aa0dbca..515a6e174 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyFieldMapParameter.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyFieldMapParameter.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Any; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyListFieldMap.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyListFieldMap.cs index dbc9eabeb..dcec81bb6 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyListFieldMap.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyListFieldMap.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyListFieldMapParameter.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyListFieldMapParameter.cs index cfa1c3702..aed34cf60 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyListFieldMapParameter.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyListFieldMapParameter.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMap.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMap.cs index abd4f4466..e6b2a7b08 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMap.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMap.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMapParameter.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMapParameter.cs index 1aa899978..49fc65dcb 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMapParameter.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/AnyMapFieldMapParameter.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/FixedFieldMap.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/FixedFieldMap.cs index 50cc5e4b7..4364cf1df 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/FixedFieldMap.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/FixedFieldMap.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/JsonPointerExtensions.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/JsonPointerExtensions.cs index d30863955..39e53933a 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/JsonPointerExtensions.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/JsonPointerExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using SharpYaml.Serialization; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/ListNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/ListNode.cs index d11ff4c04..bbc9e30b8 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/ListNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/ListNode.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs index 92c49726b..ee92938c4 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections; @@ -67,7 +67,7 @@ public override Dictionary CreateMap(Func map) var nodes = yamlMap.Select( n => { - + var key = n.Key.GetScalarValue(); T value; try @@ -76,7 +76,7 @@ public override Dictionary CreateMap(Func map) value = n.Value as YamlMappingNode == null ? default(T) : map(new MapNode(Context, n.Value as YamlMappingNode)); - } + } finally { Context.EndObject(); @@ -93,7 +93,7 @@ public override Dictionary CreateMap(Func map) public override Dictionary CreateMapWithReference( ReferenceType referenceType, - Func map) + Func map) { var yamlMap = _node; if (yamlMap == null) @@ -141,7 +141,7 @@ public override Dictionary CreateSimpleMap(Func map) { var yamlMap = _node; if (yamlMap == null) - { + { throw new OpenApiReaderException($"Expected map while parsing {typeof(T).Name}", Context); } diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs index 01aef7652..f17cf251c 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Globalization; @@ -260,7 +260,7 @@ public static IOpenApiAny GetSpecificOpenApiAny(IOpenApiAny openApiAny, OpenApiS } // If data conflicts with the given type, return a string. - // This converter is used in the parser, so it does not perform any validations, + // This converter is used in the parser, so it does not perform any validations, // but the validator can be used to validate whether the data and given type conflicts. return openApiAny; } diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs index 295b02bf3..174f5a2cf 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/PatternFieldMap.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/PatternFieldMap.cs index bbd153688..8fb28bc5e 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/PatternFieldMap.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/PatternFieldMap.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/PropertyNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/PropertyNode.cs index 2dd2c7e8a..b53c1d405 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/PropertyNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/PropertyNode.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/RootNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/RootNode.cs index 42909bee6..d9f18603f 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/RootNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/RootNode.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using SharpYaml.Serialization; diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs index bbce7a7d3..8b4de6c1a 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Readers.Exceptions; diff --git a/src/Microsoft.OpenApi.Readers/ParsingContext.cs b/src/Microsoft.OpenApi.Readers/ParsingContext.cs index afc76bcf5..ffef15904 100644 --- a/src/Microsoft.OpenApi.Readers/ParsingContext.cs +++ b/src/Microsoft.OpenApi.Readers/ParsingContext.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/Properties/AssemblyInfo.cs b/src/Microsoft.OpenApi.Readers/Properties/AssemblyInfo.cs index b42e91bd1..554e1aad8 100644 --- a/src/Microsoft.OpenApi.Readers/Properties/AssemblyInfo.cs +++ b/src/Microsoft.OpenApi.Readers/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Runtime.CompilerServices; diff --git a/src/Microsoft.OpenApi.Readers/ReadResult.cs b/src/Microsoft.OpenApi.Readers/ReadResult.cs index 7479d345f..b1ddcb712 100644 --- a/src/Microsoft.OpenApi.Readers/ReadResult.cs +++ b/src/Microsoft.OpenApi.Readers/ReadResult.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs b/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs index 09f16632b..10d8d1d93 100644 --- a/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs +++ b/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.IO; diff --git a/src/Microsoft.OpenApi.Readers/Services/OpenApiRemoteReferenceCollector.cs b/src/Microsoft.OpenApi.Readers/Services/OpenApiRemoteReferenceCollector.cs index 9a5ba9213..d7ee0ca13 100644 --- a/src/Microsoft.OpenApi.Readers/Services/OpenApiRemoteReferenceCollector.cs +++ b/src/Microsoft.OpenApi.Readers/Services/OpenApiRemoteReferenceCollector.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; @@ -31,7 +31,7 @@ public IEnumerable References } /// - /// Collect reference for each reference + /// Collect reference for each reference /// /// public override void Visit(IOpenApiReferenceable referenceable) @@ -54,6 +54,6 @@ private void AddReference(OpenApiReference reference) } } } - } + } } } diff --git a/src/Microsoft.OpenApi.Readers/Services/OpenApiWorkspaceLoader.cs b/src/Microsoft.OpenApi.Readers/Services/OpenApiWorkspaceLoader.cs index 79f6206d0..b98982f8c 100644 --- a/src/Microsoft.OpenApi.Readers/Services/OpenApiWorkspaceLoader.cs +++ b/src/Microsoft.OpenApi.Readers/Services/OpenApiWorkspaceLoader.cs @@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Readers.Services { - internal class OpenApiWorkspaceLoader + internal class OpenApiWorkspaceLoader { private OpenApiWorkspace _workspace; private IStreamLoader _loader; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiContactDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiContactDeserializer.cs index 99bc4451a..c25f5d0c8 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiContactDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiContactDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs index 806c96877..4e4f000d6 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -300,7 +300,7 @@ private static void FixRequestBodyReferences(OpenApiDocument doc) private static bool IsHostValid(string host) { - //Check if the host contains :// + //Check if the host contains :// if (host.Contains(Uri.SchemeDelimiter)) { return false; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiExternalDocsDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiExternalDocsDeserializer.cs index eea726777..b773fd784 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiExternalDocsDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiExternalDocsDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiHeaderDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiHeaderDeserializer.cs index 5d6cc2ff3..821e08a26 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiHeaderDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiHeaderDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Globalization; @@ -140,10 +140,10 @@ internal static partial class OpenApiV2Deserializer OpenApiConstants.Default, new AnyFieldMapParameter( p => p.Schema?.Default, - (p, v) => + (p, v) => { if(p.Schema == null) return; - p.Schema.Default = v; + p.Schema.Default = v; }, p => p.Schema) } @@ -159,7 +159,7 @@ internal static partial class OpenApiV2Deserializer (p, v) => { if(p.Schema == null) return; - p.Schema.Enum = v; + p.Schema.Enum = v; }, p => p.Schema) }, diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiInfoDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiInfoDeserializer.cs index 5854672d3..0da2034ec 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiInfoDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiInfoDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiLicenseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiLicenseDeserializer.cs index 4c4009f57..6a7445e73 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiLicenseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiLicenseDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs index cf54df8c3..e2be3ea6a 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs index 5be08c71e..aea3b62df 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiParameterDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs index d9db5a8d8..5b6222e27 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiPathsDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiPathsDeserializer.cs index 2aa5de979..611eee485 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiPathsDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiPathsDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs index 182def419..0f340c947 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Extensions; @@ -81,7 +81,7 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P foreach (var produce in produces) { - if (response.Content.TryGetValue(produce, out var produceValue)) + if (response.Content.TryGetValue(produce, out var produceValue)) { if (schema != null) { diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiSchemaDeserializer.cs index 0878eda9a..2a0c71a72 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiSchemaDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Globalization; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs index c8384fb05..5197b6e1e 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs index b2aab773c..20de9c880 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiTagDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiTagDeserializer.cs index 12fae8660..ecd6c96c3 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiTagDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiTagDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2Deserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2Deserializer.cs index c3f26b896..6b7aea308 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2Deserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2Deserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs index 54b0a3776..cc59aebcb 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiXmlDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiXmlDeserializer.cs index ac7db2db6..47a321dbe 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiXmlDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiXmlDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Exceptions; diff --git a/src/Microsoft.OpenApi.Readers/V2/TempStorageKeys.cs b/src/Microsoft.OpenApi.Readers/V2/TempStorageKeys.cs index 5a216e086..c7b96f6ce 100644 --- a/src/Microsoft.OpenApi.Readers/V2/TempStorageKeys.cs +++ b/src/Microsoft.OpenApi.Readers/V2/TempStorageKeys.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Readers.V2 { diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiCallbackDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiCallbackDeserializer.cs index af1376580..c400e8b5b 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiCallbackDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiCallbackDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Expressions; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiComponentsDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiComponentsDeserializer.cs index 30d711d33..91ad2bcd8 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiComponentsDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiComponentsDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiContactDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiContactDeserializer.cs index 151a12354..2dfddfb3b 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiContactDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiContactDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiDiscriminatorDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiDiscriminatorDeserializer.cs index 867057d32..ec3267883 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiDiscriminatorDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiDiscriminatorDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs index d5c437148..b010f1e41 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Any; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs index fc2f990e7..d6d7a8844 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiExampleDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiExampleDeserializer.cs index 1e114ad73..264a1f8cc 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiExampleDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiExampleDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiExternalDocsDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiExternalDocsDeserializer.cs index 920b84192..1ea16f616 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiExternalDocsDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiExternalDocsDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiHeaderDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiHeaderDeserializer.cs index 1616d67f0..f7cd90aca 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiHeaderDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiHeaderDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiInfoDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiInfoDeserializer.cs index d5de92852..8ccbf6d69 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiInfoDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiInfoDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiLicenseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiLicenseDeserializer.cs index 3c38d8b9a..6a27b1286 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiLicenseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiLicenseDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiLinkDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiLinkDeserializer.cs index 7bf4c650b..9eae96b72 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiLinkDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiLinkDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs index c8bd3d240..68b6a4895 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiOAuthFlowDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiOAuthFlowDeserializer.cs index 2653ce631..1679cdf75 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiOAuthFlowDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiOAuthFlowDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiOAuthFlowsDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiOAuthFlowsDeserializer.cs index bd19f2716..9269048aa 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiOAuthFlowsDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiOAuthFlowsDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs index d6cd2e387..dee61cef6 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiParameterDeserializer.cs index e8fad07a5..c291132ca 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiParameterDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Linq; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs index 698fe64cc..8e97e1377 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; @@ -15,12 +15,12 @@ internal static partial class OpenApiV3Deserializer { private static readonly FixedFieldMap _pathItemFixedFields = new FixedFieldMap { - + { "$ref", (o,n) => { o.Reference = new OpenApiReference { ExternalResource = n.GetScalarValue() }; o.UnresolvedReference =true; - } + } }, { "summary", (o, n) => diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiPathsDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiPathsDeserializer.cs index fcfad096c..5b0b9485b 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiPathsDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiPathsDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiRequestBodyDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiRequestBodyDeserializer.cs index a2633028e..c5c2fab91 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiRequestBodyDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiRequestBodyDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiResponseDeserializer.cs index 70ea0c9bf..73f20791a 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiResponseDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiResponsesDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiResponsesDeserializer.cs index 9fe4d075f..597e8a4b6 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiResponsesDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiResponsesDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs index e5482e22f..993195709 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; @@ -27,7 +27,7 @@ internal static partial class OpenApiV3Deserializer { "multipleOf", (o, n) => { - o.MultipleOf = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); + o.MultipleOf = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture); } }, { diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs index ed8322622..4a609125e 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs index dd6ad4751..a5f50eb3f 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiServerDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiServerDeserializer.cs index e278abc90..81e92b979 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiServerDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiServerDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiServerVariableDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiServerVariableDeserializer.cs index 9b6acbc8d..fa4d07d72 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiServerVariableDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiServerVariableDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiTagDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiTagDeserializer.cs index 6a987969b..9de8bf610 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiTagDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiTagDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3Deserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3Deserializer.cs index 9689c8fe1..ac3463167 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3Deserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3Deserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index 60ce71c8a..a6cb41970 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -121,7 +121,7 @@ public OpenApiReference ConvertToOpenApiReference( if (type == null) { type = referencedType; - } + } else { if (type != referencedType) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiXmlDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiXmlDeserializer.cs index dc05da1c2..95cc2a585 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiXmlDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiXmlDeserializer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi.Readers/YamlHelper.cs b/src/Microsoft.OpenApi.Readers/YamlHelper.cs index 90794b080..7b78e968e 100644 --- a/src/Microsoft.OpenApi.Readers/YamlHelper.cs +++ b/src/Microsoft.OpenApi.Readers/YamlHelper.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using System.Linq; diff --git a/src/Microsoft.OpenApi.Workbench/App.xaml.cs b/src/Microsoft.OpenApi.Workbench/App.xaml.cs index d3fc6dcb7..de1f426f5 100644 --- a/src/Microsoft.OpenApi.Workbench/App.xaml.cs +++ b/src/Microsoft.OpenApi.Workbench/App.xaml.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Windows; diff --git a/src/Microsoft.OpenApi.Workbench/MainModel.cs b/src/Microsoft.OpenApi.Workbench/MainModel.cs index 0d0d689ec..cd1461462 100644 --- a/src/Microsoft.OpenApi.Workbench/MainModel.cs +++ b/src/Microsoft.OpenApi.Workbench/MainModel.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.ComponentModel; @@ -40,7 +40,7 @@ public class MainModel : INotifyPropertyChanged private string _renderTime; - + /// /// Default format. /// @@ -215,7 +215,7 @@ internal async Task ParseDocument() if (_inputFile.StartsWith("http")) { stream = await _httpClient.GetStreamAsync(_inputFile); - } + } else { stream = new FileStream(_inputFile, FileMode.Open); diff --git a/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs b/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs index 08bbb177d..0d2f74582 100644 --- a/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs +++ b/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Windows; diff --git a/src/Microsoft.OpenApi.Workbench/Properties/AssemblyInfo.cs b/src/Microsoft.OpenApi.Workbench/Properties/AssemblyInfo.cs index b9a41106f..0add485f6 100644 --- a/src/Microsoft.OpenApi.Workbench/Properties/AssemblyInfo.cs +++ b/src/Microsoft.OpenApi.Workbench/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Reflection; using System.Runtime.InteropServices; diff --git a/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs b/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs index 85faef630..226b873d3 100644 --- a/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs +++ b/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Any/AnyType.cs b/src/Microsoft.OpenApi/Any/AnyType.cs index d0addd808..3ac617e8a 100644 --- a/src/Microsoft.OpenApi/Any/AnyType.cs +++ b/src/Microsoft.OpenApi/Any/AnyType.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { diff --git a/src/Microsoft.OpenApi/Any/IOpenApiAny.cs b/src/Microsoft.OpenApi/Any/IOpenApiAny.cs index 26c5f4d87..ece675508 100644 --- a/src/Microsoft.OpenApi/Any/IOpenApiAny.cs +++ b/src/Microsoft.OpenApi/Any/IOpenApiAny.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Interfaces; diff --git a/src/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs b/src/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs index 0e286d1a4..039782852 100644 --- a/src/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs +++ b/src/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { diff --git a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs index e34fb8cbf..5cfded2b6 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs @@ -27,7 +27,7 @@ public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj) { return (IOpenApiAny)ci.Invoke(new object[] { obj }); } - } + } } return obj; diff --git a/src/Microsoft.OpenApi/Any/OpenApiArray.cs b/src/Microsoft.OpenApi/Any/OpenApiArray.cs index 2c877d631..1a4edf3bb 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiArray.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiArray.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Writers; using System; diff --git a/src/Microsoft.OpenApi/Any/OpenApiBinary.cs b/src/Microsoft.OpenApi/Any/OpenApiBinary.cs index da1bedad8..9933159a1 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiBinary.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiBinary.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { diff --git a/src/Microsoft.OpenApi/Any/OpenApiBoolean.cs b/src/Microsoft.OpenApi/Any/OpenApiBoolean.cs index f531e0135..10595f606 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiBoolean.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiBoolean.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { diff --git a/src/Microsoft.OpenApi/Any/OpenApiByte.cs b/src/Microsoft.OpenApi/Any/OpenApiByte.cs index 5e91b888e..48e9708d8 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiByte.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiByte.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { diff --git a/src/Microsoft.OpenApi/Any/OpenApiDate.cs b/src/Microsoft.OpenApi/Any/OpenApiDate.cs index c285799b6..485029133 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiDate.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiDate.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; diff --git a/src/Microsoft.OpenApi/Any/OpenApiDateTime.cs b/src/Microsoft.OpenApi/Any/OpenApiDateTime.cs index 81b647288..5fdaacf7c 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiDateTime.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiDateTime.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; diff --git a/src/Microsoft.OpenApi/Any/OpenApiDouble.cs b/src/Microsoft.OpenApi/Any/OpenApiDouble.cs index 35711a191..f1adb6799 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiDouble.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiDouble.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { diff --git a/src/Microsoft.OpenApi/Any/OpenApiFloat.cs b/src/Microsoft.OpenApi/Any/OpenApiFloat.cs index 3a64fb04c..e9b810331 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiFloat.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiFloat.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { diff --git a/src/Microsoft.OpenApi/Any/OpenApiInteger.cs b/src/Microsoft.OpenApi/Any/OpenApiInteger.cs index a0aa88fe8..7f7a32253 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiInteger.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiInteger.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { diff --git a/src/Microsoft.OpenApi/Any/OpenApiLong.cs b/src/Microsoft.OpenApi/Any/OpenApiLong.cs index 30b42fbf3..4168b91bd 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiLong.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiLong.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { diff --git a/src/Microsoft.OpenApi/Any/OpenApiNull.cs b/src/Microsoft.OpenApi/Any/OpenApiNull.cs index f1772c3e4..b606d98e1 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiNull.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiNull.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Any/OpenApiObject.cs b/src/Microsoft.OpenApi/Any/OpenApiObject.cs index d7e56e341..c33cbb1c0 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiObject.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiObject.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Any/OpenApiPassword.cs b/src/Microsoft.OpenApi/Any/OpenApiPassword.cs index aaa56e72b..dab7e7979 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiPassword.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiPassword.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { diff --git a/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs b/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs index b8dcf097d..11c92ce96 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Text; diff --git a/src/Microsoft.OpenApi/Any/OpenApiString.cs b/src/Microsoft.OpenApi/Any/OpenApiString.cs index a899bd301..c71cbb840 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiString.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiString.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Any { @@ -19,7 +19,7 @@ public OpenApiString(string value) : this(value, false) { } - + /// /// Initializes the class. /// diff --git a/src/Microsoft.OpenApi/Attributes/DisplayAttribute.cs b/src/Microsoft.OpenApi/Attributes/DisplayAttribute.cs index db60448ea..a77b914cf 100644 --- a/src/Microsoft.OpenApi/Attributes/DisplayAttribute.cs +++ b/src/Microsoft.OpenApi/Attributes/DisplayAttribute.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; diff --git a/src/Microsoft.OpenApi/Error.cs b/src/Microsoft.OpenApi/Error.cs index d0c41780d..9ad76ce54 100644 --- a/src/Microsoft.OpenApi/Error.cs +++ b/src/Microsoft.OpenApi/Error.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Globalization; diff --git a/src/Microsoft.OpenApi/Exceptions/OpenApiException.cs b/src/Microsoft.OpenApi/Exceptions/OpenApiException.cs index cc6fc9d46..71404d1e0 100644 --- a/src/Microsoft.OpenApi/Exceptions/OpenApiException.cs +++ b/src/Microsoft.OpenApi/Exceptions/OpenApiException.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Properties; @@ -40,10 +40,10 @@ public OpenApiException(string message, Exception innerException) /// /// The reference pointer. This is a fragment identifier used to point to where the error occurred in the document. - /// If the document has been parsed as JSON/YAML then the identifier will be a + /// If the document has been parsed as JSON/YAML then the identifier will be a /// JSON Pointer as per https://tools.ietf.org/html/rfc6901 /// If the document fails to parse as JSON/YAML then the fragment will be based on - /// a text/plain pointer as defined in https://tools.ietf.org/html/rfc5147 + /// a text/plain pointer as defined in https://tools.ietf.org/html/rfc5147 /// Currently only line= is provided because using char= causes tests to break due to CR/LF and LF differences /// public string Pointer { get; set; } diff --git a/src/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs b/src/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs index 494608b1f..9e0540c53 100644 --- a/src/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs +++ b/src/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Properties; diff --git a/src/Microsoft.OpenApi/Expressions/BodyExpression.cs b/src/Microsoft.OpenApi/Expressions/BodyExpression.cs index cd5c86bd9..92344dbf7 100644 --- a/src/Microsoft.OpenApi/Expressions/BodyExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/BodyExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Expressions { diff --git a/src/Microsoft.OpenApi/Expressions/CompositeExpression.cs b/src/Microsoft.OpenApi/Expressions/CompositeExpression.cs index 7d5e32c7d..98c5e069c 100644 --- a/src/Microsoft.OpenApi/Expressions/CompositeExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/CompositeExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; diff --git a/src/Microsoft.OpenApi/Expressions/HeaderExpression.cs b/src/Microsoft.OpenApi/Expressions/HeaderExpression.cs index f6642cb08..4bb53f94c 100644 --- a/src/Microsoft.OpenApi/Expressions/HeaderExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/HeaderExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Expressions { diff --git a/src/Microsoft.OpenApi/Expressions/MethodExpression.cs b/src/Microsoft.OpenApi/Expressions/MethodExpression.cs index 865d9c7ff..13173f7e2 100644 --- a/src/Microsoft.OpenApi/Expressions/MethodExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/MethodExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Expressions { diff --git a/src/Microsoft.OpenApi/Expressions/PathExpression.cs b/src/Microsoft.OpenApi/Expressions/PathExpression.cs index a92c8a569..85ec5baac 100644 --- a/src/Microsoft.OpenApi/Expressions/PathExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/PathExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Expressions { diff --git a/src/Microsoft.OpenApi/Expressions/QueryExpression.cs b/src/Microsoft.OpenApi/Expressions/QueryExpression.cs index 3277233b3..53e86d4ba 100644 --- a/src/Microsoft.OpenApi/Expressions/QueryExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/QueryExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Expressions { diff --git a/src/Microsoft.OpenApi/Expressions/RequestExpression.cs b/src/Microsoft.OpenApi/Expressions/RequestExpression.cs index 7ebf77471..4aa923b8c 100644 --- a/src/Microsoft.OpenApi/Expressions/RequestExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/RequestExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Expressions { diff --git a/src/Microsoft.OpenApi/Expressions/ResponseExpression.cs b/src/Microsoft.OpenApi/Expressions/ResponseExpression.cs index b91370297..212282f2d 100644 --- a/src/Microsoft.OpenApi/Expressions/ResponseExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/ResponseExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Expressions { diff --git a/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs b/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs index 965572dfd..d4a116943 100644 --- a/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Exceptions; diff --git a/src/Microsoft.OpenApi/Expressions/SourceExpression.cs b/src/Microsoft.OpenApi/Expressions/SourceExpression.cs index 3bc642473..2e55ece90 100644 --- a/src/Microsoft.OpenApi/Expressions/SourceExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/SourceExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Properties; diff --git a/src/Microsoft.OpenApi/Expressions/StatusCodeExpression.cs b/src/Microsoft.OpenApi/Expressions/StatusCodeExpression.cs index 88a384781..d077c82ad 100644 --- a/src/Microsoft.OpenApi/Expressions/StatusCodeExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/StatusCodeExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Expressions { diff --git a/src/Microsoft.OpenApi/Expressions/UrlExpression.cs b/src/Microsoft.OpenApi/Expressions/UrlExpression.cs index 4dc10bb77..e8da5710f 100644 --- a/src/Microsoft.OpenApi/Expressions/UrlExpression.cs +++ b/src/Microsoft.OpenApi/Expressions/UrlExpression.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Expressions { diff --git a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs index d7c778c19..4e2e795d3 100644 --- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Linq; diff --git a/src/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs index a32807ab6..672730339 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs @@ -14,7 +14,7 @@ internal static class OpenAPIWriterExtensions /// /// /// - internal static OpenApiWriterSettings GetSettings(this IOpenApiWriter openApiWriter) + internal static OpenApiWriterSettings GetSettings(this IOpenApiWriter openApiWriter) { if (openApiWriter is OpenApiWriterBase) { diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs index a047c066d..38a53ecec 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs index 7656aad89..9cb3f21ed 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Interfaces; diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs index 11fcd7e9e..defe95636 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs index f60c5483b..c39e378f6 100755 --- a/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Globalization; using System.IO; @@ -74,7 +74,7 @@ public static void Serialize( this T element, Stream stream, OpenApiSpecVersion specVersion, - OpenApiFormat format, + OpenApiFormat format, OpenApiWriterSettings settings) where T : IOpenApiSerializable { diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs index 970b3a976..176762dc6 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -27,7 +27,7 @@ public static class OpenApiTypeMapper [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 }, @@ -123,7 +123,7 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema ("boolean", null, true) => typeof(bool?), _ => typeof(string), }; - + return type; } } diff --git a/src/Microsoft.OpenApi/Interfaces/IEffective.cs b/src/Microsoft.OpenApi/Interfaces/IEffective.cs index b62ec12ab..b3ac0a37b 100644 --- a/src/Microsoft.OpenApi/Interfaces/IEffective.cs +++ b/src/Microsoft.OpenApi/Interfaces/IEffective.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Models; @@ -9,8 +9,8 @@ namespace Microsoft.OpenApi.Interfaces /// OpenApiElements that implement IEffective indicate that their description is not self-contained. /// External elements affect the effective description. /// - /// Currently this will only be used for accessing external references. - /// In the next major version, this will be the approach accessing all referenced elements. + /// Currently this will only be used for accessing external references. + /// In the next major version, this will be the approach accessing all referenced elements. /// This will enable us to support merging properties that are peers of the $ref /// Type of OpenApi Element that is being referenced. public interface IEffective where T : class,IOpenApiElement diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiElement.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiElement.cs index 45f7bad11..d66939532 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiElement.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiElement.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Interfaces { diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs index 7abd1bfdd..8fc4e8051 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Any; diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs index a9ea04a39..ad6f2c0e5 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs index c790e1fda..e5d0b73b4 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiSerializable.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiSerializable.cs index 582bd49cd..6f5b1bd09 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiSerializable.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiSerializable.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Writers; diff --git a/src/Microsoft.OpenApi/JsonPointer.cs b/src/Microsoft.OpenApi/JsonPointer.cs index c2aec5097..1ff843031 100644 --- a/src/Microsoft.OpenApi/JsonPointer.cs +++ b/src/Microsoft.OpenApi/JsonPointer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Linq; diff --git a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs index e6aa5d075..62c8f560f 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Expressions; @@ -103,7 +103,7 @@ public void SerializeAsV3(IOpenApiWriter writer) } /// - /// Returns an effective OpenApiCallback object based on the presence of a $ref + /// Returns an effective OpenApiCallback object based on the presence of a $ref /// /// The host OpenApiDocument that contains the reference. /// OpenApiCallback diff --git a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs index a6bfef594..5a653aa2a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; @@ -117,7 +117,7 @@ public void SerializeAsV3(IOpenApiWriter writer) }); } writer.WriteEndObject(); - return; + return; } writer.WriteStartObject(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiConstants.cs b/src/Microsoft.OpenApi/Models/OpenApiConstants.cs index 553844764..eccf3a616 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiConstants.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiConstants.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; diff --git a/src/Microsoft.OpenApi/Models/OpenApiContact.cs b/src/Microsoft.OpenApi/Models/OpenApiContact.cs index 93cb11bca..2550f866b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiContact.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiContact.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs index 9ae7f0e6a..c1b4d913c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index d2d9cf893..c19de5e84 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -187,7 +187,7 @@ public void SerializeAsV2(IOpenApiWriter writer) } else { - // Serialize each referenceable object as full object without reference if the reference in the object points to itself. + // Serialize each referenceable object as full object without reference if the reference in the object points to itself. // If the reference exists but points to other objects, the object is serialized to just that reference. // definitions writer.WriteOptionalMap( @@ -208,8 +208,8 @@ public void SerializeAsV2(IOpenApiWriter writer) }); } // parameters - var parameters = Components?.Parameters != null - ? new Dictionary(Components.Parameters) + var parameters = Components?.Parameters != null + ? new Dictionary(Components.Parameters) : new Dictionary(); if (Components?.RequestBodies != null) @@ -309,7 +309,7 @@ private static void WriteHostInfoV2(IOpenApiWriter writer, IList return; } - // Arbitrarily choose the first server given that V2 only allows + // Arbitrarily choose the first server given that V2 only allows // one host, port, and base path. var serverUrl = ParseServerUrl(servers.First()); @@ -323,7 +323,7 @@ private static void WriteHostInfoV2(IOpenApiWriter writer, IList writer.WriteProperty( OpenApiConstants.Host, firstServerUrl.GetComponents(UriComponents.Host | UriComponents.Port, UriFormat.SafeUnescaped)); - + // basePath if (firstServerUrl.AbsolutePath != "/") { @@ -407,7 +407,7 @@ public IOpenApiReferenceable ResolveReference(OpenApiReference reference) } /// - /// Takes in an OpenApi document instance and generates its hash value + /// Takes in an OpenApi document instance and generates its hash value /// /// The OpenAPI description to hash. /// The hash value. diff --git a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs index 13b6e3a0a..d5b0a2057 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Extensions; diff --git a/src/Microsoft.OpenApi/Models/OpenApiError.cs b/src/Microsoft.OpenApi/Models/OpenApiError.cs index 82f2a14df..54b98a067 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiError.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiError.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Exceptions; diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index 4d091a361..018a46729 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Any; @@ -101,7 +101,7 @@ public void SerializeAsV3(IOpenApiWriter writer) } /// - /// Returns an effective OpenApiExample object based on the presence of a $ref + /// Returns an effective OpenApiExample object based on the presence of a $ref /// /// The host OpenApiDocument that contains the reference. /// OpenApiExample diff --git a/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs b/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs index 40c26d429..02945e0f9 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; @@ -31,7 +31,7 @@ protected OpenApiExtensibleDictionary( IDictionary extensions = null) : base (dictionary) { Extensions = extensions != null ? new Dictionary(extensions) : null; - } + } /// /// This object MAY be extended with Specification Extensions. diff --git a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs index 345f07d59..3bcdbc07b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index fb4411478..ad6b3d91f 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Any; @@ -141,7 +141,7 @@ public void SerializeAsV3(IOpenApiWriter writer) } /// - /// Returns an effective OpenApiHeader object based on the presence of a $ref + /// Returns an effective OpenApiHeader object based on the presence of a $ref /// /// The host OpenApiDocument that contains the reference. /// OpenApiHeader diff --git a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs index df0aa0a49..ecba7a6d7 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs index 866515835..a02b50756 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs index b682744e9..54713c242 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Any; @@ -111,7 +111,7 @@ public void SerializeAsV3(IOpenApiWriter writer) } /// - /// Returns an effective OpenApiLink object based on the presence of a $ref + /// Returns an effective OpenApiLink object based on the presence of a $ref /// /// The host OpenApiDocument that contains the reference. /// OpenApiLink diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 63a58cd02..cebfa995c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Any; diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs index 9c12fb5a9..fc92f7bac 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs index 8443e6730..c7b73f22d 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Any; diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 9336662d8..808e50aa0 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -314,7 +314,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // schemes // All schemes in the Servers are extracted, regardless of whether the host matches - // the host defined in the outermost Swagger object. This is due to the + // the host defined in the outermost Swagger object. This is due to the // inaccessibility of information for that host in the context of an inner object like this Operation. if (Servers != null) { diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 06e5749e6..ace76ae4b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -78,7 +78,7 @@ public class OpenApiParameter : IOpenApiSerializable, IOpenApiReferenceable, IEf /// for cookie - form. /// public ParameterStyle? Style - { + { get => _style ?? SetDefaultStyleValue(); set => _style = value; } @@ -190,7 +190,7 @@ public void SerializeAsV3(IOpenApiWriter writer) { Reference.SerializeAsV3(writer); return; - } + } else { target = this.GetEffective(Reference.HostDocument); @@ -201,7 +201,7 @@ public void SerializeAsV3(IOpenApiWriter writer) } /// - /// Returns an effective OpenApiParameter object based on the presence of a $ref + /// Returns an effective OpenApiParameter object based on the presence of a $ref /// /// The host OpenApiDocument that contains the reference. /// OpenApiParameter @@ -289,7 +289,7 @@ public void SerializeAsV2(IOpenApiWriter writer) { Reference.SerializeAsV2(writer); return; - } + } else { target = this.GetEffective(Reference.HostDocument); diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs index ddd358dc2..2f4568e7d 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Extensions; @@ -102,7 +102,7 @@ public void SerializeAsV3(IOpenApiWriter writer) { Reference.SerializeAsV3(writer); return; - } + } else { target = GetEffective(Reference.HostDocument); @@ -112,7 +112,7 @@ public void SerializeAsV3(IOpenApiWriter writer) } /// - /// Returns an effective OpenApiPathItem object based on the presence of a $ref + /// Returns an effective OpenApiPathItem object based on the presence of a $ref /// /// The host OpenApiDocument that contains the reference. /// OpenApiPathItem @@ -146,7 +146,7 @@ public void SerializeAsV2(IOpenApiWriter writer) { Reference.SerializeAsV2(writer); return; - } + } else { target = this.GetEffective(Reference.HostDocument); diff --git a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs index 8aae74883..014b37a1a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Models { @@ -17,6 +17,6 @@ public OpenApiPaths() {} /// Initializes a copy of object /// /// The . - public OpenApiPaths(OpenApiPaths paths) : base(dictionary: paths) { } + public OpenApiPaths(OpenApiPaths paths) : base(dictionary: paths) { } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index e8798cc64..17055a93e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; @@ -205,7 +205,7 @@ private string GetExternalReferenceV3() { return ExternalResource + "#" + Id; } - + return ExternalResource + "#/components/" + Type.GetDisplayName() + "/"+ Id; } diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index 70f1f742a..27b48909a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -93,7 +93,7 @@ public void SerializeAsV3(IOpenApiWriter writer) } /// - /// Returns an effective OpenApiRequestBody object based on the presence of a $ref + /// Returns an effective OpenApiRequestBody object based on the presence of a $ref /// /// The host OpenApiDocument that contains the reference. /// OpenApiRequestBody @@ -187,7 +187,7 @@ internal IEnumerable ConvertToFormDataParameters() Description = property.Value.Description, Name = property.Key, Schema = property.Value, - Required = Content.First().Value.Schema.Required.Contains(property.Key) + Required = Content.First().Value.Schema.Required.Contains(property.Key) }; } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index a173f6c1a..e15e81aaf 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; @@ -98,7 +98,7 @@ public void SerializeAsV3(IOpenApiWriter writer) } /// - /// Returns an effective OpenApiRequestBody object based on the presence of a $ref + /// Returns an effective OpenApiRequestBody object based on the presence of a $ref /// /// The host OpenApiDocument that contains the reference. /// OpenApiResponse diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponses.cs b/src/Microsoft.OpenApi/Models/OpenApiResponses.cs index aa7a8c984..483524044 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponses.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponses.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Models { diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index b0ac2dbac..303f3ee31 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; @@ -487,7 +487,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) } /// - /// Serialize to Open Api v2.0 and handles not marking the provided property + /// Serialize to Open Api v2.0 and handles not marking the provided property /// as readonly if its included in the provided list of required properties of parent schema. /// /// The open api writer. @@ -545,7 +545,7 @@ internal void SerializeAsV2( } /// - /// Serialize to OpenAPI V2 document without using reference and handles not marking the provided property + /// Serialize to OpenAPI V2 document without using reference and handles not marking the provided property /// as readonly if its included in the provided list of required properties of parent schema. /// /// The open api writer. @@ -771,7 +771,7 @@ internal void WriteAsSchemaProperties( } /// - /// Returns an effective OpenApiSchema object based on the presence of a $ref + /// Returns an effective OpenApiSchema object based on the presence of a $ref /// /// The host OpenApiDocument that contains the reference. /// OpenApiSchema diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs index d2564daf2..2ccb58a52 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 616a6a022..20676ded6 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Models/OpenApiServer.cs b/src/Microsoft.OpenApi/Models/OpenApiServer.cs index a13a6fb2d..dcb2382a1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServer.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServer.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; diff --git a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs index 70164bc59..92265a386 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Any; diff --git a/src/Microsoft.OpenApi/Models/OpenApiTag.cs b/src/Microsoft.OpenApi/Models/OpenApiTag.cs index ba4129142..2794fda8e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiTag.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiTag.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Any; diff --git a/src/Microsoft.OpenApi/Models/OpenApiXml.cs b/src/Microsoft.OpenApi/Models/OpenApiXml.cs index c6719d85e..0a594c773 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiXml.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiXml.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Models/OperationType.cs b/src/Microsoft.OpenApi/Models/OperationType.cs index a85933d9b..ed3457353 100644 --- a/src/Microsoft.OpenApi/Models/OperationType.cs +++ b/src/Microsoft.OpenApi/Models/OperationType.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Attributes; diff --git a/src/Microsoft.OpenApi/Models/ParameterLocation.cs b/src/Microsoft.OpenApi/Models/ParameterLocation.cs index a729f314e..d223cad87 100644 --- a/src/Microsoft.OpenApi/Models/ParameterLocation.cs +++ b/src/Microsoft.OpenApi/Models/ParameterLocation.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Attributes; diff --git a/src/Microsoft.OpenApi/Models/ParameterStyle.cs b/src/Microsoft.OpenApi/Models/ParameterStyle.cs index a1df27962..2534b2859 100644 --- a/src/Microsoft.OpenApi/Models/ParameterStyle.cs +++ b/src/Microsoft.OpenApi/Models/ParameterStyle.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Attributes; diff --git a/src/Microsoft.OpenApi/Models/ReferenceType.cs b/src/Microsoft.OpenApi/Models/ReferenceType.cs index 9d8984c96..acbb22a9a 100644 --- a/src/Microsoft.OpenApi/Models/ReferenceType.cs +++ b/src/Microsoft.OpenApi/Models/ReferenceType.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Attributes; diff --git a/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs b/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs index 1a1f12a18..43af59f5b 100644 --- a/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs +++ b/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Expressions; diff --git a/src/Microsoft.OpenApi/Models/SecuritySchemeType.cs b/src/Microsoft.OpenApi/Models/SecuritySchemeType.cs index d75524bd6..f5136ab19 100644 --- a/src/Microsoft.OpenApi/Models/SecuritySchemeType.cs +++ b/src/Microsoft.OpenApi/Models/SecuritySchemeType.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Attributes; diff --git a/src/Microsoft.OpenApi/OpenApiFormat.cs b/src/Microsoft.OpenApi/OpenApiFormat.cs index 8f4c55b68..8005d7d62 100644 --- a/src/Microsoft.OpenApi/OpenApiFormat.cs +++ b/src/Microsoft.OpenApi/OpenApiFormat.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi { diff --git a/src/Microsoft.OpenApi/OpenApiSpecVersion.cs b/src/Microsoft.OpenApi/OpenApiSpecVersion.cs index 20e49af80..48666ab79 100644 --- a/src/Microsoft.OpenApi/OpenApiSpecVersion.cs +++ b/src/Microsoft.OpenApi/OpenApiSpecVersion.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi { @@ -15,7 +15,7 @@ public enum OpenApiSpecVersion /// /// Represents all patches of OpenAPI V3.0 spec (e.g. 3.0.0, 3.0.1) - /// + /// OpenApi3_0 } } diff --git a/src/Microsoft.OpenApi/Properties/AssemblyInfo.cs b/src/Microsoft.OpenApi/Properties/AssemblyInfo.cs index 159c979dd..559c86738 100644 --- a/src/Microsoft.OpenApi/Properties/AssemblyInfo.cs +++ b/src/Microsoft.OpenApi/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Runtime.CompilerServices; diff --git a/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs b/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs index 7e2ebdcac..7984b6c58 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiReferenceError.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs b/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs index dc0fb1c8d..88621a382 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs index 9f4ccb8be..d43e728fd 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs @@ -268,7 +268,7 @@ public void WriteMermaid(TextWriter writer) { "DELETE", new MermaidNodeStyle("Tomato", MermaidNodeShape.Rhombus) }, { "OTHER", new MermaidNodeStyle("White", MermaidNodeShape.SquareCornerRectangle) }, }; - + private static void ProcessNode(OpenApiUrlTreeNode node, TextWriter writer) { var path = string.IsNullOrEmpty(node.Path) ? "/" : SanitizeMermaidNode(node.Path); @@ -329,7 +329,7 @@ private static string SanitizeMermaidNode(string token) .Replace(".", "_") .Replace("(", "_") .Replace(")", "_") - .Replace(";", "_") + .Replace(";", "_") .Replace("-", "_") .Replace("graph", "gra_ph") // graph is a reserved word .Replace("default", "def_ault"); // default is a reserved word for classes diff --git a/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs b/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs index c9679381a..1628ccd00 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -22,7 +22,7 @@ public abstract class OpenApiVisitorBase public CurrentKeys CurrentKeys { get; } = new CurrentKeys(); /// - /// Allow Rule to indicate validation error occured at a deeper context level. + /// Allow Rule to indicate validation error occured at a deeper context level. /// /// Identifier for context public virtual void Enter(string segment) diff --git a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs index 1da6cc9cf..87db2b844 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -297,7 +297,7 @@ internal void Walk(IOpenApiExtensible openApiExtensible) } /// - /// Visits + /// Visits /// internal void Walk(IOpenApiExtension extension) { diff --git a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs index 7827a50c1..f8920efd4 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -29,7 +29,7 @@ public IEnumerable Documents { get { return _documents.Values; } - } + } /// /// A list of document fragments that are contained in the workspace @@ -69,7 +69,7 @@ public OpenApiWorkspace() public OpenApiWorkspace(OpenApiWorkspace workspace){} /// - /// Verify if workspace contains a document based on its URL. + /// Verify if workspace contains a document based on its URL. /// /// A relative or absolute URL of the file. Use file:// for folder locations. /// Returns true if a matching document is found. @@ -95,7 +95,7 @@ public void AddDocument(string location, OpenApiDocument document) /// /// /// - /// Not sure how this is going to work. Does the reference just point to the fragment as a whole, or do we need to + /// Not sure how this is going to work. Does the reference just point to the fragment as a whole, or do we need to /// to be able to point into the fragment. Keeping it private until we figure it out. /// public void AddFragment(string location, IOpenApiReferenceable fragment) diff --git a/src/Microsoft.OpenApi/Validations/IValidationContext.cs b/src/Microsoft.OpenApi/Validations/IValidationContext.cs index 7ab4d08e7..2858a239a 100644 --- a/src/Microsoft.OpenApi/Validations/IValidationContext.cs +++ b/src/Microsoft.OpenApi/Validations/IValidationContext.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Validations { @@ -21,7 +21,7 @@ public interface IValidationContext void AddWarning(OpenApiValidatorWarning warning); /// - /// Allow Rule to indicate validation error occured at a deeper context level. + /// Allow Rule to indicate validation error occured at a deeper context level. /// /// Identifier for context void Enter(string segment); diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs index 77480584d..33e088b09 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs @@ -5,7 +5,7 @@ using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Validations -{ +{ /// /// Warnings detected when validating an OpenAPI Element /// diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs index a0aee12e7..5fb37ad92 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -300,7 +300,7 @@ private void Validate(T item) } /// - /// This overload allows applying rules based on actual object type, rather than matched interface. This is + /// This overload allows applying rules based on actual object type, rather than matched interface. This is /// needed for validating extensions. /// private void Validate(object item, Type type) diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidatorError.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidatorError.cs index c24d48fe3..216b688a5 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidatorError.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidatorError.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs index 60267a26d..468e97447 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiComponentsRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Text.RegularExpressions; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs index f518453f7..d71db1822 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiContactRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiDocumentRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiDocumentRules.cs index e5193b4c2..7d01f1319 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiDocumentRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiDocumentRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs index c44983ffb..c95477c87 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExtensionRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Interfaces; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExternalDocsRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExternalDocsRules.cs index a54651073..8556eaa32 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiExternalDocsRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiExternalDocsRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs index 9ffbc38f4..cf9200917 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiInfoRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiInfoRules.cs index e02f019e2..f3ddbfa28 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiInfoRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiInfoRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiLicenseRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiLicenseRules.cs index d854268c6..89b88ca9d 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiLicenseRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiLicenseRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs index 21ad4ef72..f4cc4b2ab 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiOAuthFlowRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiOAuthFlowRules.cs index 7d900e1b4..95444fb9a 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiOAuthFlowRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiOAuthFlowRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs index d38bd7f9e..878e2db10 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; @@ -97,13 +97,13 @@ public static class OpenApiParameterRules }); /// - /// Validate that a path parameter should always appear in the path + /// Validate that a path parameter should always appear in the path /// public static ValidationRule PathParameterShouldBeInThePath => new ValidationRule( (context, parameter) => { - if (parameter.In == ParameterLocation.Path && + if (parameter.In == ParameterLocation.Path && !(context.PathString.Contains("{" + parameter.Name + "}") || context.PathString.Contains("#/components"))) { context.Enter("in"); diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs index 7ac374b62..669e27bb0 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponseRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponseRules.cs index 6aae427d1..11b228e74 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponseRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponseRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponsesRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponsesRules.cs index d05a1229c..5df74c2e9 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponsesRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiResponsesRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Linq; using System.Text.RegularExpressions; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs index a8ed2e93c..6753a3e65 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Properties; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs index 93f0f581f..67fc5eef2 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiTagRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiTagRules.cs index cc4d1f97f..9dac45966 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiTagRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiTagRules.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Models; diff --git a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs index 630dc8e65..25372d575 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Any; diff --git a/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs b/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs index 195df89cd..ed889febd 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/src/Microsoft.OpenApi/Validations/ValidationRule.cs b/src/Microsoft.OpenApi/Validations/ValidationRule.cs index fdbf5c330..5b79a9be2 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRule.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRule.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using Microsoft.OpenApi.Interfaces; diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs index eca7bc8de..a01c4a4bc 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Linq; diff --git a/src/Microsoft.OpenApi/Writers/FormattingStreamWriter.cs b/src/Microsoft.OpenApi/Writers/FormattingStreamWriter.cs index b6db3d1e0..ea4f33f63 100644 --- a/src/Microsoft.OpenApi/Writers/FormattingStreamWriter.cs +++ b/src/Microsoft.OpenApi/Writers/FormattingStreamWriter.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.IO; diff --git a/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs b/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs index 8fcbf10ed..9ea04b400 100644 --- a/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs +++ b/src/Microsoft.OpenApi/Writers/IOpenApiWriter.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Writers { diff --git a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs index 10049974b..86bacb558 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs index 361da3b2a..2c8fc7d68 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using Microsoft.OpenApi.Any; diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs index 4d7f11032..cc88b0582 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -15,7 +15,7 @@ namespace Microsoft.OpenApi.Writers /// public abstract class OpenApiWriterBase : IOpenApiWriter { - + /// /// Settings for controlling how the OpenAPI document will be written out. /// @@ -49,7 +49,7 @@ public OpenApiWriterBase(TextWriter textWriter) : this(textWriter, null) /// /// /// - public OpenApiWriterBase(TextWriter textWriter, OpenApiWriterSettings settings) + public OpenApiWriterBase(TextWriter textWriter, OpenApiWriterSettings settings) { Writer = textWriter; Writer.NewLine = "\n"; diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs index 537273cac..518936b11 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections; diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs index 06fcd0246..6e503f5d6 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs @@ -39,8 +39,8 @@ public class OpenApiWriterSettings /// Indicates how references in the source document should be handled. /// [Obsolete("Use InlineLocalReference and InlineExternalReference settings instead")] - public ReferenceInlineSetting ReferenceInline { - get { return referenceInline; } + public ReferenceInlineSetting ReferenceInline { + get { return referenceInline; } set { referenceInline = value; switch(referenceInline) diff --git a/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs b/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs index 47afdcc31..be8794941 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; @@ -185,7 +185,7 @@ public override void WriteValue(string value) } Writer.Write("|"); - + WriteChompingIndicator(value); // Write indentation indicator when it starts with spaces @@ -193,7 +193,7 @@ public override void WriteValue(string value) { Writer.Write(IndentationString.Length); } - + Writer.WriteLine(); IncreaseIndentation(); @@ -207,7 +207,7 @@ public override void WriteValue(string value) firstLine = false; else Writer.WriteLine(); - + // Indentations for empty lines aren't needed. if (line.Length > 0) { diff --git a/src/Microsoft.OpenApi/Writers/Scope.cs b/src/Microsoft.OpenApi/Writers/Scope.cs index 37093cffc..3bfdb5ef8 100644 --- a/src/Microsoft.OpenApi/Writers/Scope.cs +++ b/src/Microsoft.OpenApi/Writers/Scope.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Writers { diff --git a/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs b/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs index 6e1ea2beb..02d30ec08 100644 --- a/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Globalization; @@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Writers /// public static class SpecialCharacterStringExtensions { - // Plain style strings cannot start with indicators. + // Plain style strings cannot start with indicators. // http://www.yaml.org/spec/1.2/spec.html#indicator// private static readonly char[] _yamlIndicators = { @@ -170,9 +170,9 @@ internal static string GetYamlCompatibleString(this string input) return $"\"{input}\""; } - // If string + // If string // 1) includes a character forbidden in plain string, - // 2) starts with an indicator, OR + // 2) starts with an indicator, OR // 3) has trailing/leading white spaces, // wrap the string in single quote. // http://www.yaml.org/spec/1.2/spec.html#style/flow/plain diff --git a/src/Microsoft.OpenApi/Writers/WriterConstants.cs b/src/Microsoft.OpenApi/Writers/WriterConstants.cs index 5b4f2da91..13e6deabd 100644 --- a/src/Microsoft.OpenApi/Writers/WriterConstants.cs +++ b/src/Microsoft.OpenApi/Writers/WriterConstants.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. namespace Microsoft.OpenApi.Writers { diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs index 3fc77fc01..c6f33d6f5 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs @@ -203,7 +203,7 @@ public static OpenApiDocument CreateOpenApiDocument() Type = "string" } } - } + } }, ["/users"] = new OpenApiPathItem { diff --git a/test/Microsoft.OpenApi.Readers.Tests/DefaultSettingsFixture.cs b/test/Microsoft.OpenApi.Readers.Tests/DefaultSettingsFixture.cs index 64e25fcfb..a694d17b0 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/DefaultSettingsFixture.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/DefaultSettingsFixture.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using FluentAssertions; diff --git a/test/Microsoft.OpenApi.Readers.Tests/DefaultSettingsFixtureCollection.cs b/test/Microsoft.OpenApi.Readers.Tests/DefaultSettingsFixtureCollection.cs index 1b9bd1107..d17520848 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/DefaultSettingsFixtureCollection.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/DefaultSettingsFixtureCollection.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Xunit; diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs index 5b01e0444..0ab0f9bc7 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Threading.Tasks; diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs index cd60aa630..44b5163e3 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using FluentAssertions; using Microsoft.OpenApi.Readers.Exceptions; diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs index 869d43fab..7c3607a33 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs @@ -99,7 +99,7 @@ public Task LoadAsync(Uri uri) return null; } } - + public class ResourceLoader : IStreamLoader { diff --git a/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs index 2ece19537..7a4090c03 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using FluentAssertions; diff --git a/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs index 3875b77b0..ab61456ac 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Globalization; diff --git a/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyTests.cs b/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyTests.cs index 263c28fec..d089ccf24 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using System.Linq; diff --git a/test/Microsoft.OpenApi.Readers.Tests/Properties/AssemblyInfo.cs b/test/Microsoft.OpenApi.Readers.Tests/Properties/AssemblyInfo.cs index c8a317893..62f4c0e52 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Properties/AssemblyInfo.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/Properties/AssemblyInfo.cs @@ -1,3 +1,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs index bd9600e4f..9bd42a0e3 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using FluentAssertions; using Microsoft.OpenApi.Models; diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs index 6b94a161b..40d92075a 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using FluentAssertions; using Microsoft.OpenApi.Models; diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs index 9469de370..ff8285159 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs b/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs index 89468229a..5ab83606e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using FluentAssertions; using Microsoft.OpenApi.Any; diff --git a/test/Microsoft.OpenApi.Readers.Tests/TestHelper.cs b/test/Microsoft.OpenApi.Readers.Tests/TestHelper.cs index c97e35e9b..654be0858 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/TestHelper.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/TestHelper.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using System.Linq; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs index 1ae3678d6..0d91716a3 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using FluentAssertions; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs index 71489d39f..853c1efcb 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using FluentAssertions; using Microsoft.OpenApi.Models; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index 4acdb583f..7926a062b 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Globalization; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs index eb3bb066c..ee9ad85c6 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.IO; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index 76da8a763..30a32ed13 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.IO; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs index 3f46f5a2b..7239139c1 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.IO; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs index c32c15ff4..88179b160 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.IO; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs index 9a75e5c8d..59ee452fb 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.IO; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs index 22f7d1633..e54dbaab3 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.IO; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs index 1a45006db..d396c471b 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using System.Linq; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs index be78f942b..5ce74bc3e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using FluentAssertions; using Microsoft.OpenApi.Models; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs index 0768592b3..32160bcd9 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using System.Linq; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 85a686e49..c7684f8ce 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs index 7f33491ff..ac6750901 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using System.Linq; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs index ead84f201..4ff4b0d42 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using System.Linq; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs index 29b23cb31..5bdad67a9 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.IO; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs index 47983a9a1..f9835bfbb 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using FluentAssertions; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs index 37053c2a4..b81e8d970 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using System.Linq; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs index 3234195e5..13188dba1 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.IO; using FluentAssertions; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index 54553d5a5..1f5483162 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.IO; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs index 9d7a27d72..e5f8e155e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.IO; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs index a10d674a9..c9033832e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.IO; diff --git a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs index efba7b9b0..5466586d0 100644 --- a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs +++ b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/DefaultSettingsFixture.cs b/test/Microsoft.OpenApi.Tests/DefaultSettingsFixture.cs index 9bb685ddc..3a0b8aabe 100644 --- a/test/Microsoft.OpenApi.Tests/DefaultSettingsFixture.cs +++ b/test/Microsoft.OpenApi.Tests/DefaultSettingsFixture.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using FluentAssertions; diff --git a/test/Microsoft.OpenApi.Tests/DefaultSettingsFixtureCollection.cs b/test/Microsoft.OpenApi.Tests/DefaultSettingsFixtureCollection.cs index 4fdfe0b16..22f562c4d 100644 --- a/test/Microsoft.OpenApi.Tests/DefaultSettingsFixtureCollection.cs +++ b/test/Microsoft.OpenApi.Tests/DefaultSettingsFixtureCollection.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using Xunit; diff --git a/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs index c2b6d9597..a0fcb133a 100644 --- a/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs +++ b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -29,7 +29,7 @@ public class OpenApiTypeMapperTests 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) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs index 93b78e71b..5aabd5ef4 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Globalization; using System.IO; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs index 46a6bb772..d6222f2a7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs index 1a99241d1..0e4531551 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index becc91d97..f19895569 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -1697,10 +1697,10 @@ public void SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollectionFo { Info = new OpenApiInfo(), Paths = new OpenApiPaths - { + { ["/foo"] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new Dictionary { [OperationType.Get] = new OpenApiOperation { @@ -1730,7 +1730,7 @@ public void SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollectionFo expected = expected.MakeLineBreaksEnvironmentNeutral(); actual.Should().Be(expected); } - + [Fact] public void SerializeV2DocumentWithStyleAsNullDoesNotWriteOutStyleValue() { @@ -1818,6 +1818,6 @@ public void SerializeV2DocumentWithStyleAsNullDoesNotWriteOutStyleValue() actual = actual.MakeLineBreaksEnvironmentNeutral(); expected = expected.MakeLineBreaksEnvironmentNeutral(); actual.Should().Be(expected); - } + } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs index 24bfca242..7a4b9de50 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using FluentAssertions; using Microsoft.OpenApi.Extensions; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs index e12a7d100..6d756fec5 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Globalization; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs index 7d37fc9a4..ab013e9a2 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using FluentAssertions; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs index d45bd0038..15f081c90 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Globalization; using System.IO; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs index b2395a9ed..052c3264b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs index 46717ecec..87937072e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs index 4a10be0ae..6f06c947d 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Globalization; using System.IO; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs index c59da1e86..600958b97 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using FluentAssertions; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs index 80040f566..c16eccbef 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs index 7d4882bbb..4135e3e50 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index 11d8dc517..b0394ccab 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs index 2a2c65202..a0214fdcd 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Globalization; @@ -54,7 +54,7 @@ public class OpenApiParameterTests OneOf = new List { new OpenApiSchema { Type = "number", Format = "double" }, - new OpenApiSchema { Type = "string" } + new OpenApiSchema { Type = "string" } } }, Examples = new Dictionary diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs index b9edd2a32..e4f1e8582 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using FluentAssertions; using Microsoft.OpenApi.Extensions; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs index 78fcd0d07..6b62e9fe8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Globalization; using System.IO; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs index 0010e8cb6..235da9955 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Globalization; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index d59c026e3..82b65f015 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -430,7 +430,7 @@ public void SerializeAsV2ShouldSetFormatPropertyInParentSchemaIfPresentInChildre OneOf = new List { new OpenApiSchema - { + { Type = "number", Format = "decimal" }, diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs index 7d630c5f6..5087f71dc 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs index 44a388d90..91085e791 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -32,7 +32,7 @@ public class OpenApiSecuritySchemeTests { Description = "description1", Type = SecuritySchemeType.Http, - Scheme = OpenApiConstants.Basic + Scheme = OpenApiConstants.Basic }; @@ -311,7 +311,7 @@ public async Task SerializeReferencedSecuritySchemeAsV3JsonWorksAsync(bool produ var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act - // Add dummy start object, value, and end object to allow SerializeAsV3 to output security scheme + // Add dummy start object, value, and end object to allow SerializeAsV3 to output security scheme // as property name. writer.WriteStartObject(); ReferencedSecurityScheme.SerializeAsV3(writer); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs index e4d4f36fb..23e7fcc00 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using FluentAssertions; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs index 9d50f76f6..74f837aca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerVariableTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using FluentAssertions; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs index 66c0dfd70..a2b49fe18 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Globalization; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs index 9e79c5211..a9744b668 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Properties/AssemblyInfo.cs b/test/Microsoft.OpenApi.Tests/Properties/AssemblyInfo.cs index c8a317893..62f4c0e52 100644 --- a/test/Microsoft.OpenApi.Tests/Properties/AssemblyInfo.cs +++ b/test/Microsoft.OpenApi.Tests/Properties/AssemblyInfo.cs @@ -1,3 +1,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs index 813cb9517..3d488c7db 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/StringExtensions.cs b/test/Microsoft.OpenApi.Tests/StringExtensions.cs index 5b01c97ac..b3b458683 100644 --- a/test/Microsoft.OpenApi.Tests/StringExtensions.cs +++ b/test/Microsoft.OpenApi.Tests/StringExtensions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs index 8188d6334..b6e187360 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs index 221c245a5..7d371c12a 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiExternalDocsValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiExternalDocsValidationTests.cs index fee728f76..ab25b7c28 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiExternalDocsValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiExternalDocsValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs index 429c460a4..aa7afe477 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiInfoValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiInfoValidationTests.cs index 1a58fff04..7793de94e 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiInfoValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiInfoValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiLicenseValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiLicenseValidationTests.cs index 8efb8715c..45bab5671 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiLicenseValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiLicenseValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs index a68d91578..733a468bb 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiOAuthFlowValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiOAuthFlowValidationTests.cs index 02ab469ae..329727b2b 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiOAuthFlowValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiOAuthFlowValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs index 24f28e4eb..1a3b5442b 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs index 57f9f2cae..0c150cd5c 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiResponseValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiResponseValidationTests.cs index 5f4c29173..a3a84af95 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiResponseValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiResponseValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs index 3ea545af9..1760b000f 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -275,7 +275,7 @@ public void ValidateOneOfSchemaPropertyNameContainsPropertySpecifiedInTheDiscrim // Arrange var components = new OpenApiComponents { - Schemas = + Schemas = { { "Person", @@ -309,7 +309,7 @@ public void ValidateOneOfSchemaPropertyNameContainsPropertySpecifiedInTheDiscrim }, Reference = new OpenApiReference { Id = "Person" } } - } + } } }; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiServerValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiServerValidationTests.cs index bbc4c7e10..22b3d706f 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiServerValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiServerValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs index a039b39c2..c917592c4 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs index 58d4d3d4c..5898c1aff 100644 --- a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Linq; diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs index d3c44c29b..a9d2c6694 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs index 44d1be55b..e7980d1c2 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections; diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs index d1839015d..6e6ab8ba3 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -152,7 +152,7 @@ public static IEnumerable StringifiedDateTimes get { return - from input in new [] { + from input in new [] { "2017-1-2", "1999-01-02T12:10:22", "1999-01-03", diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs index 6ac47d6c3..05bb6e909 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System.Collections.Generic; using System.Globalization; diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs index 13f70f1e9..16395fd2b 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections; From eecda3493b6d6e3132c43ae46438c9196645ac16 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 20:09:00 +1100 Subject: [PATCH 28/69] . --- .../Options/CommandOptions.cs | 2 +- .../Exceptions/OpenApiReaderException.cs | 1 - .../OpenApiTextReaderReader.cs | 1 - .../ParsingContext.cs | 1 - .../Services/DefaultStreamLoader.cs | 1 - .../V2/OpenApiDocumentDeserializer.cs | 2 - .../V2/OpenApiV2VersionService.cs | 2 - .../V3/OpenApiComponentsDeserializer.cs | 1 - .../V3/OpenApiMediaTypeDeserializer.cs | 1 - src/Microsoft.OpenApi.Workbench/MainModel.cs | 7 +- .../Exceptions/OpenApiException.cs | 1 - .../OpenApiSerializableExtensions.cs | 1 - .../Models/OpenApiCallback.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 1 - src/Microsoft.OpenApi/Models/OpenApiLink.cs | 1 - .../Models/OpenApiParameter.cs | 4 +- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 6 +- .../Models/OpenApiSecurityScheme.cs | 1 - .../Services/OpenApiReferenceResolver.cs | 1 - .../Services/OpenApiVisitorBase.cs | 3 - .../Services/OpenApiWalker.cs | 5 +- .../Services/SearchResult.cs | 1 - .../Validations/IValidationContext.cs | 1 - .../Rules/OpenApiMediaTypeRules.cs | 1 - .../Validations/ValidationExtensions.cs | 1 - .../Writers/OpenApiWriterSettings.cs | 4 +- .../Services/OpenApiFilterServiceTests.cs | 1 - .../Services/OpenApiServiceTests.cs | 9 +- .../OpenApiWorkspaceStreamTests.cs | 5 - .../ParseNodes/OpenApiAnyConverterTests.cs | 2 - .../ConvertToOpenApiReferenceV3Tests.cs | 2 - .../V2Tests/OpenApiDocumentTests.cs | 6 - .../V2Tests/OpenApiPathItemTests.cs | 1 - .../V2Tests/OpenApiServerTests.cs | 1 - .../V3Tests/OpenApiDocumentTests.cs | 2 - .../V3Tests/OpenApiSchemaTests.cs | 1 - .../GraphTests.cs | 2 - .../Expressions/RuntimeExpressionTests.cs | 3 - .../OpenApiDeprecationExtensionTests.cs | 1 - .../Models/OpenApiDocumentTests.cs | 1 - .../Models/OpenApiReferenceTests.cs | 1 - .../Models/OpenApiSchemaTests.cs | 1 - .../Services/OpenApiValidatorTests.cs | 2 - .../OpenApiComponentsValidationTests.cs | 1 - .../OpenApiReferenceValidationTests.cs | 1 - .../Workspaces/OpenApiWorkspaceTests.cs | 186 +++++------------- .../Writers/OpenApiYamlWriterTests.cs | 3 - 47 files changed, 62 insertions(+), 222 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Options/CommandOptions.cs b/src/Microsoft.OpenApi.Hidi/Options/CommandOptions.cs index 735644970..6fee866cb 100644 --- a/src/Microsoft.OpenApi.Hidi/Options/CommandOptions.cs +++ b/src/Microsoft.OpenApi.Hidi/Options/CommandOptions.cs @@ -104,6 +104,6 @@ public IReadOnlyList